Merge pull request #29 from jgarzik/sin
Update SIN magic number. Support SINs in wallets.
This commit is contained in:
commit
b0fd358d45
2
SIN.js
2
SIN.js
|
@ -11,7 +11,7 @@ function ClassSpec(b) {
|
||||||
};
|
};
|
||||||
this.data = new Buffer(1 + 1 + payload.length);
|
this.data = new Buffer(1 + 1 + payload.length);
|
||||||
this.__proto__ = this.encodings['binary'];
|
this.__proto__ = this.encodings['binary'];
|
||||||
this.prefix(0x18); // SIN magic number, in numberspace
|
this.prefix(0x0F); // SIN magic number, in numberspace
|
||||||
this.type(type);
|
this.type(type);
|
||||||
this.payload(payload);
|
this.payload(payload);
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,9 +19,13 @@ function ClassSpec(b) {
|
||||||
this.created = timeUtil.curtime();
|
this.created = timeUtil.curtime();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SINKey.prototype.pubkeyHash = function() {
|
||||||
|
return coinUtil.sha256ripe160(this.privKey.public);
|
||||||
|
};
|
||||||
|
|
||||||
SINKey.prototype.storeObj = function() {
|
SINKey.prototype.storeObj = function() {
|
||||||
var pubKey = this.privKey.public.toString('hex');
|
var pubKey = this.privKey.public.toString('hex');
|
||||||
var pubKeyHash = coinUtil.sha256ripe160(this.privKey.public);
|
var pubKeyHash = this.pubkeyHash();
|
||||||
var sin = new SIN(SIN.SIN_EPHEM, pubKeyHash);
|
var sin = new SIN(SIN.SIN_EPHEM, pubKeyHash);
|
||||||
var obj = {
|
var obj = {
|
||||||
created: this.created,
|
created: this.created,
|
||||||
|
|
|
@ -17,6 +17,7 @@ function ClassSpec(b) {
|
||||||
best_hash: null,
|
best_hash: null,
|
||||||
best_height: -1,
|
best_height: -1,
|
||||||
keys: [],
|
keys: [],
|
||||||
|
sin: {},
|
||||||
scripts: {},
|
scripts: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -76,6 +77,11 @@ function ClassSpec(b) {
|
||||||
this.dirty = true;
|
this.dirty = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Wallet.prototype.addSIN = function(sinObj) {
|
||||||
|
this.datastore.sin[sinObj.sin] = sinObj;
|
||||||
|
this.dirty = true;
|
||||||
|
};
|
||||||
|
|
||||||
Wallet.prototype.findKeyHash = function(pubKeyHash) {
|
Wallet.prototype.findKeyHash = function(pubKeyHash) {
|
||||||
var pkhStr = pubKeyHash.toString();
|
var pkhStr = pubKeyHash.toString();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue