Skip to content

Commit 1b6f701

Browse files
committed
[RPC] shielded_sendmany throwing an error if the operation failed instead of returning an error string.
1 parent e761e92 commit 1b6f701

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,9 @@ UniValue shielded_sendmany(const JSONRPCRequest& request) {
16851685
->setShieldedRecipients(shieldAddrRecipients)
16861686
->setTransparentRecipients(taddrRecipients)
16871687
->send(txHash);
1688-
return res ? txHash : res.m_error;
1688+
1689+
if (!res) throw JSONRPCError(RPC_WALLET_ERROR, res.m_error);
1690+
return txHash;
16891691
}
16901692

16911693
UniValue listaddressgroupings(const JSONRPCRequest& request)

test/functional/sapling_key_import_export.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ def get_private_balance(node):
6161
amountTo = 10 * 250 - fee
6262
# Shield Alice's coinbase funds to her shield_addr
6363
alice_addr = alice.getnewshieldedaddress()
64-
txid = alice.shielded_sendmany(fromAddress, [{"address": alice_addr, "amount": Decimal(amountTo)}])
65-
self.sync_all()
66-
miner.generate(1)
67-
self.sync_all()
64+
txid = shielded_send(alice, fromAddress, alice_addr, amountTo)
6865

6966
# Now get a pristine address for receiving transfers:
7067
bob_addr = bob.getnewshieldedaddress()

test/functional/sapling_wallet.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ def set_test_params(self):
2222
saplingUpgrade = ['-nuparams=v5_dummy:1']
2323
self.extra_args = [saplingUpgrade, saplingUpgrade, saplingUpgrade, saplingUpgrade]
2424

25+
def check_tx_priority(self, mempool, mytxid):
26+
assert(Decimal(mempool[mytxid]['startingpriority']) == Decimal('1E+25'))
27+
2528
def run_test(self):
2629
# generate 100 more to activate sapling in regtest
2730
self.nodes[2].generate(12)
@@ -54,13 +57,12 @@ def run_test(self):
5457
recipients.append({"address": saplingAddr0, "amount": Decimal('10')})
5558
coinstake = get_coinstake_address(self.nodes[0])
5659
mytxid = self.nodes[0].shielded_sendmany(coinstake, recipients, 1, nMinDefaultSaplingFee)
57-
assert(mytxid != "SendTransaction: CommitTransaction failed")
5860

5961
self.sync_all()
6062

6163
# Verify priority of tx is INF_PRIORITY, defined as 1E+25 (10000000000000000000000000)
6264
mempool = self.nodes[0].getrawmempool(True)
63-
assert(Decimal(mempool[mytxid]['startingpriority']) == Decimal('1E+25'))
65+
self.check_tx_priority(mempool, mytxid)
6466

6567
# Shield another coinbase UTXO
6668
mytxid = self.nodes[0].shielded_sendmany(get_coinstake_address(self.nodes[0]), recipients, 1, nMinDefaultSaplingFee)
@@ -85,7 +87,7 @@ def run_test(self):
8587

8688
# Verify priority of tx is MAX_PRIORITY, defined as 1E+25 (10000000000000000000000000)
8789
mempool = self.nodes[0].getrawmempool(True)
88-
assert(Decimal(mempool[mytxid]['startingpriority']) == Decimal('1E+25'))
90+
self.check_tx_priority(mempool, mytxid)
8991

9092
self.nodes[2].generate(1)
9193
self.sync_all()
@@ -103,12 +105,11 @@ def run_test(self):
103105
recipients.append({"address": saplingAddr0, "amount": Decimal('5')})
104106
recipients.append({"address": taddr1, "amount": Decimal('5')})
105107
mytxid = self.nodes[1].shielded_sendmany(saplingAddr1, recipients, 1, nMinDefaultSaplingFee)
106-
assert(mytxid != "SendTransaction: CommitTransaction failed")
107108
self.sync_all()
108109

109110
# Verify priority of tx is MAX_PRIORITY, defined as 1E+25 (10000000000000000000000000)
110111
mempool = self.nodes[1].getrawmempool(True)
111-
assert(Decimal(mempool[mytxid]['startingpriority']) == Decimal('1E+25'))
112+
self.check_tx_priority(mempool, mytxid)
112113

113114
self.nodes[2].generate(1)
114115
self.sync_all()

0 commit comments

Comments
 (0)