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

Commit

Permalink
Merge pull request #866 from lightninglabs/support-p2wkh-address
Browse files Browse the repository at this point in the history
Fix bitcoin address validation to accept p2wkh
  • Loading branch information
tanx authored Jan 8, 2019
2 parents c04e381 + a3fa6fc commit cb8a5f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

/**
Expand Down
5 changes: 5 additions & 0 deletions test/unit/helper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cb8a5f7

Please sign in to comment.