Skip to content

Commit

Permalink
Bufferify the return from cashaddr.decode
Browse files Browse the repository at this point in the history
  • Loading branch information
Arachnid committed Oct 22, 2019
1 parent a3eff58 commit e74726d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ function encodeCashAddr(data: Buffer): string {
function decodeCashAddr(data: string): Buffer {
const { prefix, type, hash } = cashaddr.decode(data);
if (type === 'P2PKH') {
return Buffer.concat([Buffer.from([0x76, 0xa9, 0x14]), hash, Buffer.from([0x88, 0xac])]);
return Buffer.concat([Buffer.from([0x76, 0xa9, 0x14]), Buffer.from(hash), Buffer.from([0x88, 0xac])]);
} else if (type === 'P2SH') {
return Buffer.concat([Buffer.from([0xa9, 0x14]), hash, Buffer.from([0x87])]);
return Buffer.concat([Buffer.from([0xa9, 0x14]), Buffer.from(hash), Buffer.from([0x87])]);
}
throw Error('Unrecognised address format');
}
Expand Down

0 comments on commit e74726d

Please sign in to comment.