cmd: Export and move utxosToOutpoint.
Signed-off-by: Ononiwu Maureen <59079323+Chinwendu20@users.noreply.github.com>
This commit is contained in:
1 parent
b50a1e6360
commit
900d7fdd17
2 files changed
+20
-19
No files matched your search
@@ -406,7 +406,7 @@ func openChannel(ctx *cli.Context) error {
|
||||
if ctx.IsSet("utxo") {
|
||||
utxos := ctx.StringSlice("utxo")
|
||||
|
||||
outpoints, err := utxosToOutpoints(utxos)
|
||||
outpoints, err := UtxosToOutpoints(utxos)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode utxos: %w", err)
|
||||
}
|
||||
@@ -1141,21 +1141,3 @@ func decodePsbt(psbt string) ([]byte, error) {
|
||||
return nil, fmt.Errorf("not a PSBT")
|
||||
}
|
||||
}
|
||||
|
||||
// parseUtxos parses a comma separated list of utxos into outpoints that are
|
||||
// passed to the server.
|
||||
func utxosToOutpoints(utxos []string) ([]*lnrpc.OutPoint, error) {
|
||||
var outpoints []*lnrpc.OutPoint
|
||||
if len(utxos) == 0 {
|
||||
return nil, fmt.Errorf("no utxos specified")
|
||||
}
|
||||
for _, utxo := range utxos {
|
||||
outpoint, err := NewProtoOutPoint(utxo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
outpoints = append(outpoints, outpoint)
|
||||
}
|
||||
|
||||
return outpoints, nil
|
||||
}
|
||||
@@ -85,3 +85,22 @@ func NewFailedUpdateFromProto(update *lnrpc.FailedUpdate) *FailedUpdate {
|
||||
UpdateError: update.UpdateError,
|
||||
}
|
||||
}
|
||||
|
||||
// UtxosToOutpoints converts a slice of UTXO strings into a slice of OutPoint
|
||||
// protobuf objects. It returns an error if no UTXOs are specified or if any
|
||||
// UTXO string cannot be parsed into an OutPoint.
|
||||
func UtxosToOutpoints(utxos []string) ([]*lnrpc.OutPoint, error) {
|
||||
var outpoints []*lnrpc.OutPoint
|
||||
if len(utxos) == 0 {
|
||||
return nil, fmt.Errorf("no utxos specified")
|
||||
}
|
||||
for _, utxo := range utxos {
|
||||
outpoint, err := NewProtoOutPoint(utxo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
outpoints = append(outpoints, outpoint)
|
||||
}
|
||||
|
||||
return outpoints, nil
|
||||
}
|
||||
Reference in new issue
Block a user