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
8 changes: 8 additions & 0 deletions .github/actions/lit-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ runs:
go mod edit -replace=github.com/lightninglabs/loop=../
go mod edit -replace=github.com/lightninglabs/loop/looprpc=../looprpc
go mod edit -replace=github.com/lightninglabs/loop/swapserverrpc=../swapserverrpc
# Module replacements are not inherited by the combined daemon.
# Keep its proof decoder and other source overrides aligned with Loop.
while IFS= read -r replacement; do
go mod edit "$replacement"
done < <(go mod edit -json ../go.mod | jq -r '
.Replace[] | select(.New.Version != null) |
"-replace=\(.Old.Path)\(if .Old.Version then "@" + .Old.Version else "" end)=\(.New.Path)@\(.New.Version)"
')
go mod tidy
shell: bash

Expand Down
42 changes: 42 additions & 0 deletions assets/tapd_version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package assets

import (
"context"

policy "github.com/lightninglabs/loop/internal/assetpolicy"
)

// MinOnchainSwapTapdVersion is the oldest tapd release that may create new
// shared-kit swap addresses or verify an untrusted HTLC/deposit history. The
// kit checks the running tapd at those RPC boundaries. It does not gate
// ordinary asset payments or local claim/refund witness construction. Recovery
// still needs valid proofs and compliant new transfers; no recovery manager is
// implemented by this version check.
//
// Taproot Assets v0.8.8 fixes asset invoice settlement. Keep the minimum
// in the shared policy used by the client, server, and SDK adapter.
const MinOnchainSwapTapdVersion = policy.MinOnchainSwapTapdVersion

// ErrTapdVersionUnsupported is returned when tapd is older than
// MinOnchainSwapTapdVersion or reports a version that cannot be parsed.
var ErrTapdVersionUnsupported = policy.ErrTapdVersionUnsupported

// CheckOnchainSwapTapdVersion checks a tapd GetInfo version against the shared
// kit's floor. Applications must also check it before offering or funding new
// swaps through APIs outside the kit. This function does not establish that an
// older backend can safely recover an existing swap.
func CheckOnchainSwapTapdVersion(version string) error {
return policy.CheckOnchainSwapTapdVersion(version)
}

// TapdInfoClient is the narrow runtime version boundary shared with on-chain
// swap integrations that perform address creation, offering or funding outside
// the kit helpers.
type TapdInfoClient = policy.TapdInfoClient

// RequireOnchainSwapTapd checks the connected tapd immediately before starting
// an on-chain asset swap operation outside the kit. It leaves ordinary asset
// payments and local recovery signing independent of the version floor.
func RequireOnchainSwapTapd(ctx context.Context, client TapdInfoClient) error {
return policy.RequireOnchainSwapTapd(ctx, client)
}
131 changes: 131 additions & 0 deletions assets/tapd_version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package assets

import (
"context"
"testing"

"github.com/lightninglabs/taproot-assets/taprpc"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
)

// TestCheckOnchainSwapTapdVersion checks the on-chain swap floor against the
// version strings that tapd reports in GetInfo.
func TestCheckOnchainSwapTapdVersion(t *testing.T) {
tests := []struct {
name string
version string
supported bool
}{
{
name: "minimum release",
version: "0.8.8-alpha commit=v0.8.8",
supported: true,
},
{
name: "prefixed minimum release",
version: "v0.8.8",
supported: true,
},
{
name: "minimum release candidate",
version: "0.8.8-alpha.rc1 commit=v0.8.8-rc1",
},
{
name: "newer patch",
version: "0.8.9-alpha",
supported: true,
},
{
name: "newer minor",
version: "0.9.0-alpha",
supported: true,
},
{
name: "newer major",
version: "1.0.0",
supported: true,
},
{
name: "v0.8.6 settlement regression",
version: "0.8.6-alpha",
},
{
name: "older patch",
version: "0.8.7-alpha commit=v0.8.7",
},
{
name: "older minor",
version: "0.7.9",
},
{
name: "empty",
version: "",
},
{
name: "missing patch",
version: "0.8",
},
{
name: "extra component",
version: "0.8.8.1",
},
{
name: "negative component",
version: "0.-8.6",
},
{
name: "not a version",
version: "garbage",
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
err := CheckOnchainSwapTapdVersion(test.version)
if test.supported {
require.NoError(t, err)
return
}
require.ErrorIs(t, err, ErrTapdVersionUnsupported)
})
}
}

// TestMinOnchainSwapTapdVersion checks that the floor itself is a parseable
// release, as an invalid floor would reject every tapd version.
func TestMinOnchainSwapTapdVersion(t *testing.T) {
require.Equal(t, "0.8.8", MinOnchainSwapTapdVersion)
require.NoError(t, CheckOnchainSwapTapdVersion(
MinOnchainSwapTapdVersion,
))
}

type tapdInfoClient struct {
version string
}

func (c tapdInfoClient) GetInfo(context.Context, *taprpc.GetInfoRequest,
...grpc.CallOption) (*taprpc.GetInfoResponse, error) {

return &taprpc.GetInfoResponse{Version: c.version}, nil
}

// TestRequireOnchainSwapTapd exercises the public runtime gate used by other
// applications before offering or funding a new swap through their own APIs.
func TestRequireOnchainSwapTapd(t *testing.T) {
for _, version := range []string{"0.8.7-alpha", "0.8.8-alpha"} {
t.Run(version, func(t *testing.T) {
err := RequireOnchainSwapTapd(t.Context(), tapdInfoClient{
version: version,
})
if version == "0.8.8-alpha" {
require.NoError(t, err)
return
}
require.ErrorIs(t, err, ErrTapdVersionUnsupported)
})
}
require.ErrorIs(t, RequireOnchainSwapTapd(t.Context(), nil),
ErrTapdVersionUnsupported)
}
11 changes: 11 additions & 0 deletions docs/release-notes/release-notes-next.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

#### New Features

* Share asset deposit, reservation and CSV/CLTV HTLC contracts through
`swapkit`, with transfer, signing, proof and recovery helpers backed by
`github.com/lightninglabs/tap-sdk` v0.1.1 and Taproot Assets v0.8.8. New on-chain
asset swaps require tapd v0.8.8 or later. Shared helpers also authenticate
group issuance evidence and register issuance metadata before verification.

#### Breaking Changes

#### Bug Fixes
Expand All @@ -15,6 +21,11 @@
already using, and a failed lock no longer resets deposits that a withdrawal
or a channel open has taken.

* Harden the shared `swapkit` adapter against hostile peer input: bind a
recovery fallback to the authenticated deposit before co-signing, verify a
caller-provided asset witness before declaring it, recognize annex spends,
and report a reorg during outcome verification as retryable.

#### Maintenance

#### Contributors (Alphabetical Order)
47 changes: 27 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/btcsuite/btcd/btcutil/psbt v1.1.10
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
github.com/btcsuite/btclog/v2 v2.0.1-0.20250728225537-6090e87c6c5b
github.com/btcsuite/btcwallet v0.16.18
github.com/btcsuite/btcwallet v0.16.19
github.com/btcsuite/btcwallet/wtxmgr v1.5.6
github.com/davecgh/go-spew v1.1.1
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0
Expand All @@ -16,35 +16,37 @@ require (
github.com/google/go-cmp v0.7.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0
github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438
github.com/jackc/pgx/v5 v5.9.2
github.com/jackc/pgx/v5 v5.11.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/lndclient v0.21.0-2
github.com/lightninglabs/loop/looprpc v1.0.17-0.20261021185954-333ed1efccdd
github.com/lightninglabs/loop/swapserverrpc v1.0.14
github.com/lightninglabs/taproot-assets v0.8.1
github.com/lightninglabs/taproot-assets/taprpc v1.2.0
github.com/lightninglabs/tap-sdk v0.1.1
github.com/lightninglabs/taproot-assets v0.8.8
github.com/lightninglabs/taproot-assets/taprpc v1.3.3
github.com/lightningnetwork/lightning-onion v1.3.0
github.com/lightningnetwork/lnd v0.21.0-beta
github.com/lightningnetwork/lnd v0.21.3-beta
github.com/lightningnetwork/lnd/cert v1.2.2
github.com/lightningnetwork/lnd/clock v1.1.1
github.com/lightningnetwork/lnd/queue v1.2.0
github.com/lightningnetwork/lnd/ticker v1.1.1
github.com/lightningnetwork/lnd/tlv v1.3.2
github.com/lightningnetwork/lnd/tor v1.1.6
github.com/lightningnetwork/lnd/tor v1.1.7
github.com/ory/dockertest/v3 v3.10.0
github.com/stretchr/testify v1.11.1
github.com/urfave/cli-docs/v3 v3.1.1-0.20251020101624-bec07369b4f6
github.com/urfave/cli/v3 v3.4.1
go.etcd.io/bbolt v1.4.3
golang.org/x/crypto v0.55.0
golang.org/x/sync v0.22.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20260803160001-6ac0973c030d
google.golang.org/grpc v1.83.2
google.golang.org/protobuf v1.36.11
gopkg.in/macaroon-bakery.v2 v2.3.0
gopkg.in/macaroon.v2 v2.1.0
modernc.org/sqlite v1.34.5
modernc.org/sqlite v1.59.0
)

require (
Expand Down Expand Up @@ -85,7 +87,7 @@ require (
github.com/docker/go-connections v0.7.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/felixge/httpsnoop v1.1.0 // indirect
github.com/fergusstrange/embedded-postgres v1.25.0 // indirect
github.com/go-logr/logr v1.4.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand All @@ -94,7 +96,7 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/golang/snappy v1.0.0 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.6.0 // indirect
Expand All @@ -115,6 +117,7 @@ require (
github.com/kkdai/bstream v1.0.0 // indirect
github.com/klauspost/compress v1.18.7 // indirect
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf // indirect
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.4-0.20250610182311-2f1d46ef18b7 // indirect
github.com/lightninglabs/neutrino v0.17.1 // indirect
github.com/lightninglabs/neutrino/cache v1.1.3 // indirect
github.com/lightningnetwork/lnd/actor v0.0.6 // indirect
Expand All @@ -123,8 +126,7 @@ require (
github.com/lightningnetwork/lnd/kvdb v1.5.1 // indirect
github.com/lightningnetwork/lnd/sqldb v1.0.13 // 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
github.com/mattn/go-isatty v0.0.24 // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/moby/api v1.54.2 // indirect
Expand All @@ -133,15 +135,16 @@ require (
github.com/moby/term v0.5.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.1 // indirect
github.com/opencontainers/runc v1.3.6 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rogpeppe/fastuuid v1.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand Down Expand Up @@ -178,8 +181,8 @@ require (
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.24.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.55.0 // indirect
golang.org/x/exp v0.0.0-20250811191247-51f88131bc50 // indirect
golang.org/x/mod v0.38.0 // indirect
golang.org/x/net v0.58.0 // indirect
Expand All @@ -194,9 +197,9 @@ require (
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/libc v1.55.3 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/libc v1.75.7 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.12.1 // indirect
pgregory.net/rapid v1.2.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)
Expand Down Expand Up @@ -239,3 +242,7 @@ godebug multipathtcp=0
// vulnerable legacy pgx v4/pgproto3 dependency chain. Remove this replacement
// once the required lnd version includes an sqldb release with that migration.
replace github.com/lightningnetwork/lnd/sqldb v1.0.13 => github.com/lightningnetwork/lnd/sqldb v1.0.13-0.20260514041430-e9b422f78581

// Match the bounded legacy TLV decoder shipped with tapd v0.8.8. Replacements
// are not inherited: consuming binaries must include this pin as well.
replace github.com/lightningnetwork/lnd/tlv => github.com/lightninglabs/taproot-assets/third_party/lnd/tlv v0.0.0-20261022183431-6e0fef585a97
Loading
Loading