diff --git a/config.go b/config.go index 5e7cb27a..fe8bab2c 100644 --- a/config.go +++ b/config.go @@ -141,6 +141,8 @@ type config struct { DropTxIndex bool `long:"droptxindex" description:"Deletes the hash-based transaction index from the database on start up and then exits."` AddrIndex bool `long:"addrindex" description:"Maintain a full address-based transaction index which makes the searchrawtransactions RPC available"` DropAddrIndex bool `long:"dropaddrindex" description:"Deletes the address-based transaction index from the database on start up and then exits."` + RelayNonStd bool `long:"relaynonstd" description:"Relay non-standard transactions regardless of the default settings for the active network."` + RejectNonStd bool `long:"rejectnonstd" description:"Reject non-standard transactions regardless of the default settings for the active network."` onionlookup func(string) ([]net.IP, error) lookup func(string) ([]net.IP, error) oniondial func(string, string) (net.Conn, error) @@ -479,6 +481,26 @@ func loadConfig() (*config, []string, error) { return nil, nil, err } + // Set the default policy for relaying non-standard transactions + // according to the default of the active network. The set + // configuration value takes precedence over the default value for the + // selected network. + relayNonStd := activeNetParams.RelayNonStdTxs + switch { + case cfg.RelayNonStd && cfg.RejectNonStd: + str := "%s: rejectnonstd and relaynonstd cannot be used " + + "together -- choose only one" + err := fmt.Errorf(str, funcName) + fmt.Fprintln(os.Stderr, err) + fmt.Fprintln(os.Stderr, usageMessage) + return nil, nil, err + case cfg.RejectNonStd: + relayNonStd = false + case cfg.RelayNonStd: + relayNonStd = true + } + cfg.RelayNonStd = relayNonStd + // Append the network type to the data directory so it is "namespaced" // per network. In addition to the block database, there are other // pieces of data that are saved to disk such as address manager state. diff --git a/doc.go b/doc.go index d01ffe7a..2ef4cba8 100644 --- a/doc.go +++ b/doc.go @@ -108,6 +108,10 @@ Application Options: --sigcachemaxsize= The maximum number of entries in the signature verification cache. --blocksonly Do not accept transactions from remote peers. + --relaynonstd Relay non-standard transactions regardless of the + default settings for the active network. + --rejectnonstd Reject non-standard transactions regardless of the + default settings for the active network. Help Options: -h, --help Show this help message diff --git a/sample-btcd.conf b/sample-btcd.conf index da4e4b8c..d12be44d 100644 --- a/sample-btcd.conf +++ b/sample-btcd.conf @@ -238,6 +238,12 @@ ; Do not accept transactions from remote peers. ; blocksonly=1 +; Relay non-standard transactions regardless of default network settings. +; relaynonstd=1 + +; Reject non-standard transactions regardless of default network settings. +; rejectnonstd=1 + ; ------------------------------------------------------------------------------ ; Optional Transaction Indexes diff --git a/server.go b/server.go index f78d2a33..545d0b24 100644 --- a/server.go +++ b/server.go @@ -2519,7 +2519,7 @@ func newServer(listenAddrs []string, db database.DB, chainParams *chaincfg.Param txC := mempool.Config{ Policy: mempool.Policy{ DisableRelayPriority: cfg.NoRelayPriority, - RelayNonStd: chainParams.RelayNonStdTxs, + RelayNonStd: cfg.RelayNonStd, FreeTxRelayLimit: cfg.FreeTxRelayLimit, MaxOrphanTxs: cfg.MaxOrphanTxs, MaxOrphanTxSize: defaultMaxOrphanTxSize,