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 5
5
"encoding/hex"
6
6
"errors"
7
7
"fmt"
8
+ "strings"
8
9
"sync"
9
10
"sync/atomic"
10
11
"time"
59
60
globalCallTimeout = serverRPCTimeout + lsat .PaymentTimeout
60
61
61
62
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
62
68
)
63
69
64
70
// Client performs the client side part of swaps. This interface exists to be
@@ -505,10 +511,24 @@ func (s *Client) LoopInQuote(ctx context.Context,
505
511
}, nil
506
512
}
507
513
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.
509
522
minerFee , err := s .lndServices .Client .EstimateFeeToP2WSH (
510
523
ctx , request .Amount , request .HtlcConfTarget ,
511
524
)
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
+ }
512
532
if err != nil {
513
533
return nil , err
514
534
}
You can’t perform that action at this time.
0 commit comments