Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit cb8a5f7

Browse files
authored
Merge pull request #866 from lightninglabs/support-p2wkh-address
Fix bitcoin address validation to accept p2wkh
2 parents c04e381 + a3fa6fc commit cb8a5f7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export const isLnUri = str => {
213213
* @return {boolean} If the uri is valid
214214
*/
215215
export const isAddress = str => {
216-
return /^[a-km-zA-HJ-NP-Z0-9]{26,90}$/.test(str);
216+
return /^[a-zA-Z0-9]{26,90}$/.test(str);
217217
};
218218

219219
/**

test/unit/helper.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,11 @@ describe('Helpers Unit Tests', () => {
682682
expect(helpers.isAddress(address), 'to be', true);
683683
});
684684

685+
it('should accept p2wkh address', () => {
686+
const address = 'tb1q94yln7u75nt580a6s0gvs9wqvmfl4zgcxj78sw';
687+
expect(helpers.isAddress(address), 'to be', true);
688+
});
689+
685690
it('should reject invalid bitcoin address', () => {
686691
const address = '/INVALID/rfu4i1Mo2NF7TQsN9bMVLFSoj';
687692
expect(helpers.isAddress(address), 'to be', false);

0 commit comments

Comments
 (0)