Skip to content
Draft
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
28 changes: 28 additions & 0 deletions authmailbox/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/btcsuite/btclog/v2"
"github.com/lightninglabs/taproot-assets/asset"
"github.com/lightninglabs/taproot-assets/fn"
"github.com/lightninglabs/taproot-assets/internal/test"
"github.com/lightninglabs/taproot-assets/proof"
Expand Down Expand Up @@ -169,6 +170,32 @@ func TestServerClientAuthAndRestart(t *testing.T) {
t.Cleanup(func() {
require.NoError(t, multiSub.Stop())
})
assertMultiSubConnected := func(targetKeys ...keychain.KeyDescriptor) {
t.Helper()

serverURL := url.URL{Host: clientCfg.ServerAddress}
require.Eventually(t, func() bool {
multiSub.RLock()
defer multiSub.RUnlock()

client, ok := multiSub.clients[serverURL]
if !ok {
return false
}

for _, targetKey := range targetKeys {
key := asset.ToSerialized(targetKey.PubKey)
subscription, ok := client.subscriptions[key]
if !ok || !subscription.IsSubscribed() {
return false
}
}

return true
}, testTimeout, testMinBackoff)
}
assertMultiSubConnected(clientKey1, clientKey2)

msgChan := multiSub.MessageChan()
readMultiSub := func(targetID ...uint64) {
t.Helper()
Expand Down Expand Up @@ -221,6 +248,7 @@ func TestServerClientAuthAndRestart(t *testing.T) {
harness.Start(t)
client1.assertConnected(t)
client2.assertConnected(t)
assertMultiSubConnected(clientKey1, clientKey2)

// Let's send another message to all clients.
msg2 := &Message{
Expand Down
10 changes: 6 additions & 4 deletions authmailbox/receive_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"math"
"sync"
"sync/atomic"
"time"

"github.com/btcsuite/btclog/v2"
Expand Down Expand Up @@ -61,6 +62,7 @@ type receiveSubscription struct {
serverStream clientStream
streamMutex sync.RWMutex
streamCancel func()
subscribed atomic.Bool

authOkChan chan struct{}
msgChan chan<- *ReceivedMessages
Expand Down Expand Up @@ -198,10 +200,7 @@ func (s *receiveSubscription) wait(backoff time.Duration) error {
// IsSubscribed returns true if at least one account is in an active state and
// the subscription stream to the server was established successfully.
func (s *receiveSubscription) IsSubscribed() bool {
s.streamMutex.RLock()
defer s.streamMutex.RUnlock()

return s.serverStream != nil
return s.subscribed.Load()
}

// connectServerStream opens the initial connection to the server for the stream
Expand Down Expand Up @@ -412,6 +411,8 @@ func (s *receiveSubscription) readIncomingStream(ctx context.Context) {
// The server confirms the account subscription. Nothing for us
// to do here.
case *respTypeAuthSuccess:
s.subscribed.Store(true)

// Inform the subscription about the arrived auth
// confirmation.
select {
Expand Down Expand Up @@ -476,6 +477,7 @@ func (s *receiveSubscription) closeStream(ctx context.Context) error {

s.streamMutex.Lock()
defer s.streamMutex.Unlock()
s.subscribed.Store(false)

if s.streamCancel != nil {
s.streamCancel()
Expand Down
71 changes: 38 additions & 33 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ module github.com/lightninglabs/taproot-assets
go 1.25.5

require (
github.com/btcsuite/btcd v0.24.3-0.20250318170759-4f4ea81776d6
github.com/btcsuite/btcd v0.25.1-0.20260310163610-1c55c7c18179
github.com/btcsuite/btcd/btcec/v2 v2.3.6
github.com/btcsuite/btcd/btcutil v1.1.5
github.com/btcsuite/btcd/btcutil v1.1.6
github.com/btcsuite/btcd/btcutil/psbt v1.1.10
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c
github.com/btcsuite/btclog v1.0.0
github.com/btcsuite/btclog/v2 v2.0.1-0.20250728225537-6090e87c6c5b
github.com/btcsuite/btcwallet v0.16.17
github.com/btcsuite/btcwallet/wallet/txsizes v1.2.5
github.com/btcsuite/btcwallet/wtxmgr v1.5.6
github.com/caddyserver/certmagic v0.17.2
github.com/davecgh/go-spew v1.1.1
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0
github.com/dustin/go-humanize v1.0.1
github.com/go-errors/errors v1.0.1
github.com/golang-migrate/migrate/v4 v4.17.0
Expand All @@ -24,14 +24,14 @@ require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0
github.com/jackc/pgconn v1.14.3
github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438
github.com/jessevdk/go-flags v1.4.0
github.com/jessevdk/go-flags v1.6.1
github.com/lib/pq v1.10.9
github.com/lightninglabs/aperture v0.4.0
github.com/lightninglabs/aperture v0.3.14-beta
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.4-0.20250610182311-2f1d46ef18b7
github.com/lightninglabs/lndclient v0.20.0-6
github.com/lightninglabs/neutrino/cache v1.1.3
github.com/lightninglabs/taproot-assets/taprpc v1.0.9
github.com/lightningnetwork/lnd v0.20.0-beta.rc4.0.20260305102707-7c38c1ea0572
github.com/lightninglabs/taproot-assets/taprpc v0.0.0-00010101000000-000000000000
github.com/lightningnetwork/lnd v0.20.0-beta.rc4.0.20260323171750-db765a752b63
github.com/lightningnetwork/lnd/cert v1.2.2
github.com/lightningnetwork/lnd/clock v1.1.1
github.com/lightningnetwork/lnd/fn/v2 v2.0.9
Expand All @@ -41,16 +41,16 @@ require (
github.com/ory/dockertest/v3 v3.10.0
github.com/pmezard/go-difflib v1.0.0
github.com/prometheus/client_golang v1.14.0
github.com/stretchr/testify v1.10.0
github.com/stretchr/testify v1.11.1
github.com/urfave/cli v1.22.14
golang.org/x/crypto v0.45.0
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8
golang.org/x/net v0.47.0
golang.org/x/sync v0.18.0
golang.org/x/term v0.37.0
golang.org/x/crypto v0.46.0
golang.org/x/exp v0.0.0-20250811191247-51f88131bc50
golang.org/x/net v0.48.0
golang.org/x/sync v0.19.0
golang.org/x/term v0.38.0
golang.org/x/time v0.5.0
google.golang.org/grpc v1.64.1
google.golang.org/protobuf v1.34.2
google.golang.org/grpc v1.79.1
google.golang.org/protobuf v1.36.10
gopkg.in/macaroon-bakery.v2 v2.1.0
gopkg.in/macaroon.v2 v2.1.0
modernc.org/sqlite v1.34.5
Expand All @@ -68,21 +68,22 @@ require (
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
github.com/aead/siphash v1.0.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd/v2transport v1.0.1 // indirect
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.5 // indirect
github.com/btcsuite/btcwallet/wallet/txrules v1.2.2 // indirect
github.com/btcsuite/btcwallet/walletdb v1.5.1 // indirect
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect
github.com/btcsuite/winsvc v1.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/coder/websocket v1.8.13 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/decred/dcrd/crypto/blake256 v1.1.0 // indirect
github.com/decred/dcrd/lru v1.1.2 // indirect
github.com/docker/cli v28.1.1+incompatible // indirect
github.com/docker/docker v28.1.1+incompatible // indirect
Expand Down Expand Up @@ -129,12 +130,13 @@ require (
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf // indirect
github.com/lightninglabs/lightning-node-connect/gbn v1.0.2-0.20250610182311-2f1d46ef18b7 // indirect
github.com/lightninglabs/lightning-node-connect/mailbox v1.0.2-0.20250610182311-2f1d46ef18b7 // indirect
github.com/lightninglabs/neutrino v0.16.1 // indirect
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240815225420-8b40adf04ab9 // indirect
github.com/lightninglabs/neutrino v0.16.2 // indirect
github.com/lightningnetwork/lightning-onion v1.3.0 // indirect
github.com/lightningnetwork/lnd/actor v0.0.6-0.20260324142747-bee0d598cef8 // indirect
github.com/lightningnetwork/lnd/healthcheck v1.2.6 // indirect
github.com/lightningnetwork/lnd/kvdb v1.4.16 // indirect
github.com/lightningnetwork/lnd/queue v1.1.1 // indirect
github.com/lightningnetwork/lnd/sqldb v1.0.13-0.20260305102707-7c38c1ea0572 // indirect
github.com/lightningnetwork/lnd/sqldb v1.0.13-0.20260324142747-bee0d598cef8 // indirect
github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
Expand Down Expand Up @@ -178,25 +180,25 @@ require (
go.etcd.io/etcd/pkg/v3 v3.5.12 // indirect
go.etcd.io/etcd/raft/v3 v3.5.12 // indirect
go.etcd.io/etcd/server/v3 v3.5.12 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/otel v1.37.0 // indirect
go.opentelemetry.io/otel v1.39.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.29.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.20.0 // indirect
go.opentelemetry.io/otel/metric v1.37.0 // indirect
go.opentelemetry.io/otel/sdk v1.37.0 // indirect
go.opentelemetry.io/otel/trace v1.37.0 // indirect
go.opentelemetry.io/otel/metric v1.39.0 // indirect
go.opentelemetry.io/otel/sdk v1.39.0 // indirect
go.opentelemetry.io/otel/trace v1.39.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.23.0 // indirect
golang.org/x/mod v0.29.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/text v0.31.0 // indirect
golang.org/x/tools v0.38.0 // indirect
golang.org/x/mod v0.30.0 // indirect
golang.org/x/sys v0.39.0 // indirect
golang.org/x/text v0.32.0 // indirect
golang.org/x/tools v0.39.0 // indirect
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
gopkg.in/errgo.v1 v1.0.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand All @@ -215,6 +217,9 @@ replace google.golang.org/protobuf => github.com/lightninglabs/protobuf-go-hex-d
// did not yet make it into the upstream repository.
replace github.com/golang-migrate/migrate/v4 => github.com/lightninglabs/migrate/v4 v4.18.2-9023d66a-fork-pr-2.0.20251211093704-71c1eef09789

// Keep btcwallet aligned with the lnd master snapshot we depend on.
replace github.com/btcsuite/btcwallet => github.com/btcsuite/btcwallet v0.16.17-0.20260213031108-70a94ea39e9c

// Note this is a temproary replace and will be removed when taprpc is tagged.
replace github.com/lightninglabs/taproot-assets/taprpc => ./taprpc

Expand Down
Loading
Loading