Add experimental silent payment transaction creation support#220
Add experimental silent payment transaction creation support#220nymius wants to merge 1 commit intobitcoindevkit:masterfrom
Conversation
e0a13af to
bc40b76
Compare
tvpeter
left a comment
There was a problem hiding this comment.
Thank you for working on adding this feature @nymius,
I couldn't test because I don't know how to construct sp recipients. I will check the documentation on the library and will come back to test it. In the meantime, I have left some comments.
Thank you
bc40b76 to
8d15df7
Compare
src/handlers.rs
Outdated
| if send_all { | ||
| tx_builder.drain_wallet().drain_to(recipients[0].0.clone()); | ||
| } else { |
There was a problem hiding this comment.
Is it possible to drain to an SP address? if so, it will be great to cover that as well.
There was a problem hiding this comment.
Yes, there are different cases for this though:
CreateSpTxreceives only aSilentPaymentCodeto drain funds.CreateSpTxis called with the--send_allflag and multipleSilentPaymentCodeor other addresses to drain funds.CreateSpTxis called with the--send_allflag, noSilentPaymentCode, and a plain address.
I've implemented this contemplating 1 and 3 as successful cases, and any variant of 2 as an error.
| for psbt_input in psbt.inputs.iter_mut() { | ||
| psbt_input.final_script_sig = None; | ||
| psbt_input.final_script_witness = None; | ||
| } |
There was a problem hiding this comment.
Won't it be ideal to check if they were actually finalized before resetting?
There was a problem hiding this comment.
It shouldn't be necessary, as we are not passing a PSBT around, and the wallet always has all the keys required to sign, but is not difficult to implement. Above, Wallet::sign returns a boolean that indicates if the transaction was finalized or not, so I can check that.
sdmg15
left a comment
There was a problem hiding this comment.
tested ACK.
Script to use to reproduce
export NETWORK=regtest
export EXT_DESCRIPTOR='wpkh(tprv8ZgxMBicQKsPdMzWj9KHvoExKJDqfZFuT5D8o9XVZ3wfyUcnPNPJKncq5df8kpDWnMxoKbGrpS44VawHG17ZSwTkdhEtVRzSYXd14vDYXKw/0/*)'
export INT_DESCRIPTOR='wpkh(tprv8ZgxMBicQKsPdMzWj9KHvoExKJDqfZFuT5D8o9XVZ3wfyUcnPNPJKncq5df8kpDWnMxoKbGrpS44VawHG17ZSwTkdhEtVRzSYXd14vDYXKw/1/*)'
export DATABASE_TYPE="sqlite"
export CLIENT_TYPE="rpc"
export SERVER_URL="http://127.0.0.1:18443"
export COOKIE="/home/user/.bitcoin/regtest/.cookie"
export SP_RECIPIENT="sprt1qqdu4udd7wz7flf89m27teqzp8gxzvgpg3xudw89c0ce0f0pe0gwz6qkc4d7dg587w9rkaa0cj8rf3c28z0g45tgn0t7fzkk4s867w3eugga03ret"
raw_tx=$(cargo run -- wallet create_sp_tx --to-sp $SP_RECIPIENT:1000 | jq -r '.raw_tx' | tr -d '\n')
cargo run --features rpc -- wallet broadcast --tx $raw_tx
| let _resigned = wallet.sign(&mut psbt, SignOptions::default())?; | ||
|
|
||
| let raw_tx = psbt.extract_tx()?; | ||
| if cli_opts.pretty { |
There was a problem hiding this comment.
Here to actually make this "pretty", there's is this shorten function that can be used. I'm not though convinced if that's helpful for users wanting to copy the full raw tx maybe they should just not use the pretty format.
There was a problem hiding this comment.
Good point, I'm not sure about the use cases of the pretty flag, but I'm against shortening the transaction.
8d15df7 to
8290461
Compare
|
I've addressed the pending comments:
I've also:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #220 +/- ##
==========================================
- Coverage 11.16% 10.39% -0.77%
==========================================
Files 8 8
Lines 2482 2665 +183
==========================================
Hits 277 277
- Misses 2205 2388 +183
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
8290461 to
d297c8e
Compare
- Adds CreateSpTx command to create transactions with silent payment outputs: this command creates signed transactions directly rather than PSBTs due to current limitations in secure shared derivation. It supports mixed recipients: regular addresses + silent payments. It DOES NOT support RBF for the created transactions. It generates signed transactions ready for broadcasting. - Adds SilentPaymentCode command to create silent payment codes from public keys and network: the silent payment code generated is independent from any of the other stateful features of bdk-cli. This command is mainly intended for experimental use, do not lock any funds to the generated code if you don't know what you are doing and don't have the keys matching the public keys used. - Adds bdk_sp dependency with "silent-payments" feature flag. - Adds silent payment recipient parsing utility. - Add README section for new silent payment commands. Note: This is experimental functionality for testing only, not recommended for mainnet use.
d297c8e to
beaca7e
Compare
Description
This PR adds experimental support for creating silent payment transactions through a new
CreateSpTxcommand. The implementation integrates thebdk_spcrate to enable sending Bitcoin to silent payment addresses.Key changes:
bdk_spdependency as an optional featureCreateSpTxcommand with support for silent payment recipientsaddress:amountpairsNotes to the reviewers
.expect()calls that should be addressed in future iterationsChangelog notice
Added: Experimental silent payment transaction creation via
CreateSpTxcommand (feature-gated behindspflag)Checklists
All Submissions
New Features
* [ ] I've added tests for the new feature