8
8
from test_framework .test_framework import BitcoinTestFramework
9
9
from test_framework .util import assert_equal , assert_raises_rpc_error
10
10
from test_framework .messages import COIN
11
- from test_framework .wallet import MiniWallet , getnewdestination
11
+ from test_framework .wallet import MiniWallet , MiniWalletMode , getnewdestination
12
12
13
13
14
14
class GetBlocksActivityTest (BitcoinTestFramework ):
@@ -30,6 +30,7 @@ def run_test(self):
30
30
self .test_invalid_descriptor (node , wallet )
31
31
self .test_confirmed_and_unconfirmed (node , wallet )
32
32
self .test_receive_then_spend (node , wallet )
33
+ self .test_no_address (node , wallet )
33
34
34
35
def test_no_activity (self , node ):
35
36
_ , _ , addr_1 = getnewdestination ()
@@ -192,6 +193,34 @@ def test_receive_then_spend(self, node, wallet):
192
193
assert_equal (result , node .getdescriptoractivity (
193
194
[blockhash_1 , blockhash_2 , blockhash_2 ], [wallet .get_descriptor ()], True ))
194
195
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
+
195
224
196
225
if __name__ == '__main__' :
197
226
GetBlocksActivityTest (__file__ ).main ()
0 commit comments