What changed, and why it matters
This commit is a small code cleanup: it adds a helper function called GetOutPoint to PSBTInput and replaces several direct accesses to transaction input data with calls to that helper. There is no change in behavior or security fix visible in the diff. It appears to be a refactoring to make the code easier to maintain.
No security action required. Treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces PSBTInput::GetOutPoint(), returning COutPoint(prev_txid, prev_out). It then replaces four sites that previously read the outpoint from psbtx.tx->vin[i].prevout (or tx.vin[index].prevout) with input.GetOutPoint(). The logic is functionally equivalent: the same prev_txid and prev_out fields are used. No validation rules, error handling, or data flows are altered.
Changed components
src/node/psbt.cppsrc/psbt.cppsrc/psbt.hsrc/rpc/rawtransaction.cppInspect captured patch +12 / −6
diff --git a/src/node/psbt.cpp b/src/node/psbt.cpp
index 62382e56..749007d2 100644
--- a/src/node/psbt.cpp
+++ b/src/node/psbt.cpp
@@ -130,7 +130,7 @@ PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx)
mtx.vin[i].scriptSig = input.final_script_sig;
mtx.vin[i].scriptWitness = input.final_script_witness;
newcoin.nHeight = 1;
- view.AddCoin(psbtx.tx->vin[i].prevout, std::move(newcoin), true);
+ view.AddCoin(input.GetOutPoint(), std::move(newcoin), true);
}
}
diff --git a/src/psbt.cpp b/src/psbt.cpp
index 3f5e2cde..85c2f25a 100644
--- a/src/psbt.cpp
+++ b/src/psbt.cpp
@@ -98,6 +98,11 @@ bool PartiallySignedTransaction::GetInputUTXO(CTxOut& utxo, int input_index) con
return true;
}
+COutPoint PSBTInput::GetOutPoint() const
+{
+ return COutPoint(prev_txid, prev_out);
+}
+
bool PSBTInput::IsNull() const
{
return !non_witness_utxo && witness_utxo.IsNull() && partial_sigs.empty() && unknown.empty() && hd_keypaths.empty() && redeem_script.empty() && witness_script.empty();
@@ -352,7 +357,7 @@ bool PSBTInputSignedAndVerified(const PartiallySignedTransaction& psbt, unsigned
if (input.non_witness_utxo) {
// If we're taking our information from a non-witness UTXO, verify that it matches the prevout.
- COutPoint prevout = psbt.tx->vin[input_index].prevout;
+ COutPoint prevout = input.GetOutPoint();
if (prevout.n >= input.non_witness_utxo->vout.size()) {
return false;
}
@@ -440,7 +445,7 @@ PSBTError SignPSBTInput(const SigningProvider& provider, PartiallySignedTransact
if (input.non_witness_utxo) {
// If we're taking our information from a non-witness UTXO, verify that it matches the prevout.
- COutPoint prevout = tx.vin[index].prevout;
+ COutPoint prevout = input.GetOutPoint();
if (prevout.n >= input.non_witness_utxo->vout.size()) {
return PSBTError::MISSING_INPUTS;
}
diff --git a/src/psbt.h b/src/psbt.h
index 2325ca97..bb5ce491 100644
--- a/src/psbt.h
+++ b/src/psbt.h
@@ -309,6 +309,8 @@ public:
void FromSignatureData(const SignatureData& sigdata);
void Merge(const PSBTInput& input);
uint32_t GetVersion() const { return m_psbt_version; }
+ COutPoint GetOutPoint() const;
+
explicit PSBTInput(uint32_t psbt_version, const Txid& prev_txid, uint32_t prev_out, std::optional<uint32_t> sequence = std::nullopt)
: m_psbt_version(psbt_version),
prev_txid(prev_txid),
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
index f3fb3eb7..b5a06385 100644
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -165,7 +165,7 @@ PartiallySignedTransaction ProcessPSBT(const std::string& psbt_string, const std
if (tx) {
psbt_input.non_witness_utxo = tx;
} else {
- coins[tx_in.prevout]; // Create empty map entry keyed by prevout
+ coins[psbt_input.GetOutPoint()]; // Create empty map entry keyed by prevout
}
}
@@ -177,8 +177,7 @@ PartiallySignedTransaction ProcessPSBT(const std::string& psbt_string, const std
// If there are still missing utxos, add them if they were found in the utxo set
if (!input.non_witness_utxo) {
- const CTxIn& tx_in = psbtx.tx->vin.at(i);
- const Coin& coin = coins.at(tx_in.prevout);
+ const Coin& coin = coins.at(input.GetOutPoint());
if (!coin.out.IsNull() && IsSegWitOutput(provider, coin.out.scriptPubKey)) {
input.witness_utxo = coin.out;
}
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.