Skip to content

Commit b9de46a

Browse files
committed
getaddressutxosextra: fixed processing of flag 'simple' with filter 'sender'
1 parent 77a01cb commit b9de46a

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

src/rpc/misc.cpp

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,20 +1030,19 @@ UniValue getUtxosDataWithSender(const address_vector_t& vDestAddresses, const he
10301030
output.pushKV(RPC_KEY_HEIGHT, key.blockHeight);
10311031
output.pushKV("senderAddress", sAddressFrom);
10321032

1033-
if (bJustSendersAddress)
1034-
continue;
1033+
if (!bJustSendersAddress) {
1034+
UniValue vin(UniValue::VARR);
1035+
vin.reserve(value.vInputIndex.size());
1036+
for (const auto &[prevoutHash, prevoutN, nAmount]: value.vInputIndex) {
1037+
UniValue in(UniValue::VOBJ);
1038+
in.pushKV(RPC_KEY_TXID, prevoutHash.GetHex());
1039+
in.pushKV(RPC_KEY_OUTPUT_INDEX, prevoutN);
1040+
in.pushKV("patoshis", nAmount);
1041+
vin.push_back(std::move(in));
1042+
}
1043+
output.pushKV("senders", std::move(vin));
1044+
}
10351045

1036-
UniValue vin(UniValue::VARR);
1037-
vin.reserve(value.vInputIndex.size());
1038-
for (const auto& [prevoutHash, prevoutN, nAmount]: value.vInputIndex)
1039-
{
1040-
UniValue in(UniValue::VOBJ);
1041-
in.pushKV(RPC_KEY_TXID, prevoutHash.GetHex());
1042-
in.pushKV(RPC_KEY_OUTPUT_INDEX, prevoutN);
1043-
in.pushKV("patoshis", nAmount);
1044-
vin.push_back(std::move(in));
1045-
}
1046-
output.pushKV("senders", std::move(vin));
10471046
utxos.push_back(std::move(output));
10481047
}
10491048
if (bScanMemPoolTxs)
@@ -1104,16 +1103,16 @@ UniValue getUtxosDataWithSender(const address_vector_t& vDestAddresses, const he
11041103
output.pushKV(RPC_KEY_HEIGHT, -1);
11051104
output.pushKV("senderAddress", keyIO.EncodeDestination(addressFromDest));
11061105

1107-
if (bJustSendersAddress)
1108-
continue;
1106+
if (!bJustSendersAddress) {
1107+
UniValue vin(UniValue::VARR);
1108+
UniValue in(UniValue::VOBJ);
1109+
in.pushKV(RPC_KEY_TXID, txIn.prevout.hash.GetHex());
1110+
in.pushKV(RPC_KEY_OUTPUT_INDEX, txIn.prevout.n);
1111+
in.pushKV("patoshis", prevTxOut.nValue);
1112+
vin.push_back(std::move(in));
1113+
output.pushKV("senders", std::move(vin));
1114+
}
11091115

1110-
UniValue vin(UniValue::VARR);
1111-
UniValue in(UniValue::VOBJ);
1112-
in.pushKV(RPC_KEY_TXID, txIn.prevout.hash.GetHex());
1113-
in.pushKV(RPC_KEY_OUTPUT_INDEX, txIn.prevout.n);
1114-
in.pushKV("patoshis", prevTxOut.nValue);
1115-
vin.push_back(std::move(in));
1116-
output.pushKV("senders", std::move(vin));
11171116
utxos.push_back(std::move(output));
11181117
}
11191118
}

0 commit comments

Comments
 (0)