wallet/txauthor: rename relayFeePerKb to feeRatePerKb

The new name more accurately reflects the usage of the value. This is
the target fee rate that the constructed transaction should aim to meet.
This commit is contained in:
Olaoluwa Osuntokun 2020-08-13 16:57:32 -07:00
parent fbb3bc184d
commit cde4b5dca4
No known key found for this signature in database
GPG key ID: BC13F65E2DC84465

View file

@ -83,12 +83,12 @@ type ChangeSource func() ([]byte, error)
// InputSourceError is returned. // InputSourceError is returned.
// //
// BUGS: Fee estimation may be off when redeeming non-compressed P2PKH outputs. // 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) { fetchInputs InputSource, fetchChange ChangeSource) (*AuthoredTx, error) {
targetAmount := SumOutputValues(outputs) targetAmount := SumOutputValues(outputs)
estimatedSize := txsizes.EstimateVirtualSize(0, 1, 0, outputs, true) estimatedSize := txsizes.EstimateVirtualSize(0, 1, 0, outputs, true)
targetFee := txrules.FeeForSerializeSize(relayFeePerKb, estimatedSize) targetFee := txrules.FeeForSerializeSize(feeRatePerKb, estimatedSize)
for { for {
inputAmount, inputs, inputValues, scripts, err := fetchInputs(targetAmount + targetFee) 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, maxSignedSize := txsizes.EstimateVirtualSize(p2pkh, p2wpkh,
nested, outputs, true) nested, outputs, true)
maxRequiredFee := txrules.FeeForSerializeSize(relayFeePerKb, maxSignedSize) maxRequiredFee := txrules.FeeForSerializeSize(feeRatePerKb, maxSignedSize)
remainingAmount := inputAmount - targetAmount remainingAmount := inputAmount - targetAmount
if remainingAmount < maxRequiredFee { if remainingAmount < maxRequiredFee {
targetFee = maxRequiredFee targetFee = maxRequiredFee