Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check that a separator is found for psbt inputs, outputs, and global map #14377

Merged
merged 1 commit into from Nov 1, 2018

Conversation

@achow101
Copy link
Member

@achow101 achow101 commented Oct 3, 2018

Currently it doesn't make sure that a separator was found so PSBTs missing a trailing separator would still pass. This fixes that and adds a test case for it.

It really only makes sense to check for the separator for the output maps as if an input or global map was missing a separator, the fields following it would be interpreted as belonging to the previous input or global map. However I have added the check for those two anyways to be consistent.

@MarcoFalke
Copy link
Member

@MarcoFalke MarcoFalke commented Oct 3, 2018

Is this for 0.17.1 backport?

if (key.empty()) return;
if (key.empty()) {
found_sep = true;
break;
Copy link
Contributor

@jimmysong jimmysong Oct 3, 2018

What's the rationale for breaking here instead of throwing the error right away?

Copy link
Member Author

@achow101 achow101 Oct 3, 2018

We want to throw the error if we don't get here.

@@ -300,14 +300,18 @@ struct PSBTInput
template <typename Stream>
inline void Unserialize(Stream& s) {
// Read loop
bool found_sep = false;
while(!s.empty()) {
// Read
std::vector<unsigned char> key;
s >> key;

// the key is empty if that was actually a separator byte
// This is a special case for key lengths 0 as those are not allowed (except for separator)
Copy link
Contributor

@jimmysong jimmysong Oct 3, 2018

Comment may need updating?

Copy link
Member Author

@achow101 achow101 Oct 3, 2018

No

while(!s.empty()) {
// Read
std::vector<unsigned char> key;
s >> key;

// the key is empty if that was actually a separator byte
// This is a special case for key lengths 0 as those are not allowed (except for separator)
if (key.empty()) return;
Copy link
Contributor

@jimmysong jimmysong Oct 3, 2018

same as above, comment may need updating?

while(!s.empty()) {
// Read
std::vector<unsigned char> key;
s >> key;

// the key is empty if that was actually a separator byte
// This is a special case for key lengths 0 as those are not allowed (except for separator)
if (key.empty()) break;
Copy link
Contributor

@jimmysong jimmysong Oct 3, 2018

comment may need updating?

@sipa
Copy link
Member

@sipa sipa commented Oct 4, 2018

utACK 4fb3388. I think it should go into 0.17.1.

@MarcoFalke MarcoFalke added this to the 0.17.1 milestone Oct 4, 2018
@DrahtBot
Copy link
Contributor

@DrahtBot DrahtBot commented Oct 4, 2018

Coverage Change (pull 14377) Reference (master)
Lines -0.0117 % 87.0471 %
Functions -0.0154 % 84.1130 %
Branches +0.0018 % 51.5403 %

@meshcollider
Copy link
Member

@meshcollider meshcollider commented Oct 12, 2018

utACK 4fb3388

@laanwj laanwj merged commit 4fb3388 into bitcoin:master Nov 1, 2018
2 checks passed
laanwj added a commit that referenced this issue Nov 1, 2018
…s, and global map

4fb3388 check that a separator is found for psbt inputs, outputs, and global map (Andrew Chow)

Pull request description:

  Currently it doesn't make sure that a separator was found so PSBTs missing a trailing separator would still pass. This fixes that and adds a test case for it.

  It really only makes sense to check for the separator for the output maps as if an input or global map was missing a separator, the fields following it would be interpreted as belonging to the previous input or global map. However I have added the check for those two anyways to be consistent.

Tree-SHA512: 50c0c08e201ba02494b369a4d36ddb73e6634eb5a4e4e201c4ef38fd2dbeea2c642b8a04d50c91615da61ecbfade37309e47431368f4b1064539c42015766b50
@sipa sipa mentioned this pull request Nov 22, 2018
@fanquake
Copy link
Member

@fanquake fanquake commented Nov 30, 2018

This will be backported in #14780.

sipa added a commit to sipa/bitcoin that referenced this issue Dec 3, 2018
MarcoFalke added a commit that referenced this issue 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
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue Oct 5, 2020
Summary:
PR description:
Currently it doesn't make sure that a separator was found so PSBTs missing a trailing separator would still pass. This fixes that and adds a test case for it.

It really only makes sense to check for the separator for the output maps as if an input or global map was missing a separator, the fields following it would be interpreted as belonging to the previous input or global map. However I have added the check for those two anyways to be consistent.

Backport of Core [[bitcoin/bitcoin#14377 | PR14377]]

Test Plan: `ninja && test/functional/test_runner.py rpc_psbt`

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D7753
Munkybooty added a commit to Munkybooty/dash that referenced this issue Jul 22, 2021
… outputs, and global map

4fb3388 check that a separator is found for psbt inputs, outputs, and global map (Andrew Chow)

Pull request description:

  Currently it doesn't make sure that a separator was found so PSBTs missing a trailing separator would still pass. This fixes that and adds a test case for it.

  It really only makes sense to check for the separator for the output maps as if an input or global map was missing a separator, the fields following it would be interpreted as belonging to the previous input or global map. However I have added the check for those two anyways to be consistent.

Tree-SHA512: 50c0c08e201ba02494b369a4d36ddb73e6634eb5a4e4e201c4ef38fd2dbeea2c642b8a04d50c91615da61ecbfade37309e47431368f4b1064539c42015766b50
Munkybooty added a commit to Munkybooty/dash that referenced this issue Jul 22, 2021
… outputs, and global map

4fb3388 check that a separator is found for psbt inputs, outputs, and global map (Andrew Chow)

Pull request description:

  Currently it doesn't make sure that a separator was found so PSBTs missing a trailing separator would still pass. This fixes that and adds a test case for it.

  It really only makes sense to check for the separator for the output maps as if an input or global map was missing a separator, the fields following it would be interpreted as belonging to the previous input or global map. However I have added the check for those two anyways to be consistent.

Tree-SHA512: 50c0c08e201ba02494b369a4d36ddb73e6634eb5a4e4e201c4ef38fd2dbeea2c642b8a04d50c91615da61ecbfade37309e47431368f4b1064539c42015766b50
Munkybooty added a commit to Munkybooty/dash that referenced this issue Jul 22, 2021
… outputs, and global map

4fb3388 check that a separator is found for psbt inputs, outputs, and global map (Andrew Chow)

Pull request description:

  Currently it doesn't make sure that a separator was found so PSBTs missing a trailing separator would still pass. This fixes that and adds a test case for it.

  It really only makes sense to check for the separator for the output maps as if an input or global map was missing a separator, the fields following it would be interpreted as belonging to the previous input or global map. However I have added the check for those two anyways to be consistent.

Tree-SHA512: 50c0c08e201ba02494b369a4d36ddb73e6634eb5a4e4e201c4ef38fd2dbeea2c642b8a04d50c91615da61ecbfade37309e47431368f4b1064539c42015766b50
Munkybooty added a commit to Munkybooty/dash that referenced this issue Jul 23, 2021
… outputs, and global map

4fb3388 check that a separator is found for psbt inputs, outputs, and global map (Andrew Chow)

Pull request description:

  Currently it doesn't make sure that a separator was found so PSBTs missing a trailing separator would still pass. This fixes that and adds a test case for it.

  It really only makes sense to check for the separator for the output maps as if an input or global map was missing a separator, the fields following it would be interpreted as belonging to the previous input or global map. However I have added the check for those two anyways to be consistent.

Tree-SHA512: 50c0c08e201ba02494b369a4d36ddb73e6634eb5a4e4e201c4ef38fd2dbeea2c642b8a04d50c91615da61ecbfade37309e47431368f4b1064539c42015766b50
Munkybooty added a commit to Munkybooty/dash that referenced this issue Jul 23, 2021
… outputs, and global map

4fb3388 check that a separator is found for psbt inputs, outputs, and global map (Andrew Chow)

Pull request description:

  Currently it doesn't make sure that a separator was found so PSBTs missing a trailing separator would still pass. This fixes that and adds a test case for it.

  It really only makes sense to check for the separator for the output maps as if an input or global map was missing a separator, the fields following it would be interpreted as belonging to the previous input or global map. However I have added the check for those two anyways to be consistent.

Tree-SHA512: 50c0c08e201ba02494b369a4d36ddb73e6634eb5a4e4e201c4ef38fd2dbeea2c642b8a04d50c91615da61ecbfade37309e47431368f4b1064539c42015766b50
Munkybooty added a commit to Munkybooty/dash that referenced this issue Jul 23, 2021
… outputs, and global map

4fb3388 check that a separator is found for psbt inputs, outputs, and global map (Andrew Chow)

Pull request description:

  Currently it doesn't make sure that a separator was found so PSBTs missing a trailing separator would still pass. This fixes that and adds a test case for it.

  It really only makes sense to check for the separator for the output maps as if an input or global map was missing a separator, the fields following it would be interpreted as belonging to the previous input or global map. However I have added the check for those two anyways to be consistent.

Tree-SHA512: 50c0c08e201ba02494b369a4d36ddb73e6634eb5a4e4e201c4ef38fd2dbeea2c642b8a04d50c91615da61ecbfade37309e47431368f4b1064539c42015766b50
Munkybooty added a commit to Munkybooty/dash that referenced this issue Jul 23, 2021
… outputs, and global map

4fb3388 check that a separator is found for psbt inputs, outputs, and global map (Andrew Chow)

Pull request description:

  Currently it doesn't make sure that a separator was found so PSBTs missing a trailing separator would still pass. This fixes that and adds a test case for it.

  It really only makes sense to check for the separator for the output maps as if an input or global map was missing a separator, the fields following it would be interpreted as belonging to the previous input or global map. However I have added the check for those two anyways to be consistent.

Tree-SHA512: 50c0c08e201ba02494b369a4d36ddb73e6634eb5a4e4e201c4ef38fd2dbeea2c642b8a04d50c91615da61ecbfade37309e47431368f4b1064539c42015766b50
Munkybooty added a commit to Munkybooty/dash that referenced this issue Jul 26, 2021
… outputs, and global map

4fb3388 check that a separator is found for psbt inputs, outputs, and global map (Andrew Chow)

Pull request description:

  Currently it doesn't make sure that a separator was found so PSBTs missing a trailing separator would still pass. This fixes that and adds a test case for it.

  It really only makes sense to check for the separator for the output maps as if an input or global map was missing a separator, the fields following it would be interpreted as belonging to the previous input or global map. However I have added the check for those two anyways to be consistent.

Tree-SHA512: 50c0c08e201ba02494b369a4d36ddb73e6634eb5a4e4e201c4ef38fd2dbeea2c642b8a04d50c91615da61ecbfade37309e47431368f4b1064539c42015766b50
Munkybooty added a commit to Munkybooty/dash that referenced this issue Jul 27, 2021
… outputs, and global map

4fb3388 check that a separator is found for psbt inputs, outputs, and global map (Andrew Chow)

Pull request description:

  Currently it doesn't make sure that a separator was found so PSBTs missing a trailing separator would still pass. This fixes that and adds a test case for it.

  It really only makes sense to check for the separator for the output maps as if an input or global map was missing a separator, the fields following it would be interpreted as belonging to the previous input or global map. However I have added the check for those two anyways to be consistent.

Tree-SHA512: 50c0c08e201ba02494b369a4d36ddb73e6634eb5a4e4e201c4ef38fd2dbeea2c642b8a04d50c91615da61ecbfade37309e47431368f4b1064539c42015766b50
Munkybooty added a commit to Munkybooty/dash that referenced this issue Jul 28, 2021
… outputs, and global map

4fb3388 check that a separator is found for psbt inputs, outputs, and global map (Andrew Chow)

Pull request description:

  Currently it doesn't make sure that a separator was found so PSBTs missing a trailing separator would still pass. This fixes that and adds a test case for it.

  It really only makes sense to check for the separator for the output maps as if an input or global map was missing a separator, the fields following it would be interpreted as belonging to the previous input or global map. However I have added the check for those two anyways to be consistent.

Tree-SHA512: 50c0c08e201ba02494b369a4d36ddb73e6634eb5a4e4e201c4ef38fd2dbeea2c642b8a04d50c91615da61ecbfade37309e47431368f4b1064539c42015766b50
@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.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

8 participants