@@ -16,6 +16,7 @@ import (
16
16
"github.com/lightninglabs/taproot-assets/taprpc/tapchannelrpc"
17
17
"github.com/lightninglabs/taproot-assets/taprpc/universerpc"
18
18
"github.com/lightningnetwork/lnd/lnrpc"
19
+ "github.com/lightningnetwork/lnd/lnwire"
19
20
"github.com/lightningnetwork/lnd/macaroons"
20
21
"google.golang.org/grpc"
21
22
"google.golang.org/grpc/credentials"
@@ -105,9 +106,12 @@ func (c *TapdClient) GetRfqForAsset(ctx context.Context,
105
106
expiry int64 , feeLimitMultiplier float64 ) (
106
107
* rfqrpc.PeerAcceptedSellQuote , error ) {
107
108
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 )
111
115
if err != nil {
112
116
return nil , err
113
117
}
@@ -120,7 +124,7 @@ func (c *TapdClient) GetRfqForAsset(ctx context.Context,
120
124
},
121
125
},
122
126
PeerPubKey : peerPubkey ,
123
- PaymentMaxAmt : uint64 (feeLimit ),
127
+ PaymentMaxAmt : uint64 (paymentMaxAmt ),
124
128
Expiry : uint64 (expiry ),
125
129
TimeoutSeconds : uint32 (c .cfg .RFQtimeout .Seconds ()),
126
130
})
@@ -180,6 +184,28 @@ func (c *TapdClient) GetAssetName(ctx context.Context,
180
184
return assetName , nil
181
185
}
182
186
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
+
183
209
func getClientConn (config * TapdConfig ) (* grpc.ClientConn , error ) {
184
210
// Load the specified TLS certificate and build transport credentials.
185
211
creds , err := credentials .NewClientTLSFromFile (config .TLSPath , "" )
0 commit comments