@@ -932,6 +932,40 @@ def test_avoidreuse(self):
932932 assert_equal (len (watchonly_utxos ), 1 )
933933 assert_equal (watchonly_utxos [0 ]["reused" ], True )
934934
935+ def test_preserve_tx_extra_info (self ):
936+ self .log .info ("Test that tx extra data is preserved after migration" )
937+ def_wallet = self .nodes [0 ].get_wallet_rpc (self .default_wallet_name )
938+
939+ # Create and fund wallet
940+ wallet = self .create_legacy_wallet ("persist_comments" )
941+ def_wallet .sendtoaddress (wallet .getnewaddress (), 2 )
942+
943+ self .generate (self .nodes [0 ], 6 )
944+
945+ # Create tx and bump it to store 'replaced_by_txid' and 'replaces_txid' data within the transactions.
946+ # Additionally, store an extra comment within the original tx.
947+ extra_comment = "don't discard me"
948+ original_tx_id = wallet .sendtoaddress (address = wallet .getnewaddress (), amount = 1 , comment = extra_comment )
949+ bumped_tx = wallet .bumpfee (txid = original_tx_id )
950+
951+ def check_comments ():
952+ for record in wallet .listtransactions ():
953+ if record ["txid" ] == original_tx_id :
954+ assert_equal (record ["replaced_by_txid" ], bumped_tx ["txid" ])
955+ assert_equal (record ['comment' ], extra_comment )
956+ elif record ["txid" ] == bumped_tx ["txid" ]:
957+ assert_equal (record ["replaces_txid" ], original_tx_id )
958+
959+ # Pre-migration verification
960+ check_comments ()
961+ # Migrate
962+ wallet .migratewallet ()
963+ # Post-migration verification
964+ check_comments ()
965+
966+ wallet .unloadwallet ()
967+
968+
935969 def run_test (self ):
936970 self .generate (self .nodes [0 ], 101 )
937971
@@ -952,6 +986,7 @@ def run_test(self):
952986 self .test_hybrid_pubkey ()
953987 self .test_failed_migration_cleanup ()
954988 self .test_avoidreuse ()
989+ self .test_preserve_tx_extra_info ()
955990
956991if __name__ == '__main__' :
957992 WalletMigrationTest ().main ()
0 commit comments