config: New option --minrelaytxfee
--minrelaytxfee allows the user to specify the minimum transaction fee in BTC/kB in which the fee is considered a non-zero fee.
This commit is contained in:
parent
5a9bac9668
commit
a56db22e9b
6 changed files with 31 additions and 12 deletions
13
config.go
13
config.go
|
@ -106,6 +106,7 @@ type config struct {
|
||||||
CPUProfile string `long:"cpuprofile" description:"Write CPU profile to the specified file"`
|
CPUProfile string `long:"cpuprofile" description:"Write CPU profile to the specified file"`
|
||||||
DebugLevel string `short:"d" long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set the log level for individual subsystems -- Use show to list available subsystems"`
|
DebugLevel string `short:"d" long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set the log level for individual subsystems -- Use show to list available subsystems"`
|
||||||
Upnp bool `long:"upnp" description:"Use UPnP to map our listening port outside of NAT"`
|
Upnp bool `long:"upnp" description:"Use UPnP to map our listening port outside of NAT"`
|
||||||
|
MinRelayTxFee float64 `long:"minrelaytxfee" description:"The minimum transaction fee in BTC/kB to be considered a non-zero fee."`
|
||||||
FreeTxRelayLimit float64 `long:"limitfreerelay" description:"Limit relay of transactions with no transaction fee to the given amount in thousands of bytes per minute"`
|
FreeTxRelayLimit float64 `long:"limitfreerelay" description:"Limit relay of transactions with no transaction fee to the given amount in thousands of bytes per minute"`
|
||||||
NoRelayPriority bool `long:"norelaypriority" description:"Do not require free or low-fee transactions to have high priority for relaying"`
|
NoRelayPriority bool `long:"norelaypriority" description:"Do not require free or low-fee transactions to have high priority for relaying"`
|
||||||
MaxOrphanTxs int `long:"maxorphantx" description:"Max number of orphan transactions to keep in memory"`
|
MaxOrphanTxs int `long:"maxorphantx" description:"Max number of orphan transactions to keep in memory"`
|
||||||
|
@ -124,6 +125,7 @@ type config struct {
|
||||||
oniondial func(string, string) (net.Conn, error)
|
oniondial func(string, string) (net.Conn, error)
|
||||||
dial func(string, string) (net.Conn, error)
|
dial func(string, string) (net.Conn, error)
|
||||||
miningAddrs []btcutil.Address
|
miningAddrs []btcutil.Address
|
||||||
|
minRelayTxFee btcutil.Amount
|
||||||
}
|
}
|
||||||
|
|
||||||
// serviceOptions defines the configuration options for btcd as a service on
|
// serviceOptions defines the configuration options for btcd as a service on
|
||||||
|
@ -320,6 +322,7 @@ func loadConfig() (*config, []string, error) {
|
||||||
DbType: defaultDbType,
|
DbType: defaultDbType,
|
||||||
RPCKey: defaultRPCKeyFile,
|
RPCKey: defaultRPCKeyFile,
|
||||||
RPCCert: defaultRPCCertFile,
|
RPCCert: defaultRPCCertFile,
|
||||||
|
MinRelayTxFee: defaultMinRelayTxFee.ToBTC(),
|
||||||
FreeTxRelayLimit: defaultFreeTxRelayLimit,
|
FreeTxRelayLimit: defaultFreeTxRelayLimit,
|
||||||
BlockMinSize: defaultBlockMinSize,
|
BlockMinSize: defaultBlockMinSize,
|
||||||
BlockMaxSize: defaultBlockMaxSize,
|
BlockMaxSize: defaultBlockMaxSize,
|
||||||
|
@ -594,6 +597,16 @@ func loadConfig() (*config, []string, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate the the minrelaytxfee.
|
||||||
|
cfg.minRelayTxFee, err = btcutil.NewAmount(cfg.MinRelayTxFee)
|
||||||
|
if err != nil {
|
||||||
|
str := "%s: invalid minrelaytxfee: %v"
|
||||||
|
err := fmt.Errorf(str, funcName, err)
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
fmt.Fprintln(os.Stderr, usageMessage)
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// Limit the max block size to a sane value.
|
// Limit the max block size to a sane value.
|
||||||
if cfg.BlockMaxSize < blockMaxSizeMin || cfg.BlockMaxSize >
|
if cfg.BlockMaxSize < blockMaxSizeMin || cfg.BlockMaxSize >
|
||||||
blockMaxSizeMax {
|
blockMaxSizeMax {
|
||||||
|
|
2
doc.go
2
doc.go
|
@ -81,6 +81,8 @@ Application Options:
|
||||||
the log level for individual subsystems -- Use show
|
the log level for individual subsystems -- Use show
|
||||||
to list available subsystems (info)
|
to list available subsystems (info)
|
||||||
--upnp Use UPnP to map our listening port outside of NAT
|
--upnp Use UPnP to map our listening port outside of NAT
|
||||||
|
--minrelaytxfee= The minimum transaction fee in BTC/kB to be
|
||||||
|
considered a non-zero fee.
|
||||||
--limitfreerelay= Limit relay of transactions with no transaction fee
|
--limitfreerelay= Limit relay of transactions with no transaction fee
|
||||||
to the given amount in thousands of bytes per
|
to the given amount in thousands of bytes per
|
||||||
minute (15)
|
minute (15)
|
||||||
|
|
18
mempool.go
18
mempool.go
|
@ -68,12 +68,12 @@ const (
|
||||||
// considered standard.
|
// considered standard.
|
||||||
maxStandardMultiSigKeys = 3
|
maxStandardMultiSigKeys = 3
|
||||||
|
|
||||||
// minTxRelayFee is the minimum fee in satoshi that is required for a
|
// defaultMinRelayTxFee is the minimum fee in satoshi that is required
|
||||||
// transaction to be treated as free for relay and mining purposes. It
|
// for a transaction to be treated as free for relay and mining
|
||||||
// is also used to help determine if a transaction is considered dust
|
// purposes. It is also used to help determine if a transaction is
|
||||||
// and as a base for calculating minimum required fees for larger
|
// considered dust and as a base for calculating minimum required fees
|
||||||
// transactions. This value is in Satoshi/1000 bytes.
|
// for larger transactions. This value is in Satoshi/1000 bytes.
|
||||||
minTxRelayFee = 1000
|
defaultMinRelayTxFee = btcutil.Amount(1000)
|
||||||
)
|
)
|
||||||
|
|
||||||
// TxDesc is a descriptor containing a transaction in the mempool and the
|
// TxDesc is a descriptor containing a transaction in the mempool and the
|
||||||
|
@ -168,7 +168,7 @@ func isDust(txOut *wire.TxOut) bool {
|
||||||
//
|
//
|
||||||
// The following is equivalent to (value/totalSize) * (1/3) * 1000
|
// The following is equivalent to (value/totalSize) * (1/3) * 1000
|
||||||
// without needing to do floating point math.
|
// without needing to do floating point math.
|
||||||
return txOut.Value*1000/(3*int64(totalSize)) < minTxRelayFee
|
return txOut.Value*1000/(3*int64(totalSize)) < int64(cfg.minRelayTxFee)
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkPkScriptStandard performs a series of checks on a transaction ouput
|
// checkPkScriptStandard performs a series of checks on a transaction ouput
|
||||||
|
@ -377,11 +377,11 @@ func checkInputsStandard(tx *btcutil.Tx, txStore blockchain.TxStore) error {
|
||||||
func calcMinRequiredTxRelayFee(serializedSize int64) int64 {
|
func calcMinRequiredTxRelayFee(serializedSize int64) int64 {
|
||||||
// Calculate the minimum fee for a transaction to be allowed into the
|
// Calculate the minimum fee for a transaction to be allowed into the
|
||||||
// mempool and relayed by scaling the base fee (which is the minimum
|
// mempool and relayed by scaling the base fee (which is the minimum
|
||||||
// free transaction relay fee). minTxRelayFee is in Satoshi/KB, so
|
// free transaction relay fee). cfg.minRelayTxFee is in Satoshi/KB, so
|
||||||
// divide the transaction size by 1000 to convert to kilobytes. Also,
|
// divide the transaction size by 1000 to convert to kilobytes. Also,
|
||||||
// integer division is used so fees only increase on full kilobyte
|
// integer division is used so fees only increase on full kilobyte
|
||||||
// boundaries.
|
// boundaries.
|
||||||
minFee := (1 + serializedSize/1000) * minTxRelayFee
|
minFee := (1 + serializedSize/1000) * int64(cfg.minRelayTxFee)
|
||||||
|
|
||||||
// Set the minimum fee to the maximum possible value if the calculated
|
// Set the minimum fee to the maximum possible value if the calculated
|
||||||
// fee is not in the valid range for monetary amounts.
|
// fee is not in the valid range for monetary amounts.
|
||||||
|
|
|
@ -604,13 +604,14 @@ mempoolLoop:
|
||||||
|
|
||||||
// Skip free transactions once the block is larger than the
|
// Skip free transactions once the block is larger than the
|
||||||
// minimum block size.
|
// minimum block size.
|
||||||
if sortedByFee && prioItem.feePerKB < minTxRelayFee &&
|
if sortedByFee &&
|
||||||
|
prioItem.feePerKB < float64(cfg.minRelayTxFee) &&
|
||||||
blockPlusTxSize >= cfg.BlockMinSize {
|
blockPlusTxSize >= cfg.BlockMinSize {
|
||||||
|
|
||||||
minrLog.Tracef("Skipping tx %s with feePerKB %.2f "+
|
minrLog.Tracef("Skipping tx %s with feePerKB %.2f "+
|
||||||
"< minTxRelayFee %d and block size %d >= "+
|
"< minTxRelayFee %d and block size %d >= "+
|
||||||
"minBlockSize %d", tx.Sha(), prioItem.feePerKB,
|
"minBlockSize %d", tx.Sha(), prioItem.feePerKB,
|
||||||
minTxRelayFee, blockPlusTxSize,
|
cfg.minRelayTxFee, blockPlusTxSize,
|
||||||
cfg.BlockMinSize)
|
cfg.BlockMinSize)
|
||||||
logSkippedDeps(tx, deps)
|
logSkippedDeps(tx, deps)
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -2103,7 +2103,7 @@ func handleGetInfo(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (in
|
||||||
Proxy: cfg.Proxy,
|
Proxy: cfg.Proxy,
|
||||||
Difficulty: getDifficultyRatio(blkHeader.Bits),
|
Difficulty: getDifficultyRatio(blkHeader.Bits),
|
||||||
TestNet: cfg.TestNet3,
|
TestNet: cfg.TestNet3,
|
||||||
RelayFee: float64(minTxRelayFee) / btcutil.SatoshiPerBitcoin,
|
RelayFee: cfg.minRelayTxFee.ToBTC(),
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret, nil
|
return ret, nil
|
||||||
|
|
|
@ -214,6 +214,9 @@
|
||||||
; Mempool Settings - The following options
|
; Mempool Settings - The following options
|
||||||
; ------------------------------------------------------------------------------
|
; ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
; Set the minimum transaction fee to be considered a non-zero fee,
|
||||||
|
; minrelaytxfee=0.00001
|
||||||
|
|
||||||
; Rate-limit free transactions to the value 15 * 1000 bytes per
|
; Rate-limit free transactions to the value 15 * 1000 bytes per
|
||||||
; minute.
|
; minute.
|
||||||
; limitfreerelay=15
|
; limitfreerelay=15
|
||||||
|
|
Loading…
Reference in a new issue