Skip to content

add support for P2WPKH#74

Merged
zoedberg merged 1 commit into
RGB-Tools:masterfrom
dcorral:segwit-v0-upstream
Apr 21, 2026
Merged

add support for P2WPKH#74
zoedberg merged 1 commit into
RGB-Tools:masterfrom
dcorral:segwit-v0-upstream

Conversation

@dcorral
Copy link
Copy Markdown
Contributor

@dcorral dcorral commented Apr 17, 2026

PR: Add P2WPKH (SegWit V0) support

Summary

  • Add ScriptType enum (P2wpkh / P2tr) with P2tr as the default, preserving full backward compatibility
  • Parameterize key derivation and descriptor generation to support both BIP84 (purpose 84) and BIP86 (purpose 86) paths
  • Add script_type field to WalletData with #[serde(default)] so existing serialized data continues to work
  • Add generate_keys_with_script_type and restore_keys_with_script_type public API functions
  • Add integration tests for P2WPKH-only and cross-type (P2TR to P2WPKH) RGB transfers
  • Update UniFFI bindings with ScriptType enum and WalletData.script_type field

Backward compatibility

  • ScriptType defaults to P2tr — existing wallets and serialized WalletData are unaffected
  • generate_keys / restore_keys unchanged in signature and behavior
  • #[serde(default)] on script_type means JSON without the field deserializes to P2tr

Test check

  • cargo test -- segwit_v0 — both P2WPKH integration tests passed

@dcorral dcorral force-pushed the segwit-v0-upstream branch from 86648f2 to 49fb569 Compare April 17, 2026 12:26
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.19%. Comparing base (1d461af) to head (348afa2).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #74      +/-   ##
==========================================
+ Coverage   95.16%   95.19%   +0.03%     
==========================================
  Files          23       23              
  Lines       11552    11628      +76     
==========================================
+ Hits        10993    11069      +76     
  Misses        559      559              
Flag Coverage Δ
rust 95.19% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown
Member

@zoedberg zoedberg left a comment

Choose a reason for hiding this comment

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

Please see the requested changes. Also please rename the commit since Segwit_v0 support is imprecise, this PR is adding support for just P2WPKH, not for all segwit v0 scripts. I would rename it to add support for P2WPKH

Comment thread src/wallet/objects.rs Outdated
Comment thread src/keys.rs Outdated
Comment thread src/wallet/test/mod.rs Outdated
Comment thread src/wallet/test/mod.rs Outdated
Comment thread src/wallet/test/segwit_v0.rs Outdated
Comment thread src/utils.rs Outdated
@zoedberg zoedberg changed the title Segwit_v0 support add support for P2WPKH Apr 17, 2026
@dcorral dcorral force-pushed the segwit-v0-upstream branch 2 times, most recently from 57776b5 to 48bfd07 Compare April 17, 2026 16:30
@dcorral dcorral requested a review from zoedberg April 20, 2026 08:26
Copy link
Copy Markdown
Member

@zoedberg zoedberg left a comment

Choose a reason for hiding this comment

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

Please address the requested changes

Comment thread src/wallet/objects.rs Outdated
Comment thread src/wallet/objects.rs Outdated
Comment thread src/wallet/objects.rs Outdated
Comment thread src/wallet/objects.rs Outdated
Comment thread src/error.rs Outdated
Comment thread src/wallet/multisig.rs Outdated
Comment thread src/wallet/multisig.rs Outdated
Comment thread src/wallet/singlesig.rs Outdated
Comment thread src/keys.rs Outdated
Comment thread src/keys.rs Outdated
@dcorral dcorral force-pushed the segwit-v0-upstream branch 3 times, most recently from 58d7c25 to 900f381 Compare April 20, 2026 11:02
@dcorral dcorral requested a review from zoedberg April 20, 2026 12:39
Copy link
Copy Markdown
Member

@zoedberg zoedberg left a comment

Choose a reason for hiding this comment

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

some other requests

Comment thread src/wallet/test/send.rs Outdated
Comment thread src/wallet/test/send.rs
Comment thread src/wallet/test/send.rs
Comment thread src/wallet/mod.rs Outdated
Comment thread src/keys.rs Outdated
Comment thread src/keys.rs Outdated
@dcorral dcorral force-pushed the segwit-v0-upstream branch 3 times, most recently from c40e5e6 to cb24b44 Compare April 20, 2026 17:04
@dcorral dcorral requested a review from zoedberg April 20, 2026 17:05
@dcorral dcorral force-pushed the segwit-v0-upstream branch from cb24b44 to 02ac4e5 Compare April 20, 2026 17:16
Copy link
Copy Markdown
Member

@zoedberg zoedberg left a comment

Choose a reason for hiding this comment

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

Please address the requested changes

Comment thread bindings/uniffi/src/rgb-lib.udl Outdated
Comment thread src/keys.rs
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/utils.rs Outdated
Comment thread src/wallet/test/send.rs Outdated
@dcorral dcorral force-pushed the segwit-v0-upstream branch from 02ac4e5 to 348afa2 Compare April 20, 2026 19:47
@dcorral dcorral requested a review from zoedberg April 20, 2026 20:17
Copy link
Copy Markdown
Member

@zoedberg zoedberg left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@zoedberg zoedberg merged commit 0062f2d into RGB-Tools:master Apr 21, 2026
25 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.

2 participants