Skip to content

Commit 9991f49

Browse files
committed
test: Watchonly wallets should estimate larger size
Test that when a watchonly wallet and the wallet with private keys fund the same tx, the watchonly wallet should use a higher fee since it should be estimating the size to be larger as it assumes the signer cannot grind the R value.
1 parent b1821d8 commit 9991f49

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/functional/wallet_fundrawtransaction.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def run_test(self):
152152
self.test_feerate_rounding()
153153
self.test_input_confs_control()
154154
self.test_duplicate_outputs()
155+
self.test_watchonly_cannot_grind_r()
155156

156157
def test_duplicate_outputs(self):
157158
self.log.info("Test deserializing and funding a transaction with duplicate outputs")
@@ -1516,5 +1517,28 @@ def test_input_confs_control(self):
15161517

15171518
wallet.unloadwallet()
15181519

1520+
def test_watchonly_cannot_grind_r(self):
1521+
self.log.info("Test that a watchonly wallet will estimate higher fees for a tx than the wallet with private keys")
1522+
self.nodes[0].createwallet("grind")
1523+
wallet = self.nodes[0].get_wallet_rpc("grind")
1524+
default_wallet = self.nodes[0].get_wallet_rpc(self.default_wallet_name)
1525+
1526+
self.nodes[0].createwallet(wallet_name="grind_watchonly", disable_private_keys=True)
1527+
watchonly = self.nodes[0].get_wallet_rpc("grind_watchonly")
1528+
assert_equal(watchonly.importdescriptors(wallet.listdescriptors()["descriptors"])[0]["success"], True)
1529+
1530+
# Send to legacy address type so that we will have an ecdsa signature with a measurable effect on the feerate
1531+
default_wallet.sendtoaddress(wallet.getnewaddress(address_type="legacy"), 10)
1532+
self.generate(self.nodes[0], 1)
1533+
1534+
assert_equal(wallet.listunspent(), watchonly.listunspent())
1535+
1536+
ret_addr = default_wallet.getnewaddress()
1537+
tx = wallet.createrawtransaction([], [{ret_addr: 5}])
1538+
funded = wallet.fundrawtransaction(hexstring=tx, fee_rate=10)
1539+
1540+
watchonly_funded = watchonly.fundrawtransaction(hexstring=tx, fee_rate=10)
1541+
assert_greater_than(watchonly_funded["fee"], funded["fee"])
1542+
15191543
if __name__ == '__main__':
15201544
RawTransactionsTest(__file__).main()

0 commit comments

Comments
 (0)