func FeeForSerializeSize(relayFeePerKb btcutil.Amount, txSerializeSize int) btcutil.Amount {
	fee := relayFeePerKb * btcutil.Amount(txSerializeSize) / 1000
	if fee == 0 && relayFeePerKb > 0 {
		fee = relayFeePerKb
	}
	if fee < 0 || fee > btcutil.MaxSatoshi {
		fee = btcutil.MaxSatoshi
	}
	return fee
}
FeeForSerializeSize calculates the required fee for a transaction of some
arbitrary size given a mempool's relay fee policy.
package txrules
import (
	"errors"
	"github.com/btcsuite/btcd/mempool"
	"github.com/btcsuite/btcd/txscript"
	"github.com/btcsuite/btcd/wire"
	"github.com/btcsuite/btcutil"
)
const DefaultRelayFeePerKb btcutil.Amount = 1e3
func IsDustOutput(output *wire.TxOut, relayFeePerKb btcutil.Amount) bool {
	if txscript.GetScriptClass(output.PkScript) == txscript.NullDataTy {
		return false
	}
	return mempool.IsDust(output, relayFeePerKb)
}
var (
	ErrAmountNegative   = errors.New("transaction output amount is negative")
	ErrAmountExceedsMax = errors.New("transaction output amount exceeds maximum value")
	ErrOutputIsDust     = errors.New("transaction output is dust")
)
func CheckOutput(output *wire.TxOut, relayFeePerKb btcutil.Amount) error {
	if output.Value < 0 {
		return ErrAmountNegative
	}
	if output.Value > btcutil.MaxSatoshi {
		return ErrAmountExceedsMax
	}
	if IsDustOutput(output, relayFeePerKb) {
		return ErrOutputIsDust
	}
	return nil
}