cmd/lncli/commands: filter txid_bytes from list_unspent

This commit is contained in:
Conner Fromknecht 2019-02-01 18:02:02 -08:00
parent b25f1af347
commit 4c632627ae
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -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
}