sweep+cnct+nursery+rpc: extract DetermineFeePerKw to func, add FeePreference

In this commit, we extract the existing determineFeePerKw method on the
RPC server into a new file in the sweep package. Along the way, we
consolidate code by introducing a new FeePreference struct, which allows
the caller to express their fee preference either in blocks to
confirmation, or a direct fee rate. This move takes a small step to
father decoupling calls in the main RPC server.
This commit is contained in:
Olaoluwa Osuntokun
2018-11-17 20:44:34 -08:00
parent 77262ff699
commit 73c9c2ee15
4 changed files with 112 additions and 61 deletions

View File

@ -750,10 +750,10 @@ func (s *UtxoSweeper) waitForSpend(outpoint wire.OutPoint,
// - Make handling re-orgs easier.
// - Thwart future possible fee sniping attempts.
// - Make us blend in with the bitcoind wallet.
func (s *UtxoSweeper) CreateSweepTx(inputs []Input, confTarget uint32,
func (s *UtxoSweeper) CreateSweepTx(inputs []Input, feePref FeePreference,
currentBlockHeight uint32) (*wire.MsgTx, error) {
feePerKw, err := s.cfg.FeeEstimator.EstimateFeePerKW(confTarget)
feePerKw, err := DetermineFeePerKw(s.cfg.FeeEstimator, feePref)
if err != nil {
return nil, err
}