Added hash Preimages to psbt#465
Conversation
Added hash preimages to psbt as per updated bip174
92353e7 to
1ab33aa
Compare
|
Build breaking because of #468. The last commit does not belong in this PR. If it requires tests/more reviews, it can be removed and raised as another PR. |
| *.iml | ||
|
|
||
| #Vscode project files | ||
| .vscode |
There was a problem hiding this comment.
Heh, sure, ACK this, though I seem to recall arguments about it every time somebody tries to do this.
There was a problem hiding this comment.
Don't mind removing this commit although I don't see why this is an issue.
src/util/psbt/mod.rs
Outdated
There was a problem hiding this comment.
there is a tab or something on this line that should be deleted
src/util/psbt/mod.rs
Outdated
There was a problem hiding this comment.
same on this line, trailing whitespace
There was a problem hiding this comment.
How does one figure out whether there is an empty line or whether it has spaces/tabs?
There was a problem hiding this comment.
More arguments for rustfmt :P . But yeah, I will take care of these things in future.
There was a problem hiding this comment.
On my system git diff highlights trailing whitespace in red. I don't know what setting causes it to do this.
b19bf6c to
04c45d9
Compare
dr-orlovsky
left a comment
There was a problem hiding this comment.
Proposing one improvement and few small changes to signature_hash, otherwise utACK
src/util/psbt/mod.rs
Outdated
There was a problem hiding this comment.
I assume the line should read "for non-segwit and non-P2SH wrapped segwit outputs" b/c in the current reading it seems that all P2SH (non-wrapped) should fall into this first options as well
src/util/psbt/mod.rs
Outdated
There was a problem hiding this comment.
would
match (inp.non_witness_utxo, inp.witness_utxo) {
(Some(non_witness_utxo), None) => { ... }
(None, _) => { ... }
(Some(_), Some(_)) => { /* error 2 */ }
_ => { /* error 2 */ }
}work better since it will cover currently uncovered situation if both non-witness and witness UTXO are present for the same output?
There was a problem hiding this comment.
Agreed, it would be good to catch this case and error out.
There was a problem hiding this comment.
@apoelstra @dr-orlovsky , I tried to follow the specification line by line write https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#simple-signer-algorithm. I think the specification does not error if both are present and this is the expected behaviour
There was a problem hiding this comment.
In fact, from the BIP. An input can have both PSBT_IN_NON_WITNESS_UTXO and PSBT_IN_WITNESS_UTXO.
There was a problem hiding this comment.
Ok, but which of them has priority over the other? Here, if non-witness is present, witness is just simply ignored...
There was a problem hiding this comment.
Yes, I followed the algorithm listed https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#simple-signer-algorithm.
There was a problem hiding this comment.
Ok, at least this is according to the spec... However it's wired, will look into spec to see if there could be an issue with it...
src/util/psbt/mod.rs
Outdated
There was a problem hiding this comment.
single space is missing before = if
src/util/psbt/mod.rs
Outdated
There was a problem hiding this comment.
This can be simplified once #387 will be merged - just another reason to have that PR, @apoelstra
|
Follow-up PR: #471 |
src/util/psbt/mod.rs
Outdated
src/util/psbt/mod.rs
Outdated
There was a problem hiding this comment.
This comment should be changed to indicate that it looks at the PSBT data to determine the appropriate sighash mode as well as whether to sign using segwit or legacy. As written it sounds like its primary job is to decide between segwit/non-segwit which isn't true.
src/util/psbt/mod.rs
Outdated
There was a problem hiding this comment.
You can use .to_bytes() instead of .clone().into_bytes()
src/util/psbt/mod.rs
Outdated
There was a problem hiding this comment.
Same down here, use .to_bytes
There was a problem hiding this comment.
Yeah, clone().into_bytes() looks silly. Idk why I did this..
04c45d9 to
0d47c90
Compare
|
Updated the PR. |
0d47c90 to
c1eafff
Compare
|
Sorry, I merged this by mistake. @sanket1729 can you open a new PR? |
|
Sure. |
Added hash preimages to psbt as per modified BIP 174. See bitcoin/bips#955. This will allow rust-miniscript a complete finalizer that can finalize hash preimages. (rust-bitcoin/rust-miniscript#119) .
Since the current version of the BIP does not have any tests for these,
I plan to add some roundtrip tests for the changes.Edit: Added tests