Skip to content

fix(key-wallet): correct AssetLockTx structure per DIP-00X#659

Merged
xdustinface merged 1 commit intov0.42-devfrom
fix/asset-lock-tx-structure
Apr 18, 2026
Merged

fix(key-wallet): correct AssetLockTx structure per DIP-00X#659
xdustinface merged 1 commit intov0.42-devfrom
fix/asset-lock-tx-structure

Conversation

@QuantumExplorer
Copy link
Copy Markdown
Member

Summary

The asset-lock builder produced transactions that masternodes refused to IS-lock. Four related issues, all fixed in this PR:

  1. AssetLockPayload.version was 0 — must be 1 per DIP-00X.
  2. tx.output[0] was the credit p2pkh output, but per DIP-00X that position must hold an OP_RETURN burn carrying the total locked amount. Credit outputs live only in the special-transaction payload. Burn output construction is moved into ManagedWalletInfo::build_asset_lock.
  3. BIP-69 output sorting in TransactionBuilder::build moved the change output into position 0 (change is typically smaller than the burn), breaking the structural requirement from (2). Adds a skip_bip69_sort builder option and sets it in build_asset_lock.
  4. Tx wire version was the builder default (2); special-tx version must be 3.

Symptom

Self-broadcast asset-lock txs never received an InstantLockReceived event. Network-visible broadcasts succeeded, peers relayed them into mempool, but masternodes rejected them as invalid asset-lock transactions and never signed an IS-lock.

Verification

Confirmed against dash-evo-tool e2e tests on testnet — identity_create and related tests go green after this fix.

Extracted from

Cherry-picked from feat/platform-wallet2 (draft PR #655) so it can land independently.

Test plan

  • cargo build -p key-wallet --all-features
  • cargo test -p key-wallet --all-features --lib — 459 passed / 0 failed
  • cargo test -p key-wallet --all-features --lib asset_lock — 11 passed / 0 failed
  • Two-file change (key-wallet/src/wallet/managed_wallet_info/{asset_lock_builder, transaction_builder}.rs, +65 / −19).

🤖 Extracted with Claude Code

The asset-lock builder in key-wallet produced transactions that
masternodes refused to IS-lock. Four issues:

1. `AssetLockPayload.version` was 0 — must be 1.
2. `tx.output[0]` was the credit output (p2pkh), but per DIP-00X
   that position must hold an OP_RETURN burn carrying the total
   locked amount. Credit outputs live only in the payload. Moved
   burn output construction into `ManagedWalletInfo::build_asset_lock`.
3. BIP-69 output sorting in `TransactionBuilder::build` moved the
   change output into position 0 (change is typically smaller than
   the burn), breaking the structural requirement. Added a
   `preserve_output_order` builder option and set it in
   `build_asset_lock`.
4. Tx wire version was the builder default (2) instead of the
   special-tx version 3.

Symptom: self-broadcast asset-lock txs never received an
`InstantLockReceived` event. Network-visible broadcasts succeeded,
peers relayed them into mempool, but masternodes rejected them as
invalid asset-lock transactions and never signed an IS-lock.

Verified against `dash-evo-tool` e2e tests on testnet:
identity_create and related tests go green after this fix.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 17, 2026

Warning

Rate limit exceeded

@QuantumExplorer has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 57 minutes and 37 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 57 minutes and 37 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6f9f8878-8afe-4ade-ab9c-25de0362d6a8

📥 Commits

Reviewing files that changed from the base of the PR and between e15ea34 and 76c7e9d.

📒 Files selected for processing (2)
  • key-wallet/src/wallet/managed_wallet_info/asset_lock_builder.rs
  • key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/asset-lock-tx-structure

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 18, 2026

Codecov Report

❌ Patch coverage is 53.57143% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.07%. Comparing base (e15ea34) to head (76c7e9d).
⚠️ Report is 1 commits behind head on v0.42-dev.

Files with missing lines Patch % Lines
.../wallet/managed_wallet_info/transaction_builder.rs 31.57% 13 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           v0.42-dev     #659      +/-   ##
=============================================
- Coverage      68.08%   68.07%   -0.01%     
=============================================
  Files            319      319              
  Lines          67646    67661      +15     
=============================================
+ Hits           46057    46061       +4     
- Misses         21589    21600      +11     
Flag Coverage Δ
core 75.52% <ø> (ø)
ffi 37.94% <ø> (ø)
rpc 20.00% <ø> (ø)
spv 85.85% <ø> (-0.01%) ⬇️
wallet 68.05% <53.57%> (-0.03%) ⬇️
Files with missing lines Coverage Δ
...c/wallet/managed_wallet_info/asset_lock_builder.rs 61.32% <100.00%> (+0.65%) ⬆️
.../wallet/managed_wallet_info/transaction_builder.rs 58.43% <31.57%> (-0.65%) ⬇️

... and 4 files with indirect coverage changes

Copy link
Copy Markdown
Collaborator

@ZocoLini ZocoLini left a comment

Choose a reason for hiding this comment

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

nice, were you able to send the transaction??

@xdustinface xdustinface merged commit 5f40cf8 into v0.42-dev Apr 18, 2026
39 checks passed
@xdustinface xdustinface deleted the fix/asset-lock-tx-structure branch April 18, 2026 01:24
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.

4 participants