mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 23:29:12 +01:00
bad9cf8f40Increment input value sum only once per UTXO in decodepsbt (Andrew Chow) Pull request description: Github-Pull: #19517 Rebased-From:75122780e2ACKs for top commit: jnewbery: utACKbad9cf8f40laanwj: ACKbad9cf8f40Tree-SHA512: 543bbe58f2dafc772289708007d72fa61592270f3de083afffb9a56274b03f2ffe8d8d509a93790ceea3a708e1c02b1ad941e23281b3db1f48766c01a930dbd6
This commit is contained in:
@@ -1117,39 +1117,38 @@ UniValue decodepsbt(const JSONRPCRequest& request)
|
||||
UniValue in(UniValue::VOBJ);
|
||||
// UTXOs
|
||||
bool have_a_utxo = false;
|
||||
CTxOut txout;
|
||||
if (!input.witness_utxo.IsNull()) {
|
||||
const CTxOut& txout = input.witness_utxo;
|
||||
txout = input.witness_utxo;
|
||||
|
||||
UniValue o(UniValue::VOBJ);
|
||||
ScriptToUniv(txout.scriptPubKey, o, true);
|
||||
|
||||
UniValue out(UniValue::VOBJ);
|
||||
|
||||
out.pushKV("amount", ValueFromAmount(txout.nValue));
|
||||
out.pushKV("scriptPubKey", o);
|
||||
|
||||
in.pushKV("witness_utxo", out);
|
||||
|
||||
have_a_utxo = true;
|
||||
}
|
||||
if (input.non_witness_utxo) {
|
||||
txout = input.non_witness_utxo->vout[psbtx.tx->vin[i].prevout.n];
|
||||
|
||||
UniValue non_wit(UniValue::VOBJ);
|
||||
TxToUniv(*input.non_witness_utxo, uint256(), non_wit, false);
|
||||
in.pushKV("non_witness_utxo", non_wit);
|
||||
|
||||
have_a_utxo = true;
|
||||
}
|
||||
if (have_a_utxo) {
|
||||
if (MoneyRange(txout.nValue) && MoneyRange(total_in + txout.nValue)) {
|
||||
total_in += txout.nValue;
|
||||
} else {
|
||||
// Hack to just not show fee later
|
||||
have_all_utxos = false;
|
||||
}
|
||||
|
||||
UniValue o(UniValue::VOBJ);
|
||||
ScriptToUniv(txout.scriptPubKey, o, true);
|
||||
out.pushKV("scriptPubKey", o);
|
||||
in.pushKV("witness_utxo", out);
|
||||
have_a_utxo = true;
|
||||
}
|
||||
if (input.non_witness_utxo) {
|
||||
UniValue non_wit(UniValue::VOBJ);
|
||||
TxToUniv(*input.non_witness_utxo, uint256(), non_wit, false);
|
||||
in.pushKV("non_witness_utxo", non_wit);
|
||||
CAmount utxo_val = input.non_witness_utxo->vout[psbtx.tx->vin[i].prevout.n].nValue;
|
||||
if (MoneyRange(utxo_val) && MoneyRange(total_in + utxo_val)) {
|
||||
total_in += utxo_val;
|
||||
} else {
|
||||
// Hack to just not show fee later
|
||||
have_all_utxos = false;
|
||||
}
|
||||
have_a_utxo = true;
|
||||
}
|
||||
if (!have_a_utxo) {
|
||||
} else {
|
||||
have_all_utxos = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user