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 }