aboutsummaryrefslogtreecommitdiffstats
path: root/rules
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-06-19 21:27:08 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-06-19 21:27:08 +0100
commit29ad693e4190d3ad7e6a6025df28d39955c2091c (patch)
tree324a2a1ca0e75f01cc0f171ec8d5391f0c17621a /rules
parentf99d7e2a44e0ebe6372a7322329c2813119d8215 (diff)
downloadrspamd-29ad693e4190d3ad7e6a6025df28d39955c2091c.tar.gz
rspamd-29ad693e4190d3ad7e6a6025df28d39955c2091c.zip
[Feature] Add preliminary support of BCH addresses
Diffstat (limited to 'rules')
-rw-r--r--rules/bitcoin.lua19
1 files changed, 18 insertions, 1 deletions
diff --git a/rules/bitcoin.lua b/rules/bitcoin.lua
index d9c94fdf1..b7f9f1dbc 100644
--- a/rules/bitcoin.lua
+++ b/rules/bitcoin.lua
@@ -120,7 +120,7 @@ end
local function is_segwit_bech32_address(word)
local prefix = word:sub(1, 3)
- if prefix == 'bc1' or prefix.sub(1, 1) == '1' or prefix.sub(1, 1) == '3' then
+ if prefix == 'bc1' or prefix:sub(1, 1) == '1' or prefix:sub(1, 1) == '3' then
-- Strip beach32 prefix in bitcoin
word = word:lower()
local last_one_pos = word:find('1[^1]*$')
@@ -134,6 +134,23 @@ local function is_segwit_bech32_address(word)
if decoded then
return verify_beach32_cksum(hrp, decoded)
end
+ else
+ -- BCH address
+ -- 1 byte address type (who cares)
+ -- XXX bytes address hash (who cares)
+ -- 40 bit checksum
+ local rspamd_util = require 'rspamd_util'
+ local decoded = rspamd_util.decode_base32(word:lower(), 'bleach')
+
+ if decoded then
+ local bytes = decoded:bytes()
+
+ if bytes[1] == 0 then
+ -- TODO: Add checksum validation some day
+
+ return true
+ end
+ end
end
end