Skip to content

Commit d20abe4

Browse files
achow101vijaydasmp
authored andcommitted
Merge bitcoin#26733: test: Add test for sendmany rpc that uses subtractfeefrom parameter
057057a Add test for `sendmany` rpc that uses `subtractfeefrom` parameter (Yusuf Sahin HAMZA) Pull request description: This PR adds test that uses `sendmany` rpc to send **BTC** to multiple addresses using `subtractfeefrom` parameter, then checks receiver addresses balances to make sure fees are subtracted correctly. ACKs for top commit: achow101: ACK 057057a Tree-SHA512: 51167120d489f0ff7b8b9855424d07cb55a8965984f904643cddf45e7a08c350eaded498c350ec9c660edf72c2f128ec142347c9c79d5043d9f6cd481b15cd7e
1 parent 2e6a225 commit d20abe4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/functional/wallet_basic.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,21 @@ def run_test(self):
280280
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), node_0_bal + Decimal('100'), fee_per_byte, count_bytes(self.nodes[2].gettransaction(txid)['hex']))
281281

282282
self.log.info("Test sendmany with fee_rate param (explicit fee rate in duff/B)")
283+
# Sendmany 5 DASH to two addresses with subtracting fee from both addresses
284+
a0 = self.nodes[0].getnewaddress()
285+
a1 = self.nodes[0].getnewaddress()
286+
txid = self.nodes[2].sendmany(dummy='', amounts={a0: 5, a1: 5}, subtractfeefrom=[a0, a1])
287+
self.generate(self.nodes[2], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
288+
node_2_bal -= Decimal('10')
289+
assert_equal(self.nodes[2].getbalance(), node_2_bal)
290+
tx = self.nodes[2].gettransaction(txid)
291+
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), node_0_bal + Decimal('10'), fee_per_byte, self.get_vsize(tx['hex']))
292+
assert_equal(self.nodes[0].getbalance(), node_0_bal)
293+
expected_bal = Decimal('5') + (tx['fee'] / 2)
294+
assert_equal(self.nodes[0].getreceivedbyaddress(a0), expected_bal)
295+
assert_equal(self.nodes[0].getreceivedbyaddress(a1), expected_bal)
296+
297+
self.log.info("Test sendmany with fee_rate param (explicit fee rate in sat/vB)")
283298
fee_rate_sat_vb = 2
284299
fee_rate_btc_kvb = fee_rate_sat_vb * 1e3 / 1e8
285300
explicit_fee_rate_btc_kvb = Decimal(fee_rate_btc_kvb) / 1000

0 commit comments

Comments
 (0)