feat: minimal sweep WIF QR-code implementation#53
Conversation
|
@psychemist Hi thanks for the PR. Not quite sure we want to add a WIF feature for the sample app. IMO adding WIF is a big jump from where the wallet is atm. @thunderbiscuit might have a different opinion. Don't mind me asking, what was your rationale the for adding WIF ? are you use in your projects somewhere? |
|
have a contributor who added it for BDK iOS bitcoindevkit/BDKSwiftExampleWallet#355 so let me know if we're doing anything different from ya'll here if you do add it |
|
@ItoroD i saw the contribution on the iOS repo so i thought it would be a nice addition here. unfortunately, i thought about raising the issue AFTER i was done building |
Ahhh I see! Thanks for the input. |
No worries! When I saw camera permissions and QR scanning I had to look a little harder. I know IOS has been using those for a while already. I think we do not even have camera scanning for QR anywhere yet not even for scanning addresses. Probably good to start now. I will run the test and do a proper review. |
| DwLogger.log(INFO, "Sweep started for WIF $shortWif (length=${wif.length}) on ${wallet.network()}") | ||
| DwLogger.log(INFO, "Esplora endpoint: ${getClientEndpoint()}") | ||
|
|
||
| val candidates = listOf( |
There was a problem hiding this comment.
Currently, errors are rightfully thrown when we pass an uncompressed key because uncompressed will only work for legacy pkh script. Maybe we want to determine if the key is compressed or uncompressed and that will help us determine what to put as the candidates. pkh for uncompressed then the rest if compressed.
Maybe a helper function in WifParser can help tell us if isCompressed here.
Description
This PR adds the ability to sweep funds from an external WIF private key into the user's wallet by scanning a QR code or copy-pasting the raw WIF string.
What This Does
raw WIF,wif: prefix, andbitcoin:?wif= URIformatsFlow
Testing
Unit tests (JVM, no device needed)
./gradlew :app:testDebugUnitTestInstall on device/emulator
./gradlew installDebugManual: send testnet4 coins to the wpkh address derived from a test WIF then sweep. Check in-app logs for balance details per descriptor.
Check out test sweep transaction on testnet4 here:
Screenshots