@@ -1105,39 +1105,38 @@ UniValue decodepsbt(const JSONRPCRequest& request)
1105
1105
UniValue in (UniValue::VOBJ);
1106
1106
// UTXOs
1107
1107
bool have_a_utxo = false ;
1108
+ CTxOut txout;
1108
1109
if (!input.witness_utxo .IsNull ()) {
1109
- const CTxOut& txout = input.witness_utxo ;
1110
-
1111
- UniValue out (UniValue::VOBJ);
1112
-
1113
- out.pushKV (" amount" , ValueFromAmount (txout.nValue ));
1114
- if (MoneyRange (txout.nValue ) && MoneyRange (total_in + txout.nValue )) {
1115
- total_in += txout.nValue ;
1116
- } else {
1117
- // Hack to just not show fee later
1118
- have_all_utxos = false ;
1119
- }
1110
+ txout = input.witness_utxo ;
1120
1111
1121
1112
UniValue o (UniValue::VOBJ);
1122
1113
ScriptToUniv (txout.scriptPubKey , o, true );
1114
+
1115
+ UniValue out (UniValue::VOBJ);
1116
+ out.pushKV (" amount" , ValueFromAmount (txout.nValue ));
1123
1117
out.pushKV (" scriptPubKey" , o);
1118
+
1124
1119
in.pushKV (" witness_utxo" , out);
1120
+
1125
1121
have_a_utxo = true ;
1126
1122
}
1127
1123
if (input.non_witness_utxo ) {
1124
+ txout = input.non_witness_utxo ->vout [psbtx.tx ->vin [i].prevout .n ];
1125
+
1128
1126
UniValue non_wit (UniValue::VOBJ);
1129
1127
TxToUniv (*input.non_witness_utxo , uint256 (), non_wit, false );
1130
1128
in.pushKV (" non_witness_utxo" , non_wit);
1131
- CAmount utxo_val = input.non_witness_utxo ->vout [psbtx.tx ->vin [i].prevout .n ].nValue ;
1132
- if (MoneyRange (utxo_val) && MoneyRange (total_in + utxo_val)) {
1133
- total_in += utxo_val;
1129
+
1130
+ have_a_utxo = true ;
1131
+ }
1132
+ if (have_a_utxo) {
1133
+ if (MoneyRange (txout.nValue ) && MoneyRange (total_in + txout.nValue )) {
1134
+ total_in += txout.nValue ;
1134
1135
} else {
1135
1136
// Hack to just not show fee later
1136
1137
have_all_utxos = false ;
1137
1138
}
1138
- have_a_utxo = true ;
1139
- }
1140
- if (!have_a_utxo) {
1139
+ } else {
1141
1140
have_all_utxos = false ;
1142
1141
}
1143
1142
0 commit comments