ECPair/HDNode: adds getNetwork
This commit is contained in:
parent
57d0ea84a2
commit
daafb9794e
4 changed files with 28 additions and 0 deletions
|
@ -105,6 +105,10 @@ ECPair.prototype.getAddress = function () {
|
||||||
return bs58check.encode(payload)
|
return bs58check.encode(payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ECPair.prototype.getNetwork = function () {
|
||||||
|
return this.network
|
||||||
|
}
|
||||||
|
|
||||||
ECPair.prototype.getPublicKeyBuffer = function () {
|
ECPair.prototype.getPublicKeyBuffer = function () {
|
||||||
return this.Q.getEncoded(this.compressed)
|
return this.Q.getEncoded(this.compressed)
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,6 +136,10 @@ HDNode.prototype.getFingerprint = function () {
|
||||||
return this.getIdentifier().slice(0, 4)
|
return this.getIdentifier().slice(0, 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HDNode.prototype.getNetwork = function () {
|
||||||
|
return this.keyPair.getNetwork()
|
||||||
|
}
|
||||||
|
|
||||||
HDNode.prototype.getPublicKeyBuffer = function () {
|
HDNode.prototype.getPublicKeyBuffer = function () {
|
||||||
return this.keyPair.getPublicKeyBuffer()
|
return this.keyPair.getPublicKeyBuffer()
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,6 +167,17 @@ describe('ECPair', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('getNetwork', function () {
|
||||||
|
fixtures.valid.forEach(function (f) {
|
||||||
|
it('returns ' + f.network + ' for ' + f.WIF, function () {
|
||||||
|
var network = NETWORKS[f.network]
|
||||||
|
var keyPair = ECPair.fromWIF(f.WIF, NETWORKS_LIST)
|
||||||
|
|
||||||
|
assert.strictEqual(keyPair.getNetwork(), network)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('ecdsa wrappers', function () {
|
describe('ecdsa wrappers', function () {
|
||||||
var keyPair, hash
|
var keyPair, hash
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,15 @@ describe('HDNode', function () {
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('getNetwork', function () {
|
||||||
|
it('wraps keyPair.getNetwork', sinon.test(function () {
|
||||||
|
this.mock(keyPair).expects('getNetwork')
|
||||||
|
.once().withArgs().returns('network')
|
||||||
|
|
||||||
|
assert.strictEqual(hd.getNetwork(), 'network')
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
describe('getPublicKeyBuffer', function () {
|
describe('getPublicKeyBuffer', function () {
|
||||||
it('wraps keyPair.getPublicKeyBuffer', sinon.test(function () {
|
it('wraps keyPair.getPublicKeyBuffer', sinon.test(function () {
|
||||||
this.mock(keyPair).expects('getPublicKeyBuffer')
|
this.mock(keyPair).expects('getPublicKeyBuffer')
|
||||||
|
|
Loading…
Reference in a new issue