@@ -231,6 +231,41 @@ describe("serializers.ts", () => {
231231 feePerByte : undefined ,
232232 } ) ;
233233 } ) ;
234+
235+ it ( "should succeed to serialize a bitcoin transaction with changeAddress" , ( ) => {
236+ const transaction : BitcoinTransaction = {
237+ amount : new BigNumber ( 100 ) ,
238+ recipient : "recipient" ,
239+ family,
240+ changeAddress : "changeAddress" ,
241+ } ;
242+ const serializedTransaction = serializeTransaction ( transaction ) ;
243+
244+ expect ( serializedTransaction ) . toEqual ( {
245+ family,
246+ amount : "100" ,
247+ recipient : "recipient" ,
248+ feePerByte : undefined ,
249+ changeAddress : "changeAddress" ,
250+ } ) ;
251+ } ) ;
252+
253+ it ( "should succeed to serialize a bitcoin transaction without changeAddress" , ( ) => {
254+ const transaction : BitcoinTransaction = {
255+ amount : new BigNumber ( 100 ) ,
256+ recipient : "recipient" ,
257+ family,
258+ } ;
259+ const serializedTransaction = serializeTransaction ( transaction ) ;
260+
261+ expect ( serializedTransaction ) . toEqual ( {
262+ family,
263+ amount : "100" ,
264+ recipient : "recipient" ,
265+ feePerByte : undefined ,
266+ changeAddress : undefined ,
267+ } ) ;
268+ } ) ;
234269 } ) ;
235270
236271 describe ( "kaspa" , ( ) => {
@@ -1114,6 +1149,43 @@ describe("serializers.ts", () => {
11141149 feePerByte : undefined ,
11151150 } ) ;
11161151 } ) ;
1152+
1153+ it ( "should succeed to deserialize a bitcoin transaction with changeAddress" , ( ) => {
1154+ const serializedTransaction : RawBitcoinTransaction = {
1155+ family,
1156+ amount : "0" ,
1157+ recipient : "recipient" ,
1158+ changeAddress : "changeAddress" ,
1159+ } ;
1160+
1161+ const transaction = deserializeTransaction ( serializedTransaction ) ;
1162+
1163+ expect ( transaction ) . toEqual ( {
1164+ family,
1165+ amount : new BigNumber ( 0 ) ,
1166+ recipient : "recipient" ,
1167+ feePerByte : undefined ,
1168+ changeAddress : "changeAddress" ,
1169+ } ) ;
1170+ } ) ;
1171+
1172+ it ( "should succeed to deserialize a bitcoin transaction without changeAddress" , ( ) => {
1173+ const serializedTransaction : RawBitcoinTransaction = {
1174+ family,
1175+ amount : "0" ,
1176+ recipient : "recipient" ,
1177+ } ;
1178+
1179+ const transaction = deserializeTransaction ( serializedTransaction ) ;
1180+
1181+ expect ( transaction ) . toEqual ( {
1182+ family,
1183+ amount : new BigNumber ( 0 ) ,
1184+ recipient : "recipient" ,
1185+ feePerByte : undefined ,
1186+ changeAddress : undefined ,
1187+ } ) ;
1188+ } ) ;
11171189 } ) ;
11181190
11191191 describe ( "kaspa" , ( ) => {
0 commit comments