mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
fix(rpc): masternode outputs
should work correctly with multiple outputs created via a single tx (#4967)
* fix(rpc): `masternode outputs` should produce an array or it would ignore all but 1 outputs produced by the same tx * rpc: improve `masternode outputs` help * tests: check that `masternode outputs` show all outputs produced in the same tx
This commit is contained in:
parent
175323836a
commit
b30005d246
@ -181,7 +181,11 @@ static void masternode_outputs_help(const JSONRPCRequest& request)
|
|||||||
RPCHelpMan{"masternode outputs",
|
RPCHelpMan{"masternode outputs",
|
||||||
"Print masternode compatible outputs\n",
|
"Print masternode compatible outputs\n",
|
||||||
{},
|
{},
|
||||||
RPCResults{},
|
RPCResult {
|
||||||
|
RPCResult::Type::ARR, "", "A list of outpoints that can be/are used as masternode collaterals",
|
||||||
|
{
|
||||||
|
{RPCResult::Type::STR, "", "A (potential) masternode collateral"},
|
||||||
|
}},
|
||||||
RPCExamples{""}
|
RPCExamples{""}
|
||||||
}.Check(request);
|
}.Check(request);
|
||||||
}
|
}
|
||||||
@ -202,12 +206,12 @@ static UniValue masternode_outputs(const JSONRPCRequest& request)
|
|||||||
LOCK(pwallet->cs_wallet);
|
LOCK(pwallet->cs_wallet);
|
||||||
pwallet->AvailableCoins(vPossibleCoins, true, &coin_control);
|
pwallet->AvailableCoins(vPossibleCoins, true, &coin_control);
|
||||||
}
|
}
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue outputsArr(UniValue::VARR);
|
||||||
for (const auto& out : vPossibleCoins) {
|
for (const auto& out : vPossibleCoins) {
|
||||||
obj.pushKV(out.tx->GetHash().ToString(), strprintf("%d", out.i));
|
outputsArr.push_back(out.GetInputCoin().outpoint.ToStringShort());
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj;
|
return outputsArr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ENABLE_WALLET
|
#endif // ENABLE_WALLET
|
||||||
|
@ -66,6 +66,13 @@ class RPCMasternodeTest(DashTestFramework):
|
|||||||
assert_equal(gbt_masternode[i]["script"], payments_masternode["payees"][i]["script"])
|
assert_equal(gbt_masternode[i]["script"], payments_masternode["payees"][i]["script"])
|
||||||
assert_equal(gbt_masternode[i]["amount"], payments_masternode["payees"][i]["amount"])
|
assert_equal(gbt_masternode[i]["amount"], payments_masternode["payees"][i]["amount"])
|
||||||
|
|
||||||
|
self.log.info("test that `masternode outputs` show correct list")
|
||||||
|
addr1 = self.nodes[0].getnewaddress()
|
||||||
|
addr2 = self.nodes[0].getnewaddress()
|
||||||
|
self.nodes[0].sendmany('', {addr1: 1000, addr2: 1000})
|
||||||
|
self.nodes[0].generate(1)
|
||||||
|
# we have 3 masternodes that are running already and 2 new outputs we just created
|
||||||
|
assert_equal(len(self.nodes[0].masternode("outputs")), 5)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
RPCMasternodeTest().main()
|
RPCMasternodeTest().main()
|
||||||
|
Loading…
Reference in New Issue
Block a user