From bf31f7651b01fb2dee39a5ad3570ff7135c683fd Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Thu, 15 Feb 2018 11:44:45 +1100 Subject: [PATCH] Whitelist script addresses on testnet when wallet support is missing, and blacklist bech32 addresses. --- src/bitcoin.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/bitcoin.c b/src/bitcoin.c index 646ad472..cc24c219 100644 --- a/src/bitcoin.c +++ b/src/bitcoin.c @@ -65,11 +65,16 @@ bool validate_address(connsock_t *cs, const char *address, bool *script, bool *s ret = true; tmp_val = json_object_get(res_val, "isscript"); if (unlikely(!tmp_val)) { - /* All recent bitcoinds should support this, if not, look for - * a 3x address to at least support it on mainnet */ + /* All recent bitcoinds with wallet support built in should + * support this, if not, look for addresses the braindead way + * to tell if it's a script address. */ LOGDEBUG("No isscript support from bitcoind"); - if (address[0] == '3') + if (address[0] == '3' || address[0] == '2') *script = true; + /* Now look to see this isn't a bech32: We can't support + * bech32 without knowing if it's a pubkey or a script */ + else if (address[0] != '1' && address[0] != 'm') + ret = false; goto out; } *script = json_is_true(tmp_val);