Skip to content

Conversation

@achow101
Copy link
Member

@achow101 achow101 commented Aug 9, 2018

This PR adds 3 new utility RPCs for interacting with PSBTs.

utxoupdatepsbt updates a PSBT with UTXO information from the node. It only works with witness UTXOs because full transactions (as would be needed for non-witness UTXOs) are not available unless txindex is enabled.

joinpsbts joins the inputs from multiple distinct PSBTs into one PSBT. e.g. if PSBT 1 has inputs 1 and 2, and PSBT 2 has inputs 3 and 4, joinpsbts would create a new PSBT with inputs 1, 2, 3, and 4.

analyzepsbt analyzes a PSBT and determines the current state of it and all of its inputs, and the next step that needs to be done.

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 9, 2018

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #15404 ([test] Remove -txindex to start nodes by amitiuttarwar)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@gmaxwell
Copy link
Contributor

It only works with witness UTXOs because full transactions (as would be needed for non-witness UTXOs) are not available unless txindex is enabled.

It doesn't look in the wallet?

@sipa
Copy link
Member

sipa commented Aug 10, 2018

@gmaxwell walletprocesspsbt already exists for that. This is a node RPC that works without a wallet.

@achow101
Copy link
Member Author

Rebased

@achow101
Copy link
Member Author

Rebased

@achow101 achow101 force-pushed the psbt-util-rpcs branch 2 times, most recently from eeafff2 to f29d03c Compare August 28, 2018 22:22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could reduce indentation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be more informative?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What else could be said?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the conflicting input index?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should allow duplicate outputs? Or should sum values into one output?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate outputs should be allowed. The idea is that there are two distinct transactions with separate inputs and outputs. They are just being combined into one transaction. Thus you can have duplicate outputs as outputs are still unique. However the inputs must be enforced to be unique.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@achow101 could you ack/nack on #12419, esp @meshcollider #12419 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is necessary because the first is a copy and the remaining psbt inputs are cleared because of AddInput. Maybe remove this "optimization" and merge all psbts to an empty psbt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how that is better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be less code, and less complexity, which I would say is always better, absent a reason to write more code. Why write more code?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Also, this is copied from combinepsbt, where it is easiest to treat the first tx specially, because we need something to compare all the others to, to make sure the underlying transaction is the same. That restriction doesn't exist here, so the need for the extra step is gone.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should force txs.size() > 1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scope of size could be reduced?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@achow101
Copy link
Member Author

Rebased


from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error, find_output
from decimal import Decimal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Sort imports :-)

Adds a joinpsbts RPC which combines multiple distinct PSBTs into
one PSBT.
When signing an input, figure out what was requested for but was unable
to be found and store it in a SignatureData.

Return this information in SignPSBTInput.
@achow101 achow101 force-pushed the psbt-util-rpcs branch 2 times, most recently from 310b395 to 43bbc2c Compare February 16, 2019 05:16
@laanwj
Copy link
Member

laanwj commented Feb 16, 2019

re-utACK 540729e

@laanwj laanwj merged commit 540729e into bitcoin:master Feb 16, 2019
laanwj added a commit that referenced this pull request Feb 16, 2019
540729e Implement analyzepsbt RPC and tests (Andrew Chow)
77542cf Move PSBT UTXO fetching to a separate method (Andrew Chow)
cb40b3a Figure out what is missing during signing (Andrew Chow)
08f749c Implement joinpsbts RPC and tests (Andrew Chow)
7344a7b Implement utxoupdatepsbt RPC and tests (Andrew Chow)

Pull request description:

  This PR adds 3 new utility RPCs for interacting with PSBTs.

  `utxoupdatepsbt` updates a PSBT with UTXO information from the node. It only works with witness UTXOs because full transactions (as would be needed for non-witness UTXOs) are not available unless txindex is enabled.

  `joinpsbts` joins the inputs from multiple distinct PSBTs into one PSBT. e.g. if PSBT 1 has inputs 1 and 2, and PSBT 2 has inputs 3 and 4, `joinpsbts` would create a new PSBT with inputs 1, 2, 3, and 4.

  `analyzepsbt` analyzes a PSBT and determines the current state of it and all of its inputs, and the next step that needs to be done.

Tree-SHA512: 3c1fa302201abca76a8901d0c2be7b4ccbce334d989533c215f8b3e50e22f2f018ce6209544b26789f58f5980a253c0655111e1e20d47d5656e0414c64891a5c
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 13, 2020
Summary:
bitcoin/bitcoin@7344a7b

---

This is a partial backport of Core [[bitcoin/bitcoin#13932 | PR13932]]

Test Plan:
  ninja check
  test_runner.py rpc_psbt

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6043
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 13, 2020
Summary:
Adds a joinpsbts RPC which combines multiple distinct PSBTs into
one PSBT.

bitcoin/bitcoin@08f749c

---

Depends on D6043

This is a partial backport of Core [[bitcoin/bitcoin#13932 | PR13932]] plus a test case

Test Plan:
  ninja check
  test_runner.py rpc_psbt

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6044
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 13, 2020
Summary:
bitcoin/bitcoin@77542cf

---

Depends on D6044

This is a partial backport of Core [[bitcoin/bitcoin#13932 | PR13932]]

Test Plan: unfortunately no tests are included with this commit

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6045
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 13, 2020
Summary:
When signing an input, figure out what was requested for but was unable
to be found and store it in a SignatureData.

Return this information in SignPSBTInput.

bitcoin/bitcoin@cb40b3a

---

Depends on D6045

This is a partial backport of Core [[bitcoin/bitcoin#13932 | PR13932]]

Test Plan:
  ninja check check-functional

Reviewers: #bitcoin_abc, deadalnix, nakihito

Reviewed By: #bitcoin_abc, deadalnix, nakihito

Subscribers: nakihito, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D6046
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 16, 2020
Summary:
bitcoin/bitcoin@540729e

---

This completes the backport of Core [[bitcoin/bitcoin#13932 | PR13932]]

Test Plan:
  cmake .. -GNinja -DENABLE_WERROR=ON
  ninja check-all

Reviewers: #bitcoin_abc, nakihito, deadalnix

Reviewed By: #bitcoin_abc, nakihito, deadalnix

Subscribers: nakihito

Differential Revision: https://reviews.bitcoinabc.org/D6058
kwvg added a commit to kwvg/dash that referenced this pull request Aug 5, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Aug 9, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants