Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2477 from cfromknecht/utxo-lnrpc
lnrpc: replace ChanPoint w/ OutPoint in ListUnspent resp
- Loading branch information
Showing
7 changed files
with
710 additions
and
571 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/lightningnetwork/lnd/lnrpc" | ||
) | ||
|
||
// OutPoint displays an outpoint string in the form "<txid>:<output-index>". | ||
type OutPoint string | ||
|
||
// NewOutPointFromProto formats the lnrpc.OutPoint into an OutPoint for display. | ||
func NewOutPointFromProto(op *lnrpc.OutPoint) OutPoint { | ||
return OutPoint(fmt.Sprintf("%s:%d", op.TxidStr, op.OutputIndex)) | ||
} | ||
|
||
// Utxo displays information about an unspent output, including its address, | ||
// amount, pkscript, and confirmations. | ||
type Utxo struct { | ||
Type lnrpc.AddressType `json:"address_type"` | ||
Address string `json:"address"` | ||
AmountSat int64 `json:"amount_sat"` | ||
ScriptPubkey string `json:"script_pubkey"` | ||
OutPoint OutPoint `json:"outpoint"` | ||
Confirmations int64 `json:"confirmations"` | ||
} | ||
|
||
// NewUtxoFromProto creates a display Utxo from the Utxo proto. This filters out | ||
// the raw txid bytes from the provided outpoint, which will otherwise be | ||
// printed in base64. | ||
func NewUtxoFromProto(utxo *lnrpc.Utxo) *Utxo { | ||
return &Utxo{ | ||
Type: utxo.Type, | ||
Address: utxo.Address, | ||
AmountSat: utxo.AmountSat, | ||
ScriptPubkey: utxo.ScriptPubkey, | ||
OutPoint: NewOutPointFromProto(utxo.Outpoint), | ||
Confirmations: utxo.Confirmations, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.