mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-11 22:43:06 +02:00
Add PSBTInput::GetOutPoint
Helper for getting the PSBTInput COutPoint
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user