Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ on:
push:
branches:
- 'main'
- '*-staging'
pull_request:
branches:
- '*'
merge_group:
branches:
- 'main'
- '*-staging'

defaults:
run:
Expand Down
38 changes: 38 additions & 0 deletions address/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,33 @@ const (
StatusCompleted Status = 3
)

// SortDirection is an enum used to specify the order of returned events.
type SortDirection uint8

const (
// UndefinedSortDirection indicates that the sort direction
// is not specified.
UndefinedSortDirection SortDirection = iota

// DescSortDirection indicates that the sort should be in
// descending order.
DescSortDirection

// AscSortDirection indicates that the sort should be in
// ascending order.
AscSortDirection
)

const (
// DefaultEventQueryLimit is the number of events returned
// when no limit is provided.
DefaultEventQueryLimit = 512

// MaxEventQueryLimit is the maximum number of events that can be
// returned in a single query.
MaxEventQueryLimit = 16384
)

// EventQueryParams holds the set of query params for address events.
type EventQueryParams struct {
// AddrTaprootOutputKey is the optional 32-byte x-only serialized
Expand All @@ -65,6 +92,17 @@ type EventQueryParams struct {
// (inclusive). Can be set to nil to return events of all creation
// times.
CreationTimeTo *time.Time

// Offset is the offset into the result set to start returning events.
Offset int32

// Limit is the max number of events that should be returned. If zero,
// then DefaultEventQueryLimit will be used.
Limit int32

// SortDirection is the sort direction to use when returning the
// events. The default zero value sorts the events in ascending order.
SortDirection SortDirection
}

// AssetOutput holds the information about a single asset output that was sent
Expand Down
24 changes: 24 additions & 0 deletions cmd/commands/addrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ const (
limitName = "limit"

offsetName = "offset"

directionName = "direction"
)

var queryAddrsCommand = cli.Command{
Expand Down Expand Up @@ -293,6 +295,20 @@ var receivesAddrCommand = cli.Command{
Usage: "filter transfers created before this + " +
"unix timestamp (seconds)",
},
cli.Int64Flag{
Name: limitName,
Usage: "the max number of events returned",
},
cli.Int64Flag{
Name: offsetName,
Usage: "the number of events to skip",
},
cli.StringFlag{
Name: directionName,
Usage: "the sort direction for events (asc or desc). " +
"Defaults to desc.",
Value: "desc",
},
},
Action: addrReceives,
}
Expand All @@ -311,10 +327,18 @@ func addrReceives(ctx *cli.Context) error {
addr = ctx.Args().First()
}

direction := taprpc.SortDirection_SORT_DIRECTION_DESC
if ctx.String(directionName) == "asc" {
direction = taprpc.SortDirection_SORT_DIRECTION_ASC
}

resp, err := client.AddrReceives(ctxc, &taprpc.AddrReceivesRequest{
FilterAddr: addr,
StartTimestamp: ctx.Uint64("start_timestamp"),
EndTimestamp: ctx.Uint64("end_timestamp"),
Limit: int32(ctx.Int64(limitName)),
Offset: int32(ctx.Int64(offsetName)),
Direction: direction,
})
if err != nil {
return fmt.Errorf("unable to query addr receives: %w", err)
Expand Down
38 changes: 36 additions & 2 deletions docs/examples/basic-price-oracle/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/keepalive"
)

const (
Expand Down Expand Up @@ -455,11 +456,44 @@ func main() {
log.Fatalf("Failed to generate TLS certificate: %v", err)
}

// Create the gRPC server with TLS
// Configure server-side keepalive parameters. These settings ensure the
// server actively probes client connection health and allows long-lived
// idle connections.
serverKeepalive := keepalive.ServerParameters{
// Ping clients after 1 minute of inactivity.
Time: time.Minute,

// Wait 20 seconds for ping response.
Timeout: 20 * time.Second,

// Allow connections to stay idle for 24 hours. The active
// pinging mechanism (via Time parameter) handles health
// checking, so we don't need aggressive idle timeouts.
MaxConnectionIdle: time.Hour * 24,
}

// Configure client keepalive enforcement policy. This tells the server
// how to handle client keepalive pings.
clientKeepalive := keepalive.EnforcementPolicy{
// Allow client to ping even when there are no active RPCs.
// This is critical for long-lived connections with infrequent
// price queries.
PermitWithoutStream: true,

// Prevent abusive clients from pinging too frequently (DoS
// protection).
MinTime: 5 * time.Second,
}

// Create the gRPC server with TLS and keepalive configuration.
transportCredentials := credentials.NewTLS(&tls.Config{
Certificates: []tls.Certificate{tlsCert},
})
backendService := grpc.NewServer(grpc.Creds(transportCredentials))
backendService := grpc.NewServer(
grpc.Creds(transportCredentials),
grpc.KeepaliveParams(serverKeepalive),
grpc.KeepaliveEnforcementPolicy(clientKeepalive),
)

err = startService(backendService)
if err != nil {
Expand Down
18 changes: 18 additions & 0 deletions docs/release-notes/release-notes-0.7.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@
dirty. This issue has been resolved, and the behavior is now consistent across
all database backend types.

- [Fixed "connection reset by peer" errors in RFQ price oracle
connections](https://github.com/lightninglabs/taproot-assets/pull/1834) by
implementing comprehensive bidirectional gRPC keepalive configuration. The
issue occurred when connections sat idle between RFQ price queries and were
silently closed by the network layer or server timeout, causing the first
payment attempt after an idle period to fail. The fix adds client-side
keepalive pings every 30 seconds and extends the server's idle connection
timeout from 2 minutes to 24 hours, while enabling active health checking on
both sides. This ensures connections remain alive during infrequent RFQ
operations and any network issues are detected promptly rather than
discovered only when the next RPC fails.

# New Features

## Functional Enhancements
Expand Down Expand Up @@ -198,6 +210,9 @@
information directly from the RPC response without performing separate
blockchain queries.

- The `AddrReceives` RPC has new fields `limit`, `offset` and `direction` that
allows pagination and sorting. [See PR](https://github.com/lightninglabs/taproot-assets/pull/1813).

## tapcli Additions

- [Rename](https://github.com/lightninglabs/taproot-assets/pull/1682) the mint
Expand All @@ -219,6 +234,9 @@
- The `tapcli addrs receives` command now supports
[new `--start_timestamp` and `--end_timestamp` flags](https://github.com/lightninglabs/taproot-assets/pull/1794).

- The `tapcli addrs receives` command now has new flags `--limit`, `--offset` and
`--direction` that allows pagination and sorting. [See PR](https://github.com/lightninglabs/taproot-assets/pull/1813).

- The `fetchsupplycommit` command [now supports](https://github.com/lightninglabs/taproot-assets/pull/1823)
a `--first` flag to fetch the very first supply commitment; if no flag is
provided, it defaults to fetching the latest. Only one of `--first`,
Expand Down
70 changes: 70 additions & 0 deletions docs/release-notes/release-notes-0.8.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Release Notes
- [Bug Fixes](#bug-fixes)
- [New Features](#new-features)
- [Functional Enhancements](#functional-enhancements)
- [RPC Additions](#rpc-additions)
- [tapcli Additions](#tapcli-additions)
- [Improvements](#improvements)
- [Functional Updates](#functional-updates)
- [RPC Updates](#rpc-updates)
- [tapcli Updates](#tapcli-updates)
- [Breaking Changes](#breaking-changes)
- [Performance Improvements](#performance-improvements)
- [Deprecations](#deprecations)
- [Technical and Architectural Updates](#technical-and-architectural-updates)
- [BIP/bLIP Spec Updates](#bipblip-spec-updates)
- [Testing](#testing)
- [Database](#database)
- [Code Health](#code-health)
- [Tooling and Documentation](#tooling-and-documentation)

# Bug Fixes

# New Features

## Functional Enhancements

## RPC Additions

## tapcli Additions

# Improvements

## Functional Updates

## RPC Updates

- [PR#1841](https://github.com/lightninglabs/taproot-assets/pull/1841): Remove
the defaultMacaroonWhitelist map and inline its entries directly
into the conditional logic within MacaroonWhitelist. This ensures that
access to previously always-available endpoints is now governed by
explicit user configuration (read/write/courier), improving permission
control and aligning with expected access restrictions.

- [PR#1841](https://github.com/lightninglabs/taproot-assets/pull/1841): Add
default RPC permissions for RPC endpoints universerpc.Universe/Info and
/authmailboxrpc.Mailbox/MailboxInfo.

## tapcli Updates

## Code Health

## Breaking Changes

## Performance Improvements

## Deprecations

# Technical and Architectural Updates

## BIP/bLIP Spec Updates

## Testing

## Database

## Code Health

## Tooling and Documentation

# Contributors (Alphabetical Order)
Loading
Loading