File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 55 "encoding/hex"
66 "errors"
77 "fmt"
8+ "strings"
89 "sync"
910 "sync/atomic"
1011 "time"
5960 globalCallTimeout = serverRPCTimeout + lsat .PaymentTimeout
6061
6162 republishDelay = 10 * time .Second
63+
64+ // MinerFeeEstimationFailed is a magic number that is returned in a
65+ // quote call as the miner fee if the fee estimation in lnd's wallet
66+ // failed because of insufficient funds.
67+ MinerFeeEstimationFailed btcutil.Amount = - 1
6268)
6369
6470// Client performs the client side part of swaps. This interface exists to be
@@ -505,10 +511,24 @@ func (s *Client) LoopInQuote(ctx context.Context,
505511 }, nil
506512 }
507513
508- // Get estimate for miner fee.
514+ // Get estimate for miner fee. If estimating the miner fee for the
515+ // requested amount is not possible because lnd's wallet cannot
516+ // construct a sample TX, we just return zero instead of failing the
517+ // quote. The user interface should inform the user that fee estimation
518+ // was not possible.
519+ //
520+ // TODO(guggero): Thread through error code from lnd to avoid string
521+ // matching.
509522 minerFee , err := s .lndServices .Client .EstimateFeeToP2WSH (
510523 ctx , request .Amount , request .HtlcConfTarget ,
511524 )
525+ if err != nil && strings .Contains (err .Error (), "insufficient funds" ) {
526+ return & LoopInQuote {
527+ SwapFee : swapFee ,
528+ MinerFee : MinerFeeEstimationFailed ,
529+ CltvDelta : quote .CltvDelta ,
530+ }, nil
531+ }
512532 if err != nil {
513533 return nil , err
514534 }
You can’t perform that action at this time.
0 commit comments