Skip to content

Commit 4f645ce

Browse files
authored
Merge pull request #1194 from lightninglabs/rfq-rounding
rfq: fix precision issue in HTLC compliance check
2 parents ee06af7 + dafd55e commit 4f645ce

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

rfq/order.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,13 @@ func (c *AssetPurchasePolicy) CheckHtlcCompliance(
297297
return fmt.Errorf("error summing asset balance: %w", err)
298298
}
299299

300+
// Due to rounding errors, we may slightly underreport the incoming
301+
// value of the asset. So we increase it by exactly one asset unit to
302+
// ensure that we do not reject the HTLC in the "inbound amount cannot
303+
// be less than outbound amount" check below.
304+
roundingCorrection := rfqmath.NewBigIntFromUint64(1)
305+
assetAmt = assetAmt.Add(roundingCorrection)
306+
300307
// Convert the inbound asset amount to millisatoshis and ensure that the
301308
// outgoing HTLC amount is not more than the inbound asset amount.
302309
assetAmtFp := new(rfqmath.BigIntFixedPoint).SetIntValue(assetAmt)

0 commit comments

Comments
 (0)