Skip to content

Conversation

@sipa
Copy link
Member

@sipa sipa commented Nov 22, 2018

This is a backport of #14588, #14377, and #14197's test to 0.17.

@sipa
Copy link
Member Author

sipa commented Nov 22, 2018

Please review, @achow101 and @gwillen. All tests from the original PRs are included, and all commits pass, though some code changes may have been missed or ended up in the wrong commit.

@fanquake fanquake added this to the 0.17.1 milestone Nov 22, 2018
@gmaxwell
Copy link
Contributor

Concept ACK

@gwillen
Copy link
Contributor

gwillen commented Nov 22, 2018

ACK on my changes appearing correctly-included.

@maflcko
Copy link
Member

maflcko commented Nov 22, 2018

nit: Are these cherry-picks? It might help to include the id they were cherry-picked from.

See for example https://github.com/bitcoin-core/bitcoin-maintainer-tools#backport which might do just that (haven't tried it)

@sipa
Copy link
Member Author

sipa commented Nov 22, 2018

@MarcoFalke I created it by taking the merged #14588, rebasing it on top of the 0.17 branch, and removing all the commits except the ones from the 3 PRs listed in the description. Some commits needed nontrivial changes to work on top of the 0.17 (which lacks some of the refactors that happened in master). They're not clean cherry-picks.

Is there any marker or tag I need to put on the PR or commits so it gets picked up by the release notes scripts?

@laanwj
Copy link
Member

laanwj commented Dec 2, 2018

Is there any marker or tag I need to put on the PR or commits so it gets picked up by the release notes scripts?

yes:
Github-Pull: #1234
There's also
Rebased-From: <commitid> if the commit is directly based on another one on the master branch,this is not used by the scripts at the moment but may help other tooling as well as later troubleshooting.

@sipa sipa force-pushed the 201811_psbt_backports_0.17 branch from e811578 to 819c7a8 Compare December 3, 2018 18:28
@sipa
Copy link
Member Author

sipa commented Dec 3, 2018

Rebased.

achow101 and others added 9 commits December 3, 2018 10:32
Use .str() instead of .data() and .size() when converting CDataStream to
a string. Uses std::string, avoiding conversion to a C string.

Github-Pull: bitcoin#14588
Rebased-From: fe5d22b
New constructor that creates a PartiallySignedTransaction from a
CTransaction, automatically sizing the inputs and outputs vectors for
convenience.

Github-Pull: bitcoin#14588
Rebased-From: 65166d4
Refactor out a "PSBTInputSigned" function to check if a PSBT is signed,
for use in subsequent commits.

Also improve a related comment.

GitHub-Pull: bitcoin#14588
Rebased-From: 53e6fff
Remove redundant arguments to SignPSBTInput -- since it needs several
bits of the PartiallySignedTransaction, pass in a reference instead of
doing it piecemeal. This saves us having to pass in both a PSBTInput and
its index, as well as having to pass in the CTransaction. Also avoid
redundantly passing the sighash_type, which is contained in the
PSBTInput already.

Github-Pull: bitcoin#14588
Rebased-From: 0f5bda2
Refactor the process of PSBTInput signing to enforce the invariant that
a PSBTInput always has _either_ a witness_utxo or a non_witness_utxo,
never both.

This simplifies the logic of SignPSBTInput slightly, since it no longer
has to deal with the "both" case. When calling it, we now give it, in
order of preference: (1) whichever of the utxo fields was already
present in the PSBT we received, or (2) if neither, the
non_witness_utxo field, which is just a copy of the input transaction,
which we get from the wallet.

SignPSBTInput no longer has to remove one of the two fields; instead, it
will check if we have a witness signature, and if so, it will replace
the non_witness_utxo with the witness_utxo (which is smaller, as it is
just a copy of the output being spent.)

Add PSBTInput::IsSane checks in two more places, which checks for
both utxo fields being present; we will now give an RPC error early on
if we are supplied such a malformed PSBT to fill in.

Also add a check to FillPSBT, to avoid touching any input that is
already signed. (This is now redundant, since we should no longer
potentially harm an already-signed input, but it's harmless.)

fixes bitcoin#14473

Github-Pull: bitcoin#14588
@sipa sipa force-pushed the 201811_psbt_backports_0.17 branch from 819c7a8 to 7bee414 Compare December 3, 2018 18:38
@sipa
Copy link
Member Author

sipa commented Dec 3, 2018

Added Github-Pull: and Rebased-From: annotations

@gmaxwell
Copy link
Contributor

gmaxwell commented Dec 5, 2018

kinda tested ACK.

@Sjors
Copy link
Member

Sjors commented Dec 5, 2018

tACK 7bee414

I reviewed it along side with the originals, which I hadn't seen before, so that's a fresh perspective :-)

@meshcollider
Copy link
Contributor

utACK 7bee414

@meshcollider meshcollider requested a review from achow101 December 5, 2018 10:25
@maflcko maflcko merged commit 7bee414 into bitcoin:0.17 Dec 5, 2018
maflcko pushed a commit that referenced this pull request Dec 5, 2018
7bee414 Add test for conversion from non-witness to witness UTXO (Pieter Wuille)
ff56bb9 Add regression test for PSBT signing bug #14473 (Glenn Willen)
db445d4 Refactor PSBTInput signing to enforce invariant (Glenn Willen)
ad94165 Simplify arguments to SignPSBTInput (Glenn Willen)
39ece4f Add bool PSBTInputSigned (Glenn Willen)
70ee1f8 New PartiallySignedTransaction constructor from CTransction (Glenn Willen)
a9eab08 Remove redundant txConst parameter to FillPSBT (Glenn Willen)
cfdd6b2 More concise conversion of CDataStream to string (Glenn Willen)
a3fe125 check that a separator is found for psbt inputs, outputs, and global map (Andrew Chow)

Pull request description:

  This is a backport of #14588, #14377, and #14197's test to 0.17.

Tree-SHA512: 07535ec69a878a63b549e5e463345e233f34662dff805202614cf2ffc896c6d1981363e6d06d02db2e02d815075ad8ebdc5f93f637052cff8c8cbe6c8dfa096a
@promag
Copy link
Contributor

promag commented Dec 5, 2018

ACK 7bee414, indeed not a clean rebase, at least for me FillPSBT was the most hard.

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.