invoices+channeldb: add HTLCSet method to invoice

This commit is contained in:
Conner Fromknecht committed 2021-03-03 16:26:43 -08:00
1 parent 7f05c9d3bb
commit b2234703f6
3 files changed
+135 -12

No files matched your search

+3 -12
View File
@@ -143,14 +143,7 @@ func updateMpp(ctx *invoiceUpdateCtx,
// Check whether total amt matches other htlcs in the set.
var newSetTotal lnwire.MilliSatoshi
for _, htlc := range inv.Htlcs {
// Only consider accepted mpp htlcs. It is possible that there
// are htlcs registered in the invoice database that previously
// timed out and are in the canceled state now.
if htlc.State != channeldb.HtlcStateAccepted {
continue
}
for _, htlc := range inv.HTLCSet(nil) {
if ctx.mpp.TotalMsat() != htlc.MppTotalAmt {
return nil, ctx.failRes(ResultHtlcSetTotalMismatch), nil
}
@@ -250,10 +243,8 @@ func updateLegacy(ctx *invoiceUpdateCtx,
// Don't allow settling the invoice with an old style
// htlc if we are already in the process of gathering an
// mpp set.
for _, htlc := range inv.Htlcs {
if htlc.State == channeldb.HtlcStateAccepted &&
htlc.MppTotalAmt > 0 {
for _, htlc := range inv.HTLCSet(nil) {
if htlc.MppTotalAmt > 0 {
return nil, ctx.failRes(ResultMppInProgress), nil
}
}