Skip to content

Commit 4840f6d

Browse files
committed
Prevent witness addresses from being constructed before fork
1 parent 14d4d1d commit 4840f6d

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

contrib/devtools/check-doc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
REGEX_ARG = re.compile(r'(?:map(?:Multi)?Args(?:\.count\(|\[)|Get(?:Bool)?Arg\()\"(\-[^\"]+?)\"')
2222
REGEX_DOC = re.compile(r'HelpMessageOpt\(\"(\-[^\"=]+?)(?:=|\")')
2323
# list unsupported, deprecated and duplicate args as they need no documentation
24-
SET_DOC_OPTIONAL = set(['-rpcssl', '-benchmark', '-h', '-help', '-socks', '-tor', '-debugnet', '-whitelistalwaysrelay', '-prematurewitness', '-promiscuousmempoolflags'])
24+
SET_DOC_OPTIONAL = set(['-rpcssl', '-benchmark', '-h', '-help', '-socks', '-tor', '-debugnet', '-whitelistalwaysrelay', '-prematurewitness', '-walletprematurewitness', '-promiscuousmempoolflags'])
2525

2626
def main():
2727
used = check_output(CMD_GREP_ARGS, shell=True)

qa/rpc-tests/segwit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ def setup_chain(self):
7676

7777
def setup_network(self):
7878
self.nodes = []
79-
self.nodes.append(start_node(0, self.options.tmpdir, ["-logtimemicros", "-debug"]))
80-
self.nodes.append(start_node(1, self.options.tmpdir, ["-logtimemicros", "-debug", "-blockversion=4", "-promiscuousmempoolflags=517", "-prematurewitness"]))
81-
self.nodes.append(start_node(2, self.options.tmpdir, ["-logtimemicros", "-debug", "-blockversion=536870915", "-promiscuousmempoolflags=517", "-prematurewitness"]))
79+
self.nodes.append(start_node(0, self.options.tmpdir, ["-logtimemicros", "-debug", "-walletprematurewitness"]))
80+
self.nodes.append(start_node(1, self.options.tmpdir, ["-logtimemicros", "-debug", "-blockversion=4", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness"]))
81+
self.nodes.append(start_node(2, self.options.tmpdir, ["-logtimemicros", "-debug", "-blockversion=536870915", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness"]))
8282
connect_nodes(self.nodes[1], 0)
8383
connect_nodes(self.nodes[2], 1)
8484
connect_nodes(self.nodes[0], 2)

src/wallet/rpcwallet.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,13 @@ UniValue addwitnessaddress(const UniValue& params, bool fHelp)
11541154
throw runtime_error(msg);
11551155
}
11561156

1157+
{
1158+
LOCK(cs_main);
1159+
if (!IsWitnessEnabled(chainActive.Tip(), Params().GetConsensus()) && !GetBoolArg("-walletprematurewitness", false)) {
1160+
throw JSONRPCError(RPC_WALLET_ERROR, "Segregated witness not enabled on network");
1161+
}
1162+
}
1163+
11571164
CBitcoinAddress address(params[0].get_str());
11581165
if (!address.IsValid())
11591166
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");

0 commit comments

Comments
 (0)