Skip to content

Commit 807aa61

Browse files
authored
Merge pull request #1090 from Olexandr88/master
fix: guard against short reservation id when printing shortid
2 parents 5b68d40 + 6fd752f commit 807aa61

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

cmd/loop/instantout.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ func instantOut(ctx context.Context, cmd *cli.Command) error {
8888
fmt.Printf("Available reservations: \n\n")
8989
for _, res := range confirmedReservations {
9090
idx++
91+
if len(res.ReservationId) != reservation.IdLength {
92+
return fmt.Errorf("invalid reservation id length: "+
93+
"got %d, expected %d", len(res.ReservationId),
94+
reservation.IdLength)
95+
}
96+
9197
fmt.Printf("Reservation %v: shortid %x, amt %v, expiry "+
9298
"height %v \n", idx, res.ReservationId[:3], res.Amount,
9399
res.Expiry)
@@ -131,7 +137,7 @@ func instantOut(ctx context.Context, cmd *cli.Command) error {
131137
if err != nil {
132138
return err
133139
}
134-
if idx < 0 {
140+
if idx <= 0 {
135141
return fmt.Errorf("invalid index %v", idx)
136142
}
137143

0 commit comments

Comments
 (0)