take address stuff out of stealthkey

...that is what StealthAddress is now for
This commit is contained in:
Ryan X. Charles 2014-09-02 12:53:41 -07:00
parent 139fe02355
commit 36fd6b2d9c
2 changed files with 0 additions and 76 deletions

View File

@ -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;

View File

@ -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);
});
});
});