@@ -133,9 +133,32 @@ def export_import(self, piecemeal_output_export):
133
133
res = self .hot_wallet .export_outputs ()
134
134
self .cold_wallet .import_outputs (res .outputs_data_hex )
135
135
136
+ # Check consistency between hot & cold transfers list, especially that one-time addresses and amounts line up
137
+ def check_transfers_list_consistency (do_check_key_images ):
138
+ hot_transfers_list = self .hot_wallet .incoming_transfers ()
139
+ cold_transfers_list = self .cold_wallet .incoming_transfers ()
140
+ if 'transfers' not in hot_transfers_list :
141
+ assert 'transfers' not in cold_transfers_list
142
+ return
143
+ hot_transfers_list = hot_transfers_list ['transfers' ]
144
+ cold_transfers_list = cold_transfers_list ['transfers' ]
145
+ assert len (hot_transfers_list ) == len (cold_transfers_list )
146
+ attributes_to_cmp = ['amount' , 'subaddr_index' , 'pubkey' ]
147
+ if do_check_key_images :
148
+ attributes_to_cmp .append ("key_image" )
149
+ for i in range (len (hot_transfers_list )):
150
+ for attr in attributes_to_cmp :
151
+ hot_val = hot_transfers_list [i ][attr ]
152
+ cold_val = cold_transfers_list [i ][attr ]
153
+ assert hot_val == cold_val , "outputs mismatch ({}, \" {}\" ): {} vs {}" .format (i , attr , hot_val , cold_val )
154
+
155
+ check_transfers_list_consistency (False )
156
+
136
157
res = self .cold_wallet .export_key_images (True )
137
158
self .hot_wallet .import_key_images (res .signed_key_images , offset = res .offset )
138
159
160
+ check_transfers_list_consistency (True )
161
+
139
162
def create_tx (self , destination_addr , piecemeal_output_export ):
140
163
daemon = Daemon ()
141
164
0 commit comments