Skip to content

tapassets: populate BIP-371 taproot metadata on plain OOR outputs - #1657

Merged
darioAnongba merged 1 commit into
mainfrom
darioAnongba/tapassets-oor-exclusion-proofs
Nov 26, 2026
Merged

darioAnongba merged 1 commit into
mainfrom
darioAnongba/tapassets-oor-exclusion-proofs

Conversation

@darioAnongba

Copy link
Copy Markdown
Collaborator

Summary

When committing an OOR Ark asset transition against a real tapd backend, Taproot Assets proof generation calls AddExclusionProofs on every non-asset P2TR output in the anchor transaction. Plain Ark VTXO outputs on an OOR Ark transaction (e.g., sender carrier return and operator float change) are P2TR outputs backed by two-leaf Ark policy trees, so tapd requires PSBT_OUT_TAP_INTERNAL_KEY and BIP-371 PSBT_OUT_TAP_TREE on those PSBT outputs to prove that they carry no Taproot Asset commitment.

planOORArk previously left TaprootInternalKey and TaprootTapTree unset on non-asset outputs, causing real tapd commits to fail with:
cannot add exclusion proof, output 0 is a P2TR output but is missing the internal key in the PSBT.

Changes

  • tapassets/oor_transfer.go:
    • Populate 32-byte x-only TaprootInternalKey and BIP-371 depth-first TaprootTapTree on every plain P2TR output in planOORArk's anchor PSBT template (while keeping the canonical returned Ark PSBT unchanged).
    • Validate upfront in OORTransferRequest.validate() that every plain P2TR output carries a matching VTXOPolicyTemplate before committing any checkpoint transitions; non-P2TR outputs continue without requiring one.
  • tapassets/oor_transfer_test.go:
    • Verify planOORArk populates valid BIP-371 internal key and tap tree metadata whose reconstructed Taproot output key matches TxOut[i].PkScript.
    • Verify encodeBIP371TapTree across 1-, 2-, 3-, and 5-leaf arkscript.BuildTree shapes.
    • Verify missing/mismatched policy templates on plain P2TR outputs are rejected before any checkpoint commit, and non-P2TR plain outputs remain accepted.
  • tapassets/AGENTS.md / tapassets/CLAUDE.md: document the plain P2TR policy-template requirement for OOR transfers.

Testing

  • go test ./tapassets/... (passes, including new unit tests).
  • make fmt-changed && make lint-changed-local && make commitmsg-lint (0 issues).
  • Verified end-to-end against a real regtest tapd instance (2-hop OOR asset transfer with plain BTC carrier return and float change outputs).

Real tapd proof generation calls AddExclusionProofs on every non-asset
P2TR output of an anchor transaction, requiring
PSBT_OUT_TAP_INTERNAL_KEY and BIP-371 PSBT_OUT_TAP_TREE to prove that
the output commits to no Taproot Asset tree. Plain Ark VTXO outputs on
an OOR Ark transaction (sender carrier change and operator float change)
are P2TR outputs with two-leaf Ark policy trees, so planOORArk
previously caused tapd to fail with missing internal key on output 0.

Populate TaprootInternalKey and depth-first BIP-371 TaprootTapTree on
every plain P2TR output of the Ark anchor template passed to tap-sdk,
and validate upfront that plain P2TR outputs carry a matching policy
template before any checkpoint transition is committed.
@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-26T20:17:02.281287Z 0866a74 PR opened
ℹ️ 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.

@darioAnongba darioAnongba self-assigned this Nov 26, 2026
@darioAnongba
darioAnongba merged commit a15fc49 into main Nov 26, 2026
20 of 21 checks passed
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