Skip to content

fix: reject mixed-case bech32 addresses#4

Open
tolga-tom-nook wants to merge 1 commit into
BitgesellOfficial:betafrom
tolga-tom-nook:fix/reject-mixed-case-bech32
Open

fix: reject mixed-case bech32 addresses#4
tolga-tom-nook wants to merge 1 commit into
BitgesellOfficial:betafrom
tolga-tom-nook:fix/reject-mixed-case-bech32

Conversation

@tolga-tom-nook
Copy link
Copy Markdown

Summary

  • Reject mixed-case Bech32/SegWit addresses in isAddressValid() before checksum normalization.
  • Keep all-lowercase and all-uppercase Bech32 addresses valid, but reject mixed-case strings per BIP173.
  • Add regression coverage and update the distributed dist/functions/address.js entry point used by the package main.

RED proof

With the new regression added before the fix, npm test failed in Address functions: isAddressValid:

AssertionError: expected true to equal false
-true
+false

The failing address was a mixed-case BGL Bech32 address: Bgl1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7K0FY5A3.

GREEN proof

npm test

Result: 68 passing.

node - <<'NODE'
const assert = require('assert');
const jsbgl = require('./');
(async () => {
  await jsbgl.asyncInit(global);
  assert.strictEqual(isAddressValid('bgl1qw508d6qejxtdg4y5r3zarvary0c5xw7k0fy5a3'), true);
  assert.strictEqual(isAddressValid('BGL1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7K0FY5A3'), true);
  assert.strictEqual(isAddressValid('Bgl1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7K0FY5A3'), false);
  console.log('dist/package bech32 mixed-case regression ok');
})();
NODE

Result: dist/package bech32 mixed-case regression ok.

git diff --check

Result: clean.

Bounty context

This is submitted as a Bitgesell improvement/bugfix PR for the public bounty/improvement program:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant