Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions wallet/txauthor/author.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2016 The btcsuite developers
// Copyright (c) 2016-2024 The Decred developers
// Copyright (c) 2016-2026 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -94,10 +94,6 @@ func NewUnsignedTransaction(outputs []*wire.TxOut, relayFeePerKb dcrutil.Amount,

targetAmount := sumOutputValues(outputs)
scriptSizes := []int{txsizes.RedeemP2PKHSigScriptSize}
changeScript, changeScriptVersion, err := fetchChange.Script()
if err != nil {
return nil, errors.E(op, err)
}
changeScriptSize := fetchChange.ScriptSize()
maxSignedSize := txsizes.EstimateSerializeSize(scriptSizes, outputs, changeScriptSize)
targetFee := txrules.FeeForSerializeSize(relayFeePerKb, maxSignedSize)
Expand Down Expand Up @@ -139,6 +135,10 @@ func NewUnsignedTransaction(outputs []*wire.TxOut, relayFeePerKb dcrutil.Amount,
changeAmount := inputDetail.Amount - targetAmount - maxRequiredFee
if changeAmount != 0 && !txrules.IsDustAmount(changeAmount,
changeScriptSize, relayFeePerKb) {
changeScript, changeScriptVersion, err := fetchChange.Script()
if err != nil {
return nil, errors.E(op, err)
}
if len(changeScript) > txscript.MaxScriptElementSize {
return nil, errors.E(errors.Invalid, "script size exceed maximum bytes "+
"pushable to the stack")
Expand Down
Loading