@@ -1243,29 +1243,46 @@ var listTransfersCommand = cli.Command{
1243
1243
Name : "transfers" ,
1244
1244
ShortName : "t" ,
1245
1245
Usage : "list asset transfers" ,
1246
- Description : "list outgoing transfers of all assets or a selected " +
1247
- "asset " ,
1246
+ Description : "list outgoing transfer for a specific anchor or if " +
1247
+ "not set, all transfers " ,
1248
1248
Action : listTransfers ,
1249
1249
Flags : []cli.Flag {
1250
1250
cli.StringFlag {
1251
- Name : assetIDName ,
1252
- Usage : "A specific asset ID to list outgoing " +
1253
- "transfers for" ,
1251
+ Name : anchorTxidName ,
1252
+ Usage : "A specific anchor transaction ID to run the " +
1253
+ " transfer query against. If not set, all " +
1254
+ " transfers will be returned." ,
1254
1255
},
1255
1256
},
1256
1257
}
1257
1258
1259
+ // reverseByteOrder reverses the byte order of the byte slice in place.
1260
+ func reverseByteOrder (b []byte ) {
1261
+ for i , j := 0 , len (b )- 1 ; i < j ; i , j = i + 1 , j - 1 {
1262
+ b [i ], b [j ] = b [j ], b [i ]
1263
+ }
1264
+ }
1265
+
1258
1266
func listTransfers (ctx * cli.Context ) error {
1259
1267
ctxc := getContext ()
1260
1268
client , cleanUp := getClient (ctx )
1261
1269
defer cleanUp ()
1262
1270
1263
- req := & taprpc.ListTransfersRequest {}
1271
+ req := & taprpc.ListTransfersRequest {
1272
+ AnchorTxid : ctx .String (anchorTxidName ),
1273
+ }
1264
1274
resp , err := client .ListTransfers (ctxc , req )
1265
1275
if err != nil {
1266
1276
return fmt .Errorf ("unable to list asset transfers: %w" , err )
1267
1277
}
1268
1278
1279
+ // As the anchor TX hash is returned in a byte slice we need to reverse
1280
+ // the byte order to match the expected hex format of string serialized
1281
+ // transaction IDs.
1282
+ for _ , transfer := range resp .Transfers {
1283
+ reverseByteOrder (transfer .AnchorTxHash )
1284
+ }
1285
+
1269
1286
printRespJSON (resp )
1270
1287
return nil
1271
1288
}
0 commit comments