88from test_framework .test_framework import BitcoinTestFramework
99from test_framework .util import assert_equal , assert_raises_rpc_error
1010from test_framework .messages import COIN
11- from test_framework .wallet import MiniWallet , getnewdestination
11+ from test_framework .wallet import MiniWallet , MiniWalletMode , getnewdestination
1212
1313
1414class GetBlocksActivityTest (BitcoinTestFramework ):
@@ -30,6 +30,7 @@ def run_test(self):
3030 self .test_invalid_descriptor (node , wallet )
3131 self .test_confirmed_and_unconfirmed (node , wallet )
3232 self .test_receive_then_spend (node , wallet )
33+ self .test_no_address (node , wallet )
3334
3435 def test_no_activity (self , node ):
3536 _ , _ , addr_1 = getnewdestination ()
@@ -192,6 +193,34 @@ def test_receive_then_spend(self, node, wallet):
192193 assert_equal (result , node .getdescriptoractivity (
193194 [blockhash_1 , blockhash_2 , blockhash_2 ], [wallet .get_descriptor ()], True ))
194195
196+ def test_no_address (self , node , wallet ):
197+ raw_wallet = MiniWallet (self .nodes [0 ], mode = MiniWalletMode .RAW_P2PK )
198+ raw_wallet .generate (100 , invalid_call = False )
199+
200+ no_addr_tx = raw_wallet .send_self_transfer (from_node = node )
201+ raw_desc = raw_wallet .get_descriptor ()
202+
203+ blockhash = self .generate (node , 1 )[0 ]
204+
205+ result = node .getdescriptoractivity ([blockhash ], [raw_desc ], False )
206+
207+ assert_equal (len (result ['activity' ]), 2 )
208+
209+ a1 = result ['activity' ][0 ]
210+ a2 = result ['activity' ][1 ]
211+
212+ assert a1 ['type' ] == "spend"
213+ assert a1 ['blockhash' ] == blockhash
214+ # sPK lacks address.
215+ assert_equal (list (a1 ['prevout_spk' ].keys ()), ['asm' , 'desc' , 'hex' , 'type' ])
216+ assert a1 ['amount' ] == no_addr_tx ["fee" ] + Decimal (no_addr_tx ["tx" ].vout [0 ].nValue ) / COIN
217+
218+ assert a2 ['type' ] == "receive"
219+ assert a2 ['blockhash' ] == blockhash
220+ # sPK lacks address.
221+ assert_equal (list (a2 ['output_spk' ].keys ()), ['asm' , 'desc' , 'hex' , 'type' ])
222+ assert a2 ['amount' ] == Decimal (no_addr_tx ["tx" ].vout [0 ].nValue ) / COIN
223+
195224
196225if __name__ == '__main__' :
197226 GetBlocksActivityTest (__file__ ).main ()
0 commit comments