From a3fa6fc19b3103f1a1b871aa5d71066ad8e4cf2d Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Tue, 8 Jan 2019 13:15:12 +0700 Subject: [PATCH] Fix bitcoin address validation to accept p2wkh Closes #864 --- src/helper.js | 2 +- test/unit/helper.spec.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/helper.js b/src/helper.js index 8863ca7e3..e78ac4b16 100644 --- a/src/helper.js +++ b/src/helper.js @@ -213,7 +213,7 @@ export const isLnUri = str => { * @return {boolean} If the uri is valid */ export const isAddress = str => { - return /^[a-km-zA-HJ-NP-Z0-9]{26,90}$/.test(str); + return /^[a-zA-Z0-9]{26,90}$/.test(str); }; /** diff --git a/test/unit/helper.spec.js b/test/unit/helper.spec.js index efd98dfe1..768880d00 100644 --- a/test/unit/helper.spec.js +++ b/test/unit/helper.spec.js @@ -682,6 +682,11 @@ describe('Helpers Unit Tests', () => { expect(helpers.isAddress(address), 'to be', true); }); + it('should accept p2wkh address', () => { + const address = 'tb1q94yln7u75nt580a6s0gvs9wqvmfl4zgcxj78sw'; + expect(helpers.isAddress(address), 'to be', true); + }); + it('should reject invalid bitcoin address', () => { const address = '/INVALID/rfu4i1Mo2NF7TQsN9bMVLFSoj'; expect(helpers.isAddress(address), 'to be', false);