Skip to content

assets: Add shared asset tooling - #1225

Draft
hieblmi wants to merge 4 commits into
lightninglabs:masterfrom
hieblmi:codex/shared-asset-swapkit
Draft

assets: Add shared asset tooling#1225
hieblmi wants to merge 4 commits into
lightninglabs:masterfrom
hieblmi:codex/shared-asset-swapkit

Conversation

@hieblmi

@hieblmi hieblmi commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • make Loop the single home for the shared asset HTLC scripts, immutable
    SwapKit, legacy deposit kit, and generic OP_TRUE virtual-packet sweep
    helper
  • preserve the existing deposit contract as the explicit
    LegacyDepositV0 policy, pinned by golden script, key, anchor, witness, and
    virtual-packet vectors
  • expose narrow boundaries that both the client and server can import without
    pulling server-specific code into Loop
  • keep the module graph on Go 1.25, classic btcd, and Taproot Assets v0.8.1;
    this prototype deliberately does not add tap-sdk

Security and correctness boundaries

The shared kit verifies proofs before using them and binds every Bitcoin
spend to the proof's exact anchor outpoint, output value, script, commitment
root, and unique PSBT input. It supplies every prevout to the signer, applies
the required CSV sequence to the matched input without mutating the caller's
PSBT on failure, rejects malformed signer responses, verifies the returned
Schnorr signature, and returns the matched input index to the caller.

The OP_TRUE helper rejects empty, nil, invalid, non-OP_TRUE, mixed-asset,
overflowing, and amount-mismatched proof sets. It derives the network from the
destination address and validates the prepared output and split-root witness
before attaching the asset witness.

Network validation distinguishes shared testnet HRPs by Bitcoin network
magic. Simnet explicitly accepts both btcd's native BIP-0044 coin type 115 and
lnd's testnet-compatible coin type 1 without relying on mutable global state.

Feature state machines remain responsible for trusted proof import,
canonical-chain and confirmation tracking, reorg handling, destination
validation, quote and fee limits, and durable recovery. This PR adds no Asset
Loop Out RPC, funding flow, persistence, or state machine, and does not alter
conventional Loop In or Asset Loop In.

This is prototype infrastructure, not a release or rollout change.

Verification

  • GOTOOLCHAIN=go1.25.12 go test ./assets/... -count=1
  • GOTOOLCHAIN=go1.25.12 go test -race ./assets/... -count=1
  • GOTOOLCHAIN=go1.25.12 go vet ./assets/...
  • GOTOOLCHAIN=go1.25.12 make build
  • GOTOOLCHAIN=go1.25.12 go mod verify
  • GOTOOLCHAIN=go1.25.12 go mod tidy -diff
  • local golangci-lint run -v (zero issues)
  • make commitmsg-lint range=origin/master..HEAD
  • git diff --check origin/master..HEAD

@hieblmi hieblmi added the no-changelog Skip the release notes CI check label Sep 2, 2026
@hieblmi
hieblmi force-pushed the codex/shared-asset-swapkit branch 3 times, most recently from f805e70 to c206f0d Compare September 3, 2026 05:32
Move the existing server asset HTLC contract into Loop so both
sides can derive and spend the same commitment. Freeze the legacy
vectors and bind witness construction to verified proofs, prevouts,
and input indices.

Reserve future policies so Loop Asset Out can choose its contract
explicitly instead of inheriting the deposit key path.
@hieblmi
hieblmi force-pushed the codex/shared-asset-swapkit branch from c206f0d to 2814bf6 Compare September 3, 2026 05:54
@hieblmi hieblmi added asset loop out Taproot Asset Loop Out work and removed no-changelog Skip the release notes CI check labels Sep 3, 2026
@hieblmi hieblmi changed the title assets: Add shared asset HTLC kit assets: Add shared asset tooling Sep 3, 2026
@hieblmi hieblmi added the no-changelog Skip the release notes CI check label Sep 3, 2026
@hieblmi
hieblmi force-pushed the codex/shared-asset-swapkit branch from a33d139 to 4283082 Compare September 3, 2026 08:08
Consolidate the remaining deposit and OP_TRUE virtual-packet helpers
behind Loop-owned packages. Replace positional sweep assumptions with
proof-bound input selection, complete prevout validation, and explicit
signature verification.
@hieblmi
hieblmi force-pushed the codex/shared-asset-swapkit branch from 4283082 to 50595de Compare September 3, 2026 08:12
@hieblmi hieblmi self-assigned this Sep 3, 2026
Reject non-block deposit expiries. This prevents BIP68 flags from
changing or disabling the intended block delay.

Canonicalize OP_TRUE keys, populate and validate every virtual input
witness, and reject unsupported addresses and duplicate anchor inputs.
Return the complete anchor Merkle root from proof verification.

This lets MuSig2 spends reproduce the output's Taproot tweak.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

asset loop out Taproot Asset Loop Out work no-changelog Skip the release notes CI check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant