Correcting addresses for multibyte versions

Fixes https://github.com/str4d/insight-ui-zcash/issues/1
This commit is contained in:
Karel Bílek 2016-11-02 19:03:23 +01:00 committed by GitHub
parent b84f7ac683
commit aeaa33f237
1 changed files with 2 additions and 1 deletions

View File

@ -460,7 +460,8 @@ Address.prototype.isPayToScriptHash = function() {
* @returns {Buffer} Bitcoin address buffer
*/
Address.prototype.toBuffer = function() {
var version = new Buffer([this.network[this.type]]);
var version = new Buffer(2);
version.writeUInt16BE(this.network[this.type], 0);
var buf = Buffer.concat([version, this.hashBuffer]);
return buf;
};