Browse Source

add ability to set the version

patch-2
Stephen Pair 12 years ago
parent
commit
16ce63ca80
  1. 11
      BitcoinAddress.js

11
BitcoinAddress.js

@ -9,13 +9,20 @@ function ClassSpec(b) {
};
// return the bitcoin address version (the first byte of the address)
BitcoinAddress.prototype.version = function() {
BitcoinAddress.prototype.version = function(num) {
if(num || (num === 0)) {
var oldEncoding = this.encoding();
this.encoding('binary');
this.data.writeUInt8(num, 0);
this.encoding(oldEncoding);
return num;
}
return this.as('binary').readUInt8(0);
};
// get or set the encoding used (transforms data)
BitcoinAddress.prototype.encoding = function(encoding) {
if(encoding) {
if(encoding && (encoding != this._encoding)) {
this.data = this.as(encoding);
this.__proto__ = encodings[encoding];
}

Loading…
Cancel
Save