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

Commit aa54a3b

Browse files
Merge pull request #617 from lightninglabs/support-bech32
Support bech32 addresses which is max 90 chars long
2 parents 0ce449d + 70a3219 commit aa54a3b

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ export const isLnUri = str => {
228228
* @return {boolean} If the uri is valid
229229
*/
230230
export const isAddress = str => {
231-
return /^[a-km-zA-HJ-NP-Z0-9]{26,35}$/.test(str);
231+
return /^[a-km-zA-HJ-NP-Z0-9]{26,90}$/.test(str);
232232
};
233233

234234
/**

test/unit/helper.spec.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,12 +721,18 @@ describe('Helpers Unit Tests', () => {
721721
});
722722

723723
describe('isAddress()', () => {
724-
it('should accept bitcoin uri', () => {
724+
it('should accept bitcoin address', () => {
725725
const address = 'rfu4i1Mo2NF7TQsN9bMVLFSojSzcyQCEH5';
726726
expect(helpers.isAddress(address), 'to be', true);
727727
});
728728

729-
it('should reject invalid bitcoin uri', () => {
729+
it('should accept bech32 address', () => {
730+
const address =
731+
'bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3';
732+
expect(helpers.isAddress(address), 'to be', true);
733+
});
734+
735+
it('should reject invalid bitcoin address', () => {
730736
const address = '/INVALID/rfu4i1Mo2NF7TQsN9bMVLFSoj';
731737
expect(helpers.isAddress(address), 'to be', false);
732738
});

0 commit comments

Comments
 (0)