Skip to content

Conversation

@ishaanam
Copy link
Contributor

Previously the utxoupdatepsbt RPC, added in #13932, only updated the inputs spending segwit outputs with the witness_utxo, because the full transaction is needed for legacy inputs. Before this RPC looked for just the utxos in the utxo set and the mempool. This PR makes it so that if the user has txindex enabled, then the full transaction is looked for there for all inputs. If it is not found in the txindex or txindex isn't enabled, then the mempool is checked for the full transaction. If the transaction an input is spending from is still not found at that point, then the utxo set is searched and the inputs spending segwit outputs are updated with just the utxo.

@ishaanam ishaanam force-pushed the utxoupdatepsbt_with_txindex branch 3 times, most recently from a1c624c to cf9d50d Compare August 27, 2022 00:29
@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 27, 2022

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

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK achow101, Xekyo
Approach ACK w0xlt

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #25796 (rpc: add descriptorprocesspsbt rpc by ishaanam)
  • #21283 (Implement BIP 370 PSBTv2 by achow101)

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.

Copy link
Contributor

@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

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

Approach ACK.
If the txindex is enabled and updated, it should be used.

@ishaanam ishaanam force-pushed the utxoupdatepsbt_with_txindex branch 2 times, most recently from 05f4340 to f26d600 Compare November 15, 2022 23:23
@achow101
Copy link
Member

ACK f26d600d55d86099206456f394a422436d5f3ec3

This function is called from utxoupdatepsbt and will be modified
in a following commit to allow for updating inputs with the
`non_witness_utxo` as well.
@ishaanam ishaanam force-pushed the utxoupdatepsbt_with_txindex branch from f26d600 to 2ee9429 Compare January 19, 2023 02:24
@ishaanam
Copy link
Contributor Author

Rebased

@achow101
Copy link
Member

ACK 2ee94290bdbb66732f420dc9d74493436fb2a59f

Copy link
Contributor

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

ACK 2ee94290bdbb66732f420dc9d74493436fb2a59f

src/psbt.h Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that you’re just moving this code, but could you add a little more explanation here? When I was reviewing this, I was first trying to find out what non_witness_utxos and witness_utxos were, when we needed them, and finally learned per the previous PR when we could drop them. My understanding is that we can only drop non_witness_utxos when all inputs are segwit v1.

I would suspect that we might also be able to drop witness_utxos on non-segwit inputs when we do have the corresponding non_witness_utxos, and vice versa, drop the non_witness_utxos on segwit inputs, if we do have the witness_utxos for them. Is that accurate?

Suggested change
/** Removes the unnecessary non_witness_utxos from a psbt. */
/** Reduces the size of the PSBT by dropping unnecessary `non_witness_utxos` (i.e. previous transactions) from a psbt when all inputs are segwit v1. */

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see that you’re just moving this code, but could you add a little more explanation here?

Done as per your suggestion above.

I would suspect that we might also be able to drop witness_utxos on non-segwit inputs when we do have the corresponding non_witness_utxos,

I don't think witness_utxos should ever get added to non-segwit inputs.

and vice versa, drop the non_witness_utxos on segwit inputs, if we do have the witness_utxos for them.

Currently I'm not sure, though in #25939 (comment) sipa said that in this situation all non_witness_utxos should be kept. Even if this is not the case, changing this behavior would be out of the scope of this PR.

…txindex

Previously only the segwit utxos being spent by the psbt were looked for and
added to the psbt. Now, the full transaction corresponding to each of these
utxos (legacy and segwit) is looked for in the txindex and mempool and added
to the psbt. If txindex is disabled and the transaction is not in the mempool,
then we fall back to getting just the utxo (if segwit) from the utxo set.
@ishaanam ishaanam force-pushed the utxoupdatepsbt_with_txindex branch from 2ee9429 to 6e9f8bb Compare March 19, 2023 00:58
@achow101
Copy link
Member

ACK 6e9f8bb

@DrahtBot DrahtBot requested a review from murchandamus March 20, 2023 16:51
@murchandamus
Copy link
Contributor

ACK 6e9f8bb

@DrahtBot DrahtBot removed the request for review from murchandamus April 7, 2023 20:32
@achow101 achow101 merged commit 2755aa5 into bitcoin:master Apr 21, 2023
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 21, 2023
@ishaanam ishaanam deleted the utxoupdatepsbt_with_txindex branch November 30, 2023 03:18
@bitcoin bitcoin locked and limited conversation to collaborators Nov 29, 2024
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.

6 participants