From 52e5f3fdd489aade383574961f571ce350a6ff46 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Sat, 17 Aug 2013 01:11:23 -0400 Subject: [PATCH] Support SIN keys in wallets. --- SINKey.js | 6 +++++- Wallet.js | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/SINKey.js b/SINKey.js index 54bc54a97..b80a8a1fc 100644 --- a/SINKey.js +++ b/SINKey.js @@ -19,9 +19,13 @@ function ClassSpec(b) { this.created = timeUtil.curtime(); }; + SINKey.prototype.pubkeyHash = function() { + return coinUtil.sha256ripe160(this.privKey.public); + }; + SINKey.prototype.storeObj = function() { 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 obj = { created: this.created, diff --git a/Wallet.js b/Wallet.js index ac5a290d0..9ca8b7972 100644 --- a/Wallet.js +++ b/Wallet.js @@ -17,6 +17,7 @@ function ClassSpec(b) { best_hash: null, best_height: -1, keys: [], + sin: {}, scripts: {}, }; @@ -76,6 +77,11 @@ function ClassSpec(b) { this.dirty = true; }; + Wallet.prototype.addSIN = function(sinObj) { + this.datastore.sin[sinObj.sin] = sinObj; + this.dirty = true; + }; + Wallet.prototype.findKeyHash = function(pubKeyHash) { var pkhStr = pubKeyHash.toString();