Skip to content

waved: implement SendAssetOOR RPC, incoming asset OOR receive, and real-engine systest - #1658

Merged
darioAnongba merged 15 commits into
mainfrom
darioAnongba/waved-asset-oor
Nov 30, 2026
Merged

darioAnongba merged 15 commits into
mainfrom
darioAnongba/waved-asset-oor

Conversation

@darioAnongba

@darioAnongba darioAnongba commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Completes the daemon-side out-of-round (OOR) Taproot Assets slice on top of #1619 and #1649:

  1. Daemon SendAssetOOR RPC (waverpc, waved, rpc/restclient):
    • Adds SendAssetOOR to waverpc/daemon.proto + REST gateway mapping (no top-level wavecli user command; reachable via the generated devrpc registry wavecli dev daemon send-asset-oor).
    • Validates operator asset allowlist, advertised OORCarrierPubKey, and destination policies (arkscript.ValidatePolicy), checks canonical v2 oor.OutgoingAssetReplay idempotency identity (isolating Bitcoin and asset idempotency namespaces), selects and locks up to 8 live asset VTXOs (SelectAndReserveAssetSpend in lib/actormsg, vtxo, wallet), checks local carrier preconditions before leasing an operator carrier float (LeaseOORCarrier), plans carrier allocation (returning round-originated carriers as sender Bitcoin change), builds the asset transition via tapassets.BuildOORTransfer with current-operator checkpoint leaves, attaches composed tapleaf scripts, and submits via the durable oor registry (StartTransferRequest.PreparedSubmit).
    • Supports --dry_run preview and idempotency-key replay returning stored summary figures.
  2. Incoming asset OOR verification & sealed-package persistence (tapassets, indexer, serverconn, oor, waved):
    • Adds tapassets.NewOORProofVerifier and VTXOVerifier.VerifyOORAssetVTXO to verify incoming OOR asset packages (including merged multi-input packages) against the embedded asset engine and authenticated Bitcoin/OOR lineage before materialization.
    • Adds optional SignerScript on indexer.TaprootScriptScope and durable serverconn queries so clients resolve the local uncomposed receive key for script_scope proofs while querying composed asset output scripts.
    • Wires VerifyIncomingAssetPackage (nil when Taproot Assets are disabled) synchronously outside the actor SQLite write transaction, isolates per-output asset failures from sibling Bitcoin outputs, retries proof/chain backend failures with bounded backoff, and persists TaprootAssetRoot/Ref/Amount/TaprootAssetSealedPackage (with canonical lowercased Ref) on received VTXOs so unilateral claims and subsequent OOR respends work.
  3. Production fixes surfaced by the real embedded-engine systest and review:
    • Asset batch output expiry authentication (BatchAssetRoot): carries optional 32-byte BatchAssetRoot on tree.Tree, lib/treecodec (TLV type 7), arkrpc.TreePath (field 5), and tapassets.TreeRootAssetSource, folding it via arkscript.TapBranchHash into vtxo.validateExpiryFragment so AuthenticateBatchEvidence authenticates confirmed asset batch outputs.
    • Asset spend reservation opt-in (round.SpendReserveEvent.AllowAssetTransition): keeps plain Bitcoin spends fail-closed with ErrAssetVTXORequiresTransition while letting handleSelectAndReserveAssetSpend and startup reservation redrive transition live asset VTXOs into SpendingState.
    • Stored asset TapScript == nil consistency (oor): aligns TransferInput.Validate, TransferInputFromSnapshot, and incoming asset materialization with db.VTXOStore (asset VTXOs keep TapScript nil and derive composed spend paths from PolicyTemplate + TaprootAssetRoot).
    • Multi-output incoming OOR receive (oor, vtxo): keys completed hints, busy checks, and FIFO parkedSelfHints on IncomingHintKey{ScriptHash, EventID} (handling per-script event IDs starting at 1), tracks MaterializedPlainScripts so completed plain Bitcoin sessions stay dormant without reopening, preserves prior ReceiveCompleted on follow-up failure, rejects stale phase-1 resolutions, and guards persistIncomingDescriptor and handleVTXOsMaterialized against already-terminal stored VTXOs.
  4. Real embedded-engine systest (systest/asset_oor_test.go):
    • TestAssetOORMergeAndClaim runs two real embedded-engine waved daemons against regtest bitcoind, Esplora, and tapd with per-script event IDs starting at 1: Alice merges two real confirmed-round V1 asset VTXOs (400 + 300 units -> 550 to Bob + 150 asset change + 2,000 sat BTC carrier return) using an operator-leased carrier float, Bob verifies and persists the merged 550-unit VTXO, and Bob unilaterally unrolls and claims all 550 units into his embedded asset wallet.

Add the daemon-only SendAssetOOR RPC (plus REST gateway mapping) to
waverpc so waved can submit out-of-round Taproot Asset transfers without
exposing a CLI surface yet, and add optional batch_asset_root (field 5)
on arkrpc.TreePath so clients can authenticate composed asset batch
output expiry against confirmed commitment transactions.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T10:08:09.446435Z 202919e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b20140a8c2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread oor/local_persistence_handler.go Resolved
Comment thread waved/asset_oor.go Resolved
@darioAnongba darioAnongba self-assigned this Nov 27, 2026
Regenerate waverpc, arkrpc, and devrpc registry artifacts after adding
SendAssetOOR and TreePath.batch_asset_root.
Asset batch outputs commit to TapBranch(SweepTapscriptRoot,
BatchAssetRoot) rather than SweepTapscriptRoot alone. Export
arkscript.TapBranchHash, carry optional 32-byte BatchAssetRoot on
tree.Tree, lib/treecodec (TLV type 7), arkrpc.TreePath, and
tapassets.TreeRootAssetSource, and fold it into
vtxo.validateExpiryFragment so AuthenticateBatchEvidence verifies
confirmed asset batch outputs without trusting operator expiry scalars.
Store the operator's advertised compressed OORCarrierPubKey on
OperatorTerms so waved can verify leased carrier-float policies before
building asset OOR transfers.
Add SelectAndReserveAssetSpend (in lib/actormsg, vtxo, and wallet) to
select and atomically lock up to eight live asset VTXOs of a requested
asset reference in largest-first order, classifying locked-liquidity
shortfalls separately from balance shortfalls.

Add AllowAssetTransition on round.SpendReserveEvent so plain Bitcoin
spends keep failing closed with ErrAssetVTXORequiresTransition while
asset-aware OOR selection transitions live asset VTXOs into
SpendingState.
Allow ListVTXOsByScriptsTaproot and durable serverconn queries to carry
an optional SignerScript alongside each queried PkScript so clients can
prove script-scope ownership using the uncomposed base receive key when
querying composed Taproot Asset output scripts.
@darioAnongba
darioAnongba force-pushed the darioAnongba/waved-asset-oor branch from b20140a to 7b2f1f4 Compare November 27, 2026 18:15
@darioAnongba

Copy link
Copy Markdown
Collaborator Author

@codex review

@darioAnongba
darioAnongba force-pushed the darioAnongba/waved-asset-oor branch from 7b2f1f4 to dba8c20 Compare November 30, 2026 09:39

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dba8c20c62

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread oor/local_persistence_handler.go Resolved
@darioAnongba

Copy link
Copy Markdown
Collaborator Author

@codex review

@darioAnongba
darioAnongba force-pushed the darioAnongba/waved-asset-oor branch from dba8c20 to ed9611c Compare November 30, 2026 09:46

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ed9611cecd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread waved/asset_oor.go Resolved
@darioAnongba

Copy link
Copy Markdown
Collaborator Author

@codex review

@darioAnongba
darioAnongba force-pushed the darioAnongba/waved-asset-oor branch from ed9611c to f098880 Compare November 30, 2026 09:54

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f09888022f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread oor/local_persistence_handler.go Resolved
Add NewOORProofVerifier to check unconfirmed Taproot Asset proof
anchors against a VTXO's authenticated commitment tree and OOR package
chain, and add VerifyOORAssetVTXO on VTXOVerifier so incoming OOR asset
receives verify sealed Ark asset packages (including merged multi-input
packages) before persisting them for unilateral claims and respends.
Forward PreparedSubmitPackage through durable StartTransferRequest TLV
so asset OOR sends enter the outgoing FSM with pre-committed packages,
and keep VTXO.TapScript nil for asset-bearing TransferInputs across
validation, snapshots, and incoming materialization.

Wire incoming asset OOR metadata, composed RoutingPkScript derivation,
async VerifyIncomingAssetPackage authentication outside the write lock,
and sealed Ark asset package persistence on received VTXOs. Track
CompletedEventIDs across incoming snapshots and queue concurrent
distinct hints on parkedSelfHints so multi-output transfers to one
wallet (such as asset change plus Bitcoin carrier return) materialize
every owned output regardless of push ordering.
Implement daemon-only SendAssetOOR: validate allowlisted asset and
operator carrier key, select and lock up to eight asset VTXOs, lease an
operator carrier float via LeaseOORCarrier, plan carrier allocation
(returning round-originated carriers as sender Bitcoin change), build
the asset transition via tapassets.BuildOORTransfer, attach composed
tapleaf scripts, and submit through the durable OOR registry.

Wire incoming OOR asset verification onto the embedded asset engine,
route composed asset outputs through uncomposed receive scripts for
ownership lookup and signer-scoped indexer queries, and carry
OORCarrierPubKey from GetInfo.
Add TestAssetOORMergeAndClaim running two real embedded-engine waved
daemons on regtest bitcoind, Esplora, and tapd: Alice merges two
confirmed-round V1 asset VTXOs (400 + 300 units) via SendAssetOOR using
an operator-leased carrier float, Bob authenticates batch expiry with
BatchAssetRoot and verifies the merged 550-unit VTXO while Alice
receives her 150-unit asset change and 2,000-sat carrier return, and
Bob unilaterally exits and claims all 550 units into his embedded
asset wallet.
Add VTXOStatus.IsTerminal and guard handleVTXOsMaterialized against
replayed notifications for already-terminal stored VTXOs. Set
AllowAssetTransition on the startup reservation-sweep redrive so
resumed asset OOR reservations are not rejected, and match asset
references case-insensitively during candidate selection.
Key multi-output incoming receive hints, parked self-hints, and
ReceiveCompleted tracking on IncomingHintKey{ScriptHash, EventID} so
distinct fresh scripts numbered 1 by the operator do not collide.
Record MaterializedPlainScripts so plain Bitcoin sessions stay dormant
without reopening, preserve prior ReceiveCompleted if a follow-up pass
fails, reject stale phase-1 resolutions, reconstruct active hints on
restore, and guard persistIncomingDescriptor against terminal rows.

Isolate per-output asset verification failures and disabled-asset
sessions so sibling plain Bitcoin outputs still materialize, normalize
incoming TaprootAssetRef casing, and add version-2 OutgoingAssetReplay
proofs to isolate asset and Bitcoin idempotency namespaces.
Validate policy_template destinations with arkscript.ValidatePolicy,
parse oor_carrier_pubkey leniently during operator-terms bootstrap,
and build checkpoint owner leaves under current terms.PubKey so asset
VTXOs remain spendable across operator key rotations.

Consolidate SendAssetOOR lock cleanup into a single detached-context
defer and check local carrier floor preconditions before leasing a
carrier float. Bind keyed asset OOR attempts to v2 OutgoingAssetReplay
identity, reject cross-type Bitcoin/asset key reuse with AlreadyExists,
and return stored summary figures without emitting duplicate metrics.

Wire incomingAssetVerifier as nil when Taproot Assets are disabled,
unwrap proof-verifier errors so transient chain outages retry with
bounded backoff, and skip unverifiable asset events during wallet
recovery instead of aborting the scan.
Document that SignerScript overrides local receive-key lookup for the
script_scope proof while the RPC request queries the composed PkScript.
Match real operator per-script recipient_event_id numbering starting at
1 so TestAssetOORMergeAndClaim exercises distinct fresh scripts sharing
event_id 1 in the same OOR transfer.
@darioAnongba

Copy link
Copy Markdown
Collaborator Author

@codex review

@darioAnongba
darioAnongba force-pushed the darioAnongba/waved-asset-oor branch from f098880 to 202919e Compare November 30, 2026 10:03
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 202919ed5e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@lightninglabs lightninglabs deleted a comment from lightninglabs-gateway Bot Nov 30, 2026
@darioAnongba
darioAnongba merged commit e9f3bbe into main Nov 30, 2026
45 of 49 checks passed
@darioAnongba
darioAnongba deleted the darioAnongba/waved-asset-oor branch November 30, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant