Skip to content
This repository has been archived by the owner on Apr 5, 2020. It is now read-only.

Commit

Permalink
Add regtest address support
Browse files Browse the repository at this point in the history
  • Loading branch information
jmprcx committed Apr 20, 2018
1 parent f0f7c8b commit ad9ad3e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ Address._transformStringCashAddr = function(data, network, type) {
$.checkArgument(
!network ||
(network === 'livenet' && decoded.prefix === 'bitcoincash') ||
(network === 'testnet' && decoded.prefix === 'bchtest'),
(network === 'testnet' && decoded.prefix === 'bchtest') ||
(network === 'testnet' && decoded.prefix === 'bchreg'),
'Invalid network.'
);
$.checkArgument(
Expand Down Expand Up @@ -622,7 +623,10 @@ Address.prototype._toStringBitpay = function() {
* @returns {string} Bitcoin address
*/
Address.prototype._toStringCashAddr = function() {
var prefix = this.network.toString() === 'livenet' ? 'bitcoincash' : 'bchtest';
var prefix = this.network.toString();
if (prefix === 'livenet') prefix = 'bitcoincash';
else if (prefix === 'testnet' && this.network.regtestEnabled !== true) prefix = 'bchtest';
else if (prefix === 'testnet' && this.network.regtestEnabled === true) prefix = 'bchreg';
var type = this.type === Address.PayToPublicKeyHash ? 'P2PKH' : 'P2SH';
return cashaddr.encode(prefix, type, this.hashBuffer);
}
Expand Down

0 comments on commit ad9ad3e

Please sign in to comment.