diff --git a/cmd/lncli/cmd_open_channel.go b/cmd/lncli/cmd_open_channel.go index e3044c835..f0585ed47 100644 --- a/cmd/lncli/cmd_open_channel.go +++ b/cmd/lncli/cmd_open_channel.go @@ -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 -} diff --git a/cmd/lncli/types.go b/cmd/lncli/types.go index b878811a0..a93d3e2c6 100644 --- a/cmd/lncli/types.go +++ b/cmd/lncli/types.go @@ -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 +}