Skip to content

Commit a8cf34e

Browse files
Merge #763: Fix Wallet::descriptor_checksum to actually return the checksum
af0b369 Fix `Wallet::descriptor_checksum` to actually return the checksum (志宇) Pull request description: ### Description `Wallet::descriptor_checksum` should return the checksum, not the descriptor without the checksum. ### Notes to the reviewers Please merge. ### Changelog notice Fix `Wallet::descriptor_checksum` to actually return the descriptor checksum. ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### Bugfixes: ~* [ ] This pull request breaks the existing API~ * [x] I've added tests to reproduce the issue which are now passing ~* [ ] I'm linking the issue being fixed by this PR~ ACKs for top commit: danielabrozzoni: ACK af0b369 - I run the test you added with the old code, and verified that the bug was there. I then run the test (with a few more dbg!() expressions) and manually verified that the problem is fixed. notmandatory: ACK af0b369 Tree-SHA512: 64a5b1f4708db6f6dcff2f6ef5e0a4c7d206e764d7602ea803c8cc002410326eb59eee770d9c91694dfbf07193ee3ff6bfe163bcbb3506cd7b2a6b59814a3e5c
2 parents 92ad487 + af0b369 commit a8cf34e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/wallet/mod.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,7 @@ where
18421842
.to_string()
18431843
.split_once('#')
18441844
.unwrap()
1845-
.0
1845+
.1
18461846
.to_string()
18471847
}
18481848
}
@@ -1938,6 +1938,22 @@ pub(crate) mod test {
19381938
// OP_PUSH.
19391939
const P2WPKH_FAKE_WITNESS_SIZE: usize = 106;
19401940

1941+
#[test]
1942+
fn test_descriptor_checksum() {
1943+
let (wallet, _, _) = get_funded_wallet(get_test_wpkh());
1944+
let checksum = wallet.descriptor_checksum(KeychainKind::External);
1945+
assert_eq!(checksum.len(), 8);
1946+
1947+
let raw_descriptor = wallet
1948+
.descriptor
1949+
.to_string()
1950+
.split_once('#')
1951+
.unwrap()
1952+
.0
1953+
.to_string();
1954+
assert_eq!(get_checksum(&raw_descriptor).unwrap(), checksum);
1955+
}
1956+
19411957
#[test]
19421958
fn test_get_funded_wallet_balance() {
19431959
let (wallet, _, _) = get_funded_wallet(get_test_wpkh());

0 commit comments

Comments
 (0)