@@ -248,6 +248,9 @@ type AssetPurchasePolicy struct {
248248 // BidAssetRate is the quote's asset to BTC conversion rate.
249249 BidAssetRate rfqmath.BigIntFixedPoint
250250
251+ // PaymentMaxAmt is the maximum agreed BTC payment.
252+ PaymentMaxAmt lnwire.MilliSatoshi
253+
251254 // expiry is the policy's expiry unix timestamp in seconds after which
252255 // the policy is no longer valid.
253256 expiry uint64
@@ -260,6 +263,7 @@ func NewAssetPurchasePolicy(quote rfqmsg.SellAccept) *AssetPurchasePolicy {
260263 AssetSpecifier : quote .Request .AssetSpecifier ,
261264 AcceptedQuoteId : quote .ID ,
262265 BidAssetRate : quote .AssetRate ,
266+ PaymentMaxAmt : quote .Request .PaymentMaxAmt ,
263267 expiry : quote .Expiry ,
264268 }
265269}
@@ -308,6 +312,15 @@ func (c *AssetPurchasePolicy) CheckHtlcCompliance(
308312 assetAmt .String (), inboundAmountMSat )
309313 }
310314
315+ // Ensure that the outbound HTLC amount is less than the maximum agreed
316+ // BTC payment.
317+ if htlc .AmountOutMsat > c .PaymentMaxAmt {
318+ return fmt .Errorf ("htlc out amount is more than the maximum " +
319+ "agreed BTC payment (htlc_out_msat=%d, " +
320+ "payment_max_amt=%d)" , htlc .AmountOutMsat ,
321+ c .PaymentMaxAmt )
322+ }
323+
311324 // Lastly, check to ensure that the policy has not expired.
312325 if time .Now ().Unix () > int64 (c .expiry ) {
313326 return fmt .Errorf ("policy has expired (expiry_unix_ts=%d)" ,
0 commit comments