Skip to content

Commit

Permalink
add network checks
Browse files Browse the repository at this point in the history
  • Loading branch information
lukachi committed Aug 2, 2024
1 parent d7ed189 commit 22d513a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/connector/src/helpers/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,16 @@ export function fromBase58Check(qtumAddress: string) {
const buffer = Buffer.from(payload);
return `0x${buffer.toString('hex').slice(2)}`;
}

// eslint-disable-next-line jsdoc/require-jsdoc
export function isAddressMatchNetwork(qtumAddress: string, chainId: number) {
const payload = bs58check.decode(qtumAddress);

const version = {
8889: 120,
81: 58,
}[chainId];

// Check if the version matches
return payload[0] === version;
}

0 comments on commit 22d513a

Please sign in to comment.