Skip to content

Conversation

@instagibbs
Copy link
Member

@instagibbs instagibbs commented Sep 12, 2024

Resolves #30873

The typical use-case would be when you have a too low-fee(perhaps presigned) or timelocked parent transaction where you want to sign the child transaction before broadcasting anything.

You could imagine the parent transaction being a LN commitment transaction at 0 fee, and the child transaction being an anchor spend. Due to the below mempool minimum of the parent, the parent and child transaction must be sent as a pair via submitpackage, so the parent isn't available in the mempool or utxo set yet.

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 12, 2024

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

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/30886.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK rkrux
Concept ACK 1440000bytes, BrandonOdiwuor
Stale ACK pablomartin4btc

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:

  • #32514 (scripted-diff: Remove unused leading newline in RPC docs by maflcko)
  • #31622 (psbt: add non-default sighash types to PSBTs and unify sighash type match checking by achow101)
  • #29675 (wallet: Be able to receive and spend inputs involving MuSig2 aggregate keys by achow101)
  • #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
Member

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

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

ACK abc835282a66495f65f342cfc113e45aac4ebb48

  1. Was this functionality already exposed somewhere I missed?

I couldn't find anything but perhaps I missed some.

  1. Should "non-witness utxos" always be the type added when updating the PSBT? Looks like we fill in non-witness wherever we can, and witness whenever scraping from utxo set

You mean that segwit txs would need to be converted into legacy ones to be passed in prev_txs?

I've checked the test and I understand the use case, but could you please expand a bit on the reasons why prev txs "can not be entered into the mempool or UTXO set", if possible?

@instagibbs
Copy link
Member Author

@pablomartin4btc I expanded on the use-case a bit in the OP

For (2) I was asking what was typically done for non_witness_utxo vs witness_utxo. Due to pre-taproot weaknesses in sighash format I think it's typical to add the full transaction when possible in this codebase at least, and I conform to that in this PR.

@1440000bytes

This comment was marked as abuse.

Copy link
Contributor

@BrandonOdiwuor BrandonOdiwuor left a comment

Choose a reason for hiding this comment

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

Concept ACK

Copy link
Contributor

@rkrux rkrux left a comment

Choose a reason for hiding this comment

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

tACK abc8352

Successful make and functional tests.
I manually tested the new argument in utxoupdatepsbt using my regtest environment by creating parent transaction and a subsequent child transaction. Processing the child PSBT without passing in the raw parent transaction hex led to incomplete processing and was successful later when the parent was passed.
Also tested for duplicate parent transaction error.

@instagibbs instagibbs force-pushed the 2024-09-updateutxo_psbt branch from abc8352 to b6f701d Compare October 21, 2024 14:30
@DrahtBot
Copy link
Contributor

🚧 At least one of the CI tasks failed.
Debug: https://github.com/bitcoin/bitcoin/runs/31832620127

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

This feature is useful when construction a series of
presigned transactions that can not be entered into the
mempool or UTXO set before signing everything.
@instagibbs instagibbs force-pushed the 2024-09-updateutxo_psbt branch from b1ec4d5 to 87ceb61 Compare October 21, 2024 18:48
Copy link
Contributor

@rkrux rkrux left a comment

Choose a reason for hiding this comment

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

tACK 87ceb61

Rebuilt and reran functional tests.

return ret;
}

std::vector<CTransactionRef> ParseTransactionVector(const UniValue txns_param)
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, this pure function implementation is nice!

@rkrux
Copy link
Contributor

rkrux commented Oct 22, 2024

This is far easier to use compared to the earlier way of signrawtransactionwithwallet where few details need to be passed manually such as txid, vout, scriptPubKey, witnessScript, amount!

➜  bcli28 signrawtransactionwithwallet 0300000001f70daae6a5f540e7ff0216e443f6422200f13c2d3c57fa10ab0cff3f1f2abf3f0000000000fdffffff0120e20f2401000000160014e2370a8c1504f239194d158eb0b1450c932b56a900000000 "[{\"txid\":\"3fbf2a1f3fff0cab10fa573c2d3cf1002242f643e41602ffe740f5a5e6aa0df7\", \"vout\": 0, \"scriptPubKey\": \"0014e2370a8c1504f239194d158eb0b1450c932b56a9\", \"witnessScript\": \"035d276773f6e233b41aba595b63e1fa31c3c21b68ca58c4383bb658a3ead4d296\", \"amount\": 48.99989}]"
{
  "hex": "03000000000101f70daae6a5f540e7ff0216e443f6422200f13c2d3c57fa10ab0cff3f1f2abf3f0000000000fdffffff0120e20f2401000000160014e2370a8c1504f239194d158eb0b1450c932b56a9024730440220562a76cf2d701f61bd34a7e741523b1925dfa96b303df94ae7d25c45e186ac3f02207e420ee8a9b9c792b3c67bad8d108c0fc4f0a8d8605f66d61282115a63982d8c0121037dd7593d1344e3b8a13b95ab8cc320ee93466f2b558d2869a6d03361b251d65800000000",
  "complete": true
}

luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Feb 22, 2025
This feature is useful when construction a series of
presigned transactions that can not be entered into the
mempool or UTXO set before signing everything.

Github-Pull: bitcoin#30886
Rebased-From: 87ceb61
@instagibbs instagibbs marked this pull request as draft April 8, 2025 20:47
@instagibbs
Copy link
Member Author

I'm not sure this has proper amount of user demand, putting into draft in case someone stumbles on it and says otherwise

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

@achow101
Copy link
Member

Closing this as it has not had any activity in a while. If you are interested in continuing work on this, please leave a comment so that it can be reopened.

@achow101 achow101 closed this Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RPC: Populate a PSBT input with a UTXO not in wallet/mempool/utxo set

7 participants