Skip to content

Commit

Permalink
cmd/lncli/commands: filter txid_bytes from list_unspent
Browse files Browse the repository at this point in the history
  • Loading branch information
cfromknecht committed Feb 2, 2019
1 parent b25f1af commit 4c63262
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions cmd/lncli/commands.go
Expand Up @@ -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
}

Expand Down

0 comments on commit 4c63262

Please sign in to comment.