aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorAndrew Chow <github@achow101.com>2023-04-21 13:54:58 -0400
committerAndrew Chow <github@achow101.com>2023-04-21 14:06:12 -0400
commit2755aa5121ac8c83365a8da747c3f0fc8ebae9c6 (patch)
tree5fcc67e84f9ef086cd9f047664b1fcea86c39551 /src/wallet
parentf3f5c9712670fc2c9fb3b57580146aa248a5d36f (diff)
parent6e9f8bb050785dbc754b6bb493aad9139908ef98 (diff)
Merge bitcoin/bitcoin#25939: rpc: In `utxoupdatepsbt` also look for the tx in the txindex
6e9f8bb050785dbc754b6bb493aad9139908ef98 rpc, tests: in `utxoupdatepsbt` also look for the transaction in the txindex (ishaanam) a5b4883fb43d01bfef1244df62c64bf8691ca63a rpc: extract psbt updating logic into ProcessPSBT (ishaanam) Pull request description: 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. ACKs for top commit: achow101: ACK 6e9f8bb050785dbc754b6bb493aad9139908ef98 Xekyo: ACK 6e9f8bb050785dbc754b6bb493aad9139908ef98 Tree-SHA512: 078db3c37a1ecd5816d80a42e8bd1341e416d661f508fa5fce0f4e1249fefd7b92a0d45f44957781cb69d0953145ef096ecdd4545ada39062be27742402dac6f
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet.cpp29
1 files changed, 1 insertions, 28 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 1095529188..56bd25b90a 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2184,34 +2184,7 @@ TransactionError CWallet::FillPSBT(PartiallySignedTransaction& psbtx, bool& comp
}
}
- // Only drop non_witness_utxos if sighash_type != SIGHASH_ANYONECANPAY
- if ((sighash_type & 0x80) != SIGHASH_ANYONECANPAY) {
- // Figure out if any non_witness_utxos should be dropped
- std::vector<unsigned int> to_drop;
- for (unsigned int i = 0; i < psbtx.inputs.size(); ++i) {
- const auto& input = psbtx.inputs.at(i);
- int wit_ver;
- std::vector<unsigned char> wit_prog;
- if (input.witness_utxo.IsNull() || !input.witness_utxo.scriptPubKey.IsWitnessProgram(wit_ver, wit_prog)) {
- // There's a non-segwit input or Segwit v0, so we cannot drop any witness_utxos
- to_drop.clear();
- break;
- }
- if (wit_ver == 0) {
- // Segwit v0, so we cannot drop any non_witness_utxos
- to_drop.clear();
- break;
- }
- if (input.non_witness_utxo) {
- to_drop.push_back(i);
- }
- }
-
- // Drop the non_witness_utxos that we can drop
- for (unsigned int i : to_drop) {
- psbtx.inputs.at(i).non_witness_utxo = nullptr;
- }
- }
+ RemoveUnnecessaryTransactions(psbtx, sighash_type);
// Complete if every input is now signed
complete = true;