Skip to content

WIP feat(rgbx): add BTC Merkle proof verification to native asset confirm#1299

Open
bysomeone wants to merge 7 commits into
33cn:masterfrom
bysomeone:feature/rgbx-native-proof
Open

WIP feat(rgbx): add BTC Merkle proof verification to native asset confirm#1299
bysomeone wants to merge 7 commits into
33cn:masterfrom
bysomeone:feature/rgbx-native-proof

Conversation

@bysomeone

Copy link
Copy Markdown
Collaborator

Summary

Add BTC Merkle proof (BtcTxProof) verification to RGBx native asset Confirm transactions (Mint/Transfer confirm). Previously only cross-chain deposit/withdraw had Merkle proof validation; native asset confirms only checked UtxoSpendingProof without proving the spending tx existed in a BTC block.

Changes

Proto

  • Simplify UtxoSpendingProof: remove redundant spendingTx and opRetOutputPkScript fields (spending tx now sourced from BtcTxProof.txData)

On-chain validation (executor/)

  • checkConfirm non-withdraw path: add validateBtcTxProof call for Merkle proof verification
  • Exec_Confirm: spendHash computed from BtcTxProof.TxData

Off-chain proof construction (neutrino/)

  • utxoSpendInfo: add blockHash field
  • rescanUtxo: fetch block hash from neutrino header when UTXO spend detected
  • createConfirmPayload: construct BtcTxProof via buildNativeConfirmBtcTxProof
  • New buildNativeConfirmBtcTxProof method reuses existing buildTxExistenceProof

CLI

  • New btcMintSpend command for constructing BTC spending tx with OP_RETURN (used by CI)

Testing

  • Unit tests: supplement checktx_test.go with BtcTxProof validation test cases
  • Docker integration: new scenario_native_asset_mint + native/all entry points

Verification

  • All unit tests pass (rgbx + lightclient)
  • Docker integration test ./docker-compose.sh native passes (mint native asset → BTC spend → neutrino auto-confirm → verify asset created)
  • CI: make docker-compose dapp=rgbx includes native asset scenario

Commits

  • feat: add BTC Merkle proof verification to native asset confirm
  • fix: update exec_test.go for BtcTxProof.TxData spendHash
  • test: add native asset mint docker scenario and supplement unit tests
  • docs: add Phase 4 review report
  • fix: add native asset mint CI scenario with btcMintSpend command
  • fix: improve OP_RETURN matching in createConfirmPayload

🤖 Generated with Claude Code

Co-authored-by: Claude noreply@anthropic.com

bysomeone and others added 5 commits May 27, 2026 12:08
- Simplify UtxoSpendingProof proto, remove redundant spendingTx and OpRetOutputPkScript
- Add validateBtcTxProof call in checkConfirm non-withdraw path
- Migrate Exec_Confirm to use BtcTxProof.txData for spendHash calculation
- Add blockHash field to utxoSpendInfo in off-chain neutrino module
- Add buildNativeConfirmBtcTxProof method on neutrinoClient for Merkle proof construction
- Update createConfirmPayload to construct and include BtcTxProof

Co-Authored-By: Claude <noreply@anthropic.com>
… tests

- Add scenario_native_asset_mint docker integration test
- Add run_native_tests / run_all_tests_wrapper entry points
- Add native/all actions to case dispatch
- Supplement checktx_test.go with BtcTxProof validation test cases
- Fix duplicate import in checktx_test.go
- Add btcMintSpend Go command for building/signing/broadcasting BTC
  mint spending tx with OP_RETURN, replacing fragile raw tx hex parsing
- Fix native case routing to run_native_tests, bypassing chain33 solo
  consensus post-restart block production failure
- Add -k GENESIS_KEY to mint command so stdout captures tx hash
- Add 101 BTC block mining prerequisite before native asset mint
- Add platform: linux/amd64 to docker-compose.yml for Apple Silicon
- Add restart: unless-stopped to para2-4 for reliability

Co-Authored-By: Claude <noreply@anthropic.com>
… matching commitment

- In createConfirmPayload, scan all OP_RETURN outputs and prefer the one
  matching the expected commitment from pending tx hash
- Fall back to first OP_RETURN if no match found
- Add unit test for the matching behavior
- Fix docker-compose.sh case pattern missing 'all' action
@bysomeone bysomeone force-pushed the feature/rgbx-native-proof branch from df551f2 to 809983d Compare June 9, 2026 08:34
@bysomeone bysomeone changed the title feat(rgbx): add BTC Merkle proof verification to native asset confirm WIP feat(rgbx): add BTC Merkle proof verification to native asset confirm Jun 9, 2026
@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.00000% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 28.85%. Comparing base (0d0e378) to head (809983d).
⚠️ Report is 122 commits behind head on master.

Files with missing lines Patch % Lines
...pp/lightclient/rpc/lightclient/neutrino/bitcoin.go 0.00% 19 Missing ⚠️
.../dapp/lightclient/rpc/lightclient/neutrino/rgbx.go 34.61% 15 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1299       +/-   ##
===========================================
- Coverage   48.37%   28.85%   -19.53%     
===========================================
  Files         223      378      +155     
  Lines       42519    73207    +30688     
===========================================
+ Hits        20568    21122      +554     
- Misses      20058    50113    +30055     
- Partials     1893     1972       +79     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bysomeone bysomeone force-pushed the feature/rgbx-native-proof branch from 6a42f75 to 98ecd9f Compare June 10, 2026 09:16
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