Commit 85979b38 authored by Zhenzhen Zhan's avatar Zhenzhen Zhan
Browse files

Implement an address conversion tool

parent 60a844e5
......@@ -385,6 +385,19 @@ Address.fromString = function(str, network, type) {
return new Address(info.hashBuffer, info.network, info.type);
};
Address.fromOldFormatString = function(str) {
var buffer = Base58Check.decode(str);
var pubkeyhashNetwork = Networks.get(buffer[0], 'pubkeyhash');
var scripthashNetwork = Networks.get(buffer[0], 'scripthash');
if (pubkeyhashNetwork) {
buffer = Buffer.concat([pubkeyhashNetwork.pubkeyAddressPrefix, buffer.slice(1)]);
}
else {
buffer = Buffer.concat([scripthashNetwork.scriptAddressPrefix, buffer.slice(1)]);
}
return Address.fromBuffer(buffer);
};
/**
* Instantiate an address from an Object
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment