@@ -16,6 +16,7 @@ import (
1616 "github.com/lightninglabs/taproot-assets/taprpc/tapchannelrpc"
1717 "github.com/lightninglabs/taproot-assets/taprpc/universerpc"
1818 "github.com/lightningnetwork/lnd/lnrpc"
19+ "github.com/lightningnetwork/lnd/lnwire"
1920 "github.com/lightningnetwork/lnd/macaroons"
2021 "google.golang.org/grpc"
2122 "google.golang.org/grpc/credentials"
@@ -105,9 +106,12 @@ func (c *TapdClient) GetRfqForAsset(ctx context.Context,
105106 expiry int64 , feeLimitMultiplier float64 ) (
106107 * rfqrpc.PeerAcceptedSellQuote , error ) {
107108
108- feeLimit , err := lnrpc .UnmarshallAmt (
109- int64 (satAmount )+ int64 (satAmount .MulF64 (feeLimitMultiplier )), 0 ,
110- )
109+ // paymentMaxAmt is the maximum amount we are willing to pay for the
110+ // payment.
111+ // E.g. on a 250k sats payment we'll multiply the sat amount by 1.2.
112+ // The resulting maximum amount we're willing to pay is 300k sats.
113+ // The response asset amount will be for those 300k sats.
114+ paymentMaxAmt , err := getPaymentMaxAmount (satAmount , feeLimitMultiplier )
111115 if err != nil {
112116 return nil , err
113117 }
@@ -120,7 +124,7 @@ func (c *TapdClient) GetRfqForAsset(ctx context.Context,
120124 },
121125 },
122126 PeerPubKey : peerPubkey ,
123- PaymentMaxAmt : uint64 (feeLimit ),
127+ PaymentMaxAmt : uint64 (paymentMaxAmt ),
124128 Expiry : uint64 (expiry ),
125129 TimeoutSeconds : uint32 (c .cfg .RFQtimeout .Seconds ()),
126130 })
@@ -180,6 +184,28 @@ func (c *TapdClient) GetAssetName(ctx context.Context,
180184 return assetName , nil
181185}
182186
187+ // getPaymentMaxAmount returns the milisat amount we are willing to pay for the
188+ // payment.
189+ func getPaymentMaxAmount (satAmount btcutil.Amount , feeLimitMultiplier float64 ) (
190+ lnwire.MilliSatoshi , error ) {
191+
192+ if satAmount == 0 {
193+ return 0 , fmt .Errorf ("satAmount cannot be zero" )
194+ }
195+ if feeLimitMultiplier < 1 {
196+ return 0 , fmt .Errorf ("feeLimitMultiplier must be at least 1" )
197+ }
198+
199+ // paymentMaxAmt is the maximum amount we are willing to pay for the
200+ // payment.
201+ // E.g. on a 250k sats payment we'll multiply the sat amount by 1.2.
202+ // The resulting maximum amount we're willing to pay is 300k sats.
203+ // The response asset amount will be for those 300k sats.
204+ return lnrpc .UnmarshallAmt (
205+ int64 (satAmount .MulF64 (feeLimitMultiplier )), 0 ,
206+ )
207+ }
208+
183209func getClientConn (config * TapdConfig ) (* grpc.ClientConn , error ) {
184210 // Load the specified TLS certificate and build transport credentials.
185211 creds , err := credentials .NewClientTLSFromFile (config .TLSPath , "" )
0 commit comments