From 4c632627ae9aefc4a5ddc3a934e841b7ae0f40ce Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Fri, 1 Feb 2019 18:02:02 -0800 Subject: [PATCH] cmd/lncli/commands: filter txid_bytes from list_unspent --- cmd/lncli/commands.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/cmd/lncli/commands.go b/cmd/lncli/commands.go index 228ca6b4..f7bbbdf1 100644 --- a/cmd/lncli/commands.go +++ b/cmd/lncli/commands.go @@ -340,11 +340,26 @@ func listUnspent(ctx *cli.Context) error { MinConfs: int32(minConfirms), MaxConfs: int32(maxConfirms), } - jsonResponse, err := client.ListUnspent(ctxb, req) + resp, err := client.ListUnspent(ctxb, req) if err != nil { return err } - printRespJSON(jsonResponse) + + // Parse the response into the final json object that will be printed + // to stdout. At the moment, this filters out the raw txid bytes from + // each utxo's outpoint and only prints the txid string. + var listUnspentResp = struct { + Utxos []*Utxo `json:"utxos"` + }{ + Utxos: make([]*Utxo, 0, len(resp.Utxos)), + } + for _, protoUtxo := range resp.Utxos { + utxo := NewUtxoFromProto(protoUtxo) + listUnspentResp.Utxos = append(listUnspentResp.Utxos, utxo) + } + + printJSON(listUnspentResp) + return nil }