BP-WG / bp-wallet

Modern, lightweight & standard-compliant bitcoin wallet runtime & cli without rust-bitcoin dependencies
Apache License 2.0
17 stars 12 forks source link

cannot find coins with Wpkh wallets #52

Closed zoedberg closed 3 months ago

zoedberg commented 3 months ago

In this branch https://github.com/zoedberg/rgb-integration-tests/tree/rgb_next_master_no_dw I've completely switched the integration tests from descriptor-wallet to bp-wallet. By running cargo test --test issuance you can see that all tests with Wpkh wallets fail looking for coins (the call to wallet().address_coins() returns an empty list).

It seems the issue is with the update method (used to find new coins), that with Tr wallets correctly logs keychain 0 .......... keychain 1 .......... keychain 9 .......... keychain 10 .........., while with Wpkh wallets logs keychain 0 .......... keychain 1 ........... So it seems like it's not looking at keychains 9 and 10, therefore missing the UTXOs.

dr-orlovsky commented 3 months ago

I assume you provide a wrong key descriptor. When calling rgb create --wpkh KEY the KEY must in in format of [xxxxxxxx/84h/1h/xh]xpubDATA/<0;1;9>/*

dr-orlovsky commented 3 months ago

Related: https://github.com/BP-WG/bp-std/issues/33

zoedberg commented 3 months ago

Please give a look at the code I've linked. The provided key descriptor and keychains are the same for both Wpkh and Tr wallets.

IMO since I've forgot to specify the keychains both type of wallets should look at their default keychains, that should be <0;1;9> for Wpkh wallets and <0;1;9;10> for Tr wallets.

dr-orlovsky commented 3 months ago

Tr had a bug assuming <0;1;9;10>, which will lead to unexpected divergence between a provided xpub descriptor and saved wallet descriptor. I made yesterday a commit fixing that - but haven't pushed it until we close this question here

zoedberg commented 3 months ago

With that fix I think this issue can be closed, since the issue ended up being just about default keychains. By providing the keychains when constructing the XpubDerivable all wallets are able to find coins and all tests pass

dr-orlovsky commented 3 months ago

Ok. I publish this as a PR and once it is reviewed I will close this

dr-orlovsky commented 3 months ago

Addressed in https://github.com/RGB-WG/rgb/pull/223