diff --git a/wallet/txauthor/author.go b/wallet/txauthor/author.go index 18f996c..5290c77 100644 --- a/wallet/txauthor/author.go +++ b/wallet/txauthor/author.go @@ -83,12 +83,12 @@ type ChangeSource func() ([]byte, error) // InputSourceError is returned. // // BUGS: Fee estimation may be off when redeeming non-compressed P2PKH outputs. -func NewUnsignedTransaction(outputs []*wire.TxOut, relayFeePerKb btcutil.Amount, +func NewUnsignedTransaction(outputs []*wire.TxOut, feeRatePerKb btcutil.Amount, fetchInputs InputSource, fetchChange ChangeSource) (*AuthoredTx, error) { targetAmount := SumOutputValues(outputs) estimatedSize := txsizes.EstimateVirtualSize(0, 1, 0, outputs, true) - targetFee := txrules.FeeForSerializeSize(relayFeePerKb, estimatedSize) + targetFee := txrules.FeeForSerializeSize(feeRatePerKb, estimatedSize) for { inputAmount, inputs, inputValues, scripts, err := fetchInputs(targetAmount + targetFee) @@ -117,7 +117,7 @@ func NewUnsignedTransaction(outputs []*wire.TxOut, relayFeePerKb btcutil.Amount, maxSignedSize := txsizes.EstimateVirtualSize(p2pkh, p2wpkh, nested, outputs, true) - maxRequiredFee := txrules.FeeForSerializeSize(relayFeePerKb, maxSignedSize) + maxRequiredFee := txrules.FeeForSerializeSize(feeRatePerKb, maxSignedSize) remainingAmount := inputAmount - targetAmount if remainingAmount < maxRequiredFee { targetFee = maxRequiredFee @@ -133,7 +133,7 @@ func NewUnsignedTransaction(outputs []*wire.TxOut, relayFeePerKb btcutil.Amount, changeIndex := -1 changeAmount := inputAmount - targetAmount - maxRequiredFee if changeAmount != 0 && !txrules.IsDustAmount(changeAmount, - txsizes.P2WPKHPkScriptSize, relayFeePerKb) { + txsizes.P2WPKHPkScriptSize, txrules.DefaultRelayFeePerKb) { changeScript, err := fetchChange() if err != nil { return nil, err