From 36fd6b2d9c0a6592ffc85a6a4116e8d4c7d8aeb2 Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Tue, 2 Sep 2014 12:53:41 -0700 Subject: [PATCH] take address stuff out of stealthkey ...that is what StealthAddress is now for --- lib/expmt/stealthkey.js | 36 ------------------------------------ test/stealthkey.js | 40 ---------------------------------------- 2 files changed, 76 deletions(-) diff --git a/lib/expmt/stealthkey.js b/lib/expmt/stealthkey.js index f249d48..2382cd0 100644 --- a/lib/expmt/stealthkey.js +++ b/lib/expmt/stealthkey.js @@ -28,28 +28,6 @@ Stealthkey.prototype.set = function(obj) { return this; }; -Stealthkey.prototype.fromAddressBuffer = function(buf) { - if (!Buffer.isBuffer(buf) || buf.length !== 66) - throw new Error('stealthkey: A stealthkey address must have length 66'); - - var pPubBuf = buf.slice(0, 33); - var sPubBuf = buf.slice(33, 66); - - var payloadPubkey = Pubkey().fromDER(pPubBuf); - this.payloadKeypair = Keypair({pubkey: payloadPubkey}); - var scanPubkey = Pubkey().fromDER(sPubBuf); - this.scanKeypair = Keypair({pubkey: scanPubkey}); - - return this; -}; - -Stealthkey.prototype.fromAddressString = function(str) { - var buf = base58check.decode(str); - this.fromAddressBuffer(buf); - - return this; -}; - Stealthkey.prototype.fromRandom = function() { this.payloadKeypair = Keypair().fromRandom(); this.scanKeypair = Keypair().fromRandom(); @@ -109,18 +87,4 @@ Stealthkey.prototype.isForMe = function(senderPubkey, myPossiblePubkeyhash) { return false; }; -Stealthkey.prototype.toAddressBuffer = function() { - var pBuf = this.payloadKeypair.pubkey.toDER(true); - var sBuf = this.scanKeypair.pubkey.toDER(true); - - return Buffer.concat([pBuf, sBuf]); -}; - -Stealthkey.prototype.toAddressString = function() { - var buf = this.toAddressBuffer(); - var b58 = base58check.encode(buf); - - return b58; -}; - module.exports = Stealthkey; diff --git a/test/stealthkey.js b/test/stealthkey.js index 5a44fa6..09638ed 100644 --- a/test/stealthkey.js +++ b/test/stealthkey.js @@ -52,29 +52,6 @@ describe('Stealthkey', function() { }); - describe('#fromAddressBuffer', function() { - - it('should give a stealthkey address with the right pubkeys', function() { - var stealthkey2 = new Stealthkey(); - var buf = base58check.decode(addressString); - stealthkey2.fromAddressBuffer(buf); - stealthkey2.payloadKeypair.pubkey.toString().should.equal(stealthkey.payloadKeypair.pubkey.toString()); - stealthkey2.scanKeypair.pubkey.toString().should.equal(stealthkey.scanKeypair.pubkey.toString()); - }); - - }); - - describe('#fromAddressString', function() { - - it('should give a stealthkey address with the right pubkeys', function() { - var stealthkey2 = new Stealthkey(); - stealthkey2.fromAddressString(addressString); - stealthkey2.payloadKeypair.pubkey.toString().should.equal(stealthkey.payloadKeypair.pubkey.toString()); - stealthkey2.scanKeypair.pubkey.toString().should.equal(stealthkey.scanKeypair.pubkey.toString()); - }); - - }); - describe('#fromRandom', function() { it('should create a new stealthkey from random', function() { @@ -178,21 +155,4 @@ describe('Stealthkey', function() { }); - describe('#toAddressBuffer', function() { - - it('should return this known address buffer', function() { - var buf = stealthkey.toAddressBuffer(); - base58check.encode(buf).should.equal(addressString); - }); - - }); - - describe('#toAddressString', function() { - - it('should return this known address string', function() { - stealthkey.toAddressString().should.equal(addressString); - }); - - }); - });