Skip to content

Commit 900d7fd

Browse files
Chinwendu20yyforyongyu
authored andcommitted
cmd: Export and move utxosToOutpoint.
Signed-off-by: Ononiwu Maureen <[email protected]>
1 parent b50a1e6 commit 900d7fd

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

cmd/lncli/cmd_open_channel.go

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ func openChannel(ctx *cli.Context) error {
406406
if ctx.IsSet("utxo") {
407407
utxos := ctx.StringSlice("utxo")
408408

409-
outpoints, err := utxosToOutpoints(utxos)
409+
outpoints, err := UtxosToOutpoints(utxos)
410410
if err != nil {
411411
return fmt.Errorf("unable to decode utxos: %w", err)
412412
}
@@ -1141,21 +1141,3 @@ func decodePsbt(psbt string) ([]byte, error) {
11411141
return nil, fmt.Errorf("not a PSBT")
11421142
}
11431143
}
1144-
1145-
// parseUtxos parses a comma separated list of utxos into outpoints that are
1146-
// passed to the server.
1147-
func utxosToOutpoints(utxos []string) ([]*lnrpc.OutPoint, error) {
1148-
var outpoints []*lnrpc.OutPoint
1149-
if len(utxos) == 0 {
1150-
return nil, fmt.Errorf("no utxos specified")
1151-
}
1152-
for _, utxo := range utxos {
1153-
outpoint, err := NewProtoOutPoint(utxo)
1154-
if err != nil {
1155-
return nil, err
1156-
}
1157-
outpoints = append(outpoints, outpoint)
1158-
}
1159-
1160-
return outpoints, nil
1161-
}

cmd/lncli/types.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,22 @@ func NewFailedUpdateFromProto(update *lnrpc.FailedUpdate) *FailedUpdate {
8585
UpdateError: update.UpdateError,
8686
}
8787
}
88+
89+
// UtxosToOutpoints converts a slice of UTXO strings into a slice of OutPoint
90+
// protobuf objects. It returns an error if no UTXOs are specified or if any
91+
// UTXO string cannot be parsed into an OutPoint.
92+
func UtxosToOutpoints(utxos []string) ([]*lnrpc.OutPoint, error) {
93+
var outpoints []*lnrpc.OutPoint
94+
if len(utxos) == 0 {
95+
return nil, fmt.Errorf("no utxos specified")
96+
}
97+
for _, utxo := range utxos {
98+
outpoint, err := NewProtoOutPoint(utxo)
99+
if err != nil {
100+
return nil, err
101+
}
102+
outpoints = append(outpoints, outpoint)
103+
}
104+
105+
return outpoints, nil
106+
}

0 commit comments

Comments
 (0)