rpc: minConfs and spendUnconfirmed for EstimateFee

This commit is contained in:
Tom Kirkpatrick
2021-04-22 19:25:50 +02:00
parent 76706c7473
commit 2f80283ec2
8 changed files with 855 additions and 738 deletions

View File

@ -975,7 +975,7 @@ func (r *rpcServer) sendCoinsOnChain(paymentMap map[string]int64,
// We first do a dry run, to sanity check we won't spend our wallet
// balance below the reserved amount.
authoredTx, err := r.server.cc.Wallet.CreateSimpleTx(
outputs, feeRate, true,
outputs, feeRate, minConfs, true,
)
if err != nil {
return nil, err
@ -1073,12 +1073,21 @@ func (r *rpcServer) EstimateFee(ctx context.Context,
return nil, err
}
// Then, we'll extract the minimum number of confirmations that each
// output we use to fund the transaction should satisfy.
minConfs, err := lnrpc.ExtractMinConfs(
in.GetMinConfs(), in.GetSpendUnconfirmed(),
)
if err != nil {
return nil, err
}
// We will ask the wallet to create a tx using this fee rate. We set
// dryRun=true to avoid inflating the change addresses in the db.
var tx *txauthor.AuthoredTx
wallet := r.server.cc.Wallet
err = wallet.WithCoinSelectLock(func() error {
tx, err = wallet.CreateSimpleTx(outputs, feePerKw, true)
tx, err = wallet.CreateSimpleTx(outputs, feePerKw, minConfs, true)
return err
})
if err != nil {