@@ -271,28 +271,29 @@ func (m *mockHtlcModifierProperty) HtlcModifier(ctx context.Context,
271271 continue
272272 }
273273
274- assetRate := lnwire .MilliSatoshi (
275- quote .AssetRate .Rate .ToUint64 (),
276- )
277- msatPerBtc := float64 (btcutil .SatoshiPerBitcoin * 1000 )
278- unitValue := msatPerBtc / float64 (assetRate )
279- assetUnits := lnwire .MilliSatoshi (htlc .Amounts .Val .Sum ())
280-
281- floatValue := float64 (assetUnits ) * unitValue
274+ assetRate := quote .AssetRate .Rate
275+ htlcAssets := htlc .Amounts .Val .Sum ()
276+ totalAssetAmount := rfqmath .NewBigIntFixedPoint (htlcAssets , 0 )
282277
283- assetValueMsat := lnwire .MilliSatoshi (floatValue )
278+ amtPaid := rfqmath .UnitsToMilliSatoshi (
279+ totalAssetAmount , assetRate ,
280+ )
284281
285282 acceptedMsat := lnwire .MilliSatoshi (0 )
286283 for _ , htlc := range r .Invoice .Htlcs {
287284 acceptedMsat += lnwire .MilliSatoshi (htlc .AmtMsat )
288285 }
289286
290- marginHtlcs := len (r .Invoice .Htlcs ) + 1
291- marginMsat := lnwire .MilliSatoshi (
292- float64 (marginHtlcs ) * unitValue ,
287+ marginHtlcs := uint64 (len (r .Invoice .Htlcs ) + 1 )
288+ marginHtlcs ++
289+
290+ marginAssetUnits := rfqmath .NewBigIntFixedPoint (marginHtlcs , 0 )
291+
292+ marginMsat := rfqmath .UnitsToMilliSatoshi (
293+ marginAssetUnits , assetRate ,
293294 )
294295
295- totalMsatIn := marginMsat + assetValueMsat + acceptedMsat + 1
296+ totalMsatIn := marginMsat + amtPaid + acceptedMsat + 1
296297
297298 invoiceValue := lnwire .MilliSatoshi (r .Invoice .ValueMsat )
298299
@@ -301,9 +302,9 @@ func (m *mockHtlcModifierProperty) HtlcModifier(ctx context.Context,
301302 m .t .Errorf ("amt + accepted != invoice amt" )
302303 }
303304 } else {
304- if assetValueMsat != res .AmtPaid {
305+ if amtPaid != res .AmtPaid {
305306 m .t .Errorf ("unexpected final asset value, " +
306- "wanted %d, got %d" , assetValueMsat ,
307+ "wanted %d, got %d" , amtPaid ,
307308 res .AmtPaid )
308309 }
309310 }
0 commit comments