make binary conversion copy the buffer to avoid overwrite issues
This commit is contained in:
parent
a7ba9a44a5
commit
ad8ccc4930
|
@ -90,6 +90,11 @@ function ClassSpec(b) {
|
||||||
var encodings = {
|
var encodings = {
|
||||||
'binary': {
|
'binary': {
|
||||||
converters: {
|
converters: {
|
||||||
|
'binary': function() {
|
||||||
|
var answer = new Buffer(this.data.length);
|
||||||
|
this.data.copy(answer);
|
||||||
|
return answer;
|
||||||
|
},
|
||||||
'base58': function() {
|
'base58': function() {
|
||||||
return base58.encode(this.data);
|
return base58.encode(this.data);
|
||||||
},
|
},
|
||||||
|
@ -127,6 +132,7 @@ function ClassSpec(b) {
|
||||||
};
|
};
|
||||||
|
|
||||||
for(var k in encodings) {
|
for(var k in encodings) {
|
||||||
|
if(!encodings[k].converters[k])
|
||||||
encodings[k].converters[k] = function() {return this.data;};
|
encodings[k].converters[k] = function() {return this.data;};
|
||||||
encodings[k]._encoding = k;
|
encodings[k]._encoding = k;
|
||||||
encodings[k].__proto__ = BitcoinAddress.prototype;
|
encodings[k].__proto__ = BitcoinAddress.prototype;
|
||||||
|
|
Loading…
Reference in New Issue