Add psbt watch-only/cold-storage example#940
Conversation
15b7b5d to
fe87ff8
Compare
fe87ff8 to
00dfd34
Compare
|
Thanks @DanGould, you the man! I used all your suggestions and everything works now, I was able to broadcast the transaction with |
00dfd34 to
af148d1
Compare
apoelstra
left a comment
There was a problem hiding this comment.
ACK af148d182efcf37d79028e4a516bba75138fc273
Wow! Did not read the code super carefully but skimmed all of it. A very thorough example.
Can me merged before or after 0.28.0, it's completely independent of the release.
|
Converting this to draft until #957 gets sorted. |
d50d2d9 to
b5d090d
Compare
b5d090d to
c6b1006
Compare
|
@DanGould I decided to throw this up in a state that can be merged because the PR to add PSBT sign functionality (#957) is proving to be thorny and I do not know how long till it will be mergable. Sorry for all the back and forward on signing but if you like you could cut'n'paste the |
|
Converting back to draft because I've made changes to this over in #957 after review and cannot be bothered maintaining two branches. |
c6b1006 to
a072bd4
Compare
|
This PSBT example has been hanging around for months now. I've back and forthed, both mentally, and draft/undraft, a million times because of not knowing if its better to do #957 before or after this PR. Also, @DanGould has #935 open with similar confusion. Now @dunxen has #999 going to show taproot psbt signing. Can we just merge these tests/examples and worry about cleaning them up to use #957 when/if that merges. My arguments are:
Cheers |
a072bd4 to
a7f2d21
Compare
|
Re-named the example file to |
apoelstra
left a comment
There was a problem hiding this comment.
ACK a7f2d210d213e60c758a801f053af273f46b24a0
|
Pretty cool! Yeah, let's just get this in. I could find some things to nit but it's not worth keeping this in limbo. |
|
sick! |
Please do nit if you think its worth it and if it will help the other psbt example/test PRs. Otherwise I can come back and improve all three after they merge. |
a7f2d21 to
ee8d06d
Compare
|
Changes in force push:
|
apoelstra
left a comment
There was a problem hiding this comment.
ACK ee8d06dc474aca967a7cab8e0a56b2b308eb0453
Add an example PSBT workflow. The workflow we simulate is that of a setup using a watch-only online wallet (contains only public keys) and a cold-storage wallet (contains the private keys). We create and update a PSBT using the watch-only wallet then pass the PSBT to the cold-storage wallet to sign. Co-authored-by: Dan Gould <d@ngould.dev>
We just added a PSBT example file, run it from CI for all test runs.
ee8d06d to
cd2369b
Compare
|
Changes in force push:
|
|
@sanket1729 this needs just one more approval |
There was a problem hiding this comment.
ACK cd2369b. The example is clean, you can address the comments in followups.
A lot of the code would be cleaned up after #957 .
This PR is really big and already has one ACK. In an effort of moving things forward and considering that my comments are really nits, I am merging this and creating an issue for addressing the follow-ups so that we forget them.
|
|
||
| let mut script_witness: Witness = Witness::new(); | ||
| script_witness.push(&sigs[0].serialize()); | ||
| script_witness.push(self.input_xpub.to_pub().serialize()); |
There was a problem hiding this comment.
nit: You can push pk from the key in the partial_keys map here instead. It seems more natural to use that instead of deriving it again.
| /// The xpub derived from `INPUT_UTXO_DERIVATION_PATH`. | ||
| input_xpub: ExtendedPubKey, | ||
| /// The master extended pubkey fingerprint. | ||
| master_fingerprint: Fingerprint, |
There was a problem hiding this comment.
nit: I think we should save the derivation path for both account_0 and input_xpub instead of global constants.
| cargo test --verbose --features="$feature" | ||
| done | ||
|
|
||
| cargo run --example ecdsa-psbt --features=bitcoinconsensus |
There was a problem hiding this comment.
Not related to this issue, but I just noted that other examples are not being when "DO_NO_STD" is not set
… example cd2369b Run ecdsa-psbt example in test script (Tobin C. Harding) 6967c0e Add psbt example (Tobin Harding) Pull request description: Add an example PSBT workflow. The workflow we simulate is that of a setup using a watch-only online wallet (contains only public keys) and a cold-storage wallet (contains the private keys). We create and update a PSBT using the watch-only wallet then pass the PSBT to the cold-storage wallet to sign. Partially resolves #892 (more done in #935). ## Note This PR includes a sub-module in `examples/psbt.rs` that implements ECDSA signing. This will hopefully eventually be merged into the main crate by way of rust-bitcoin/rust-bitcoin#957. We have three PRs that add examples/tests of PSBTs that need to do signing, in order to help us design a good AP in #957 I think it would be beneficial to complete and merge these three PRs. 1. This PR (PSBT ECDSA example) 2. PBST ECDSA integration test: rust-bitcoin/rust-bitcoin#935 3. PSBT taproot example: rust-bitcoin/rust-bitcoin#999 Note to self, this will need a change to `test.sh` if #1079 merges. ACKs for top commit: apoelstra: ACK cd2369b sanket1729: ACK cd2369b. The example is clean, you can address the comments in followups. Tree-SHA512: c4fb8ec631bf8bfc30534e8974b1f6c4bb7cc6def165a4ee2bb7aa73f5aa7fdc11d2000ca25792a4b534b2c5bf1592efe542ada14a9d702c7dfacbaa808f3aea
dd8730e Use new PSBT signing API in example (Tobin C. Harding) d2367fb Add PSBT sign functionality (Tobin C. Harding) b80e5ae Re-order import statements (Tobin C. Harding) Pull request description: Add an API for signing inputs to the `PSBT` struct. This is work based on code in `rust-miniscript` and the API design suggestions below from @sanket1729 and @Kixunil. Please note, this adds an `unimplemented!` call for taproot inputs. ECDSA signing is complete. Includes a patch adding the psbt example from #940 updated to use this new api. Run `cargo run --example psbt --features=bitcoinconsensus` to test it out. ACKs for top commit: dunxen: ACK dd8730e apoelstra: ACK dd8730e sanket1729: reACK dd8730e Tree-SHA512: 6345571e53cd3aa4b7ad962536da47ae03ab7c0b088107dc4104676bdb64fcf892e8fa60e0b716f3ef158d88d7058938bf267046721ccf74b2d1b092e9b9aaaa
Add an example PSBT workflow. The workflow we simulate is that of a setup using a watch-only online wallet (contains only public keys) and a cold-storage wallet (contains the private keys).
We create and update a PSBT using the watch-only wallet then pass the PSBT to the cold-storage wallet to sign.
Partially resolves #892 (more done in #935).
Note
This PR includes a sub-module in
examples/psbt.rsthat implements ECDSA signing. This will hopefully eventually be merged into the main crate by way of #957. We have three PRs that add examples/tests of PSBTs that need to do signing, in order to help us design a good AP in #957 I think it would be beneficial to complete and merge these three PRs.Note to self, this will need a change to
test.shif #1079 merges.