Skip to content

Commit 668c697

Browse files
committed
litcli: handle 0 asset units case on sendpayment results
1 parent d48feca commit 668c697

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cmd/litcli/ln.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,13 @@ func (w *resultStreamWrapper) Recv() (*lnrpc.Payment, error) {
216216
amountMsat := lnwire.MilliSatoshi(w.amountMsat)
217217
milliSatsFP := rfqmath.MilliSatoshiToUnits(amountMsat, *rate)
218218
numUnits := milliSatsFP.ScaleTo(0).ToUint64()
219+
if numUnits == 0 {
220+
return nil, fmt.Errorf("asset rate %v not sufficient "+
221+
"to represent value of %v",
222+
rate.ToUint64(), amountMsat,
223+
)
224+
}
225+
219226
msatPerUnit := uint64(w.amountMsat) / numUnits
220227

221228
fmt.Printf("Got quote for %v asset units at %v msat/unit from "+

0 commit comments

Comments
 (0)