From 845d54da559055e5fe169001aea72e032f7d5380 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Mon, 27 Jan 2014 16:58:49 -0500 Subject: [PATCH] Add allowfree configuration option. It may be desirable to never allow free transactions, even if the calculated priority is high enough that a fee would not be required, so this change adds a global configuration option to remove this check and always attach a fee. --- config.go | 3 +++ createtx.go | 5 ++++- sample-btcwallet.conf | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index 2ddb994..cf7b1f7 100644 --- a/config.go +++ b/config.go @@ -33,6 +33,7 @@ const ( defaultBtcNet = btcwire.TestNet3 defaultLogLevel = "info" defaultKeypoolSize = 100 + defaultAllowFree = true ) var ( @@ -60,6 +61,7 @@ type config struct { RPCKey string `long:"rpckey" description:"File containing the certificate key"` MainNet bool `long:"mainnet" description:"Use the main Bitcoin network (default testnet3)"` KeypoolSize uint `short:"k" long:"keypoolsize" description:"Maximum number of addresses in keypool"` + AllowFree bool `long:"allowfree" description:"Whether transactions with high enough priority may be made without any fee"` Proxy string `long:"proxy" description:"Connect via SOCKS5 proxy (eg. 127.0.0.1:9050)"` ProxyUser string `long:"proxyuser" description:"Username for proxy server"` ProxyPass string `long:"proxypass" default-mask:"-" description:"Password for proxy server"` @@ -145,6 +147,7 @@ func loadConfig() (*config, []string, error) { RPCKey: defaultRPCKeyFile, RPCCert: defaultRPCCertFile, KeypoolSize: defaultKeypoolSize, + AllowFree: defaultAllowFree, } // A config file in the current directory takes precedence. diff --git a/createtx.go b/createtx.go index c013a9b..24f4a0f 100644 --- a/createtx.go +++ b/createtx.go @@ -304,7 +304,10 @@ func (a *Account) txToPairs(pairs map[string]int64, minconf int) (*CreatedTx, er msgtx.TxIn[i].SignatureScript = sigscript } - noFeeAllowed := allowFree(bs.Height, inputs, msgtx.SerializeSize()) + noFeeAllowed := false + if cfg.AllowFree { + noFeeAllowed = allowFree(bs.Height, inputs, msgtx.SerializeSize()) + } if minFee := minimumFee(msgtx, noFeeAllowed); fee < minFee { fee = minFee } else { diff --git a/sample-btcwallet.conf b/sample-btcwallet.conf index ea935b9..02d0ed2 100644 --- a/sample-btcwallet.conf +++ b/sample-btcwallet.conf @@ -15,6 +15,9 @@ ; Maximum number of addresses to generate for the keypool ; keypoolsize=100 +; Whether transactions may be created without any attached fee, if the calculated +; transaction priority is high enough +; allowfree = true ; ------------------------------------------------------------------------------