Changes existing code to use new base58 API
This commit is contained in:
parent
f53b821cc9
commit
6fa0c07763
7 changed files with 83 additions and 52 deletions
src
14
src/eckey.js
14
src/eckey.js
|
@ -1,7 +1,7 @@
|
|||
var Address = require('./address')
|
||||
var assert = require('assert')
|
||||
var convert = require('./convert')
|
||||
var base58 = require('./base58')
|
||||
var base58check = require('./base58check')
|
||||
var BigInteger = require('./jsbn/jsbn')
|
||||
var ecdsa = require('./ecdsa')
|
||||
var ECPointFp = require('./jsbn/ec').ECPointFp
|
||||
|
@ -32,10 +32,10 @@ ECKey.prototype.import = function (input, compressed) {
|
|||
: Array.isArray(input) ? fromBin(input.slice(0, 32))
|
||||
: typeof input != "string" ? null
|
||||
: input.length == 44 ? fromBin(convert.base64ToBytes(input))
|
||||
: input.length == 51 && input[0] == '5' ? fromBin(base58.checkDecode(input))
|
||||
: input.length == 51 && input[0] == '9' ? fromBin(base58.checkDecode(input))
|
||||
: input.length == 52 && has('LK', input[0]) ? fromBin(base58.checkDecode(input).slice(0, 32))
|
||||
: input.length == 52 && input[0] == 'c' ? fromBin(base58.checkDecode(input).slice(0, 32))
|
||||
: input.length == 51 && input[0] == '5' ? fromBin(base58check.decode(input).payload)
|
||||
: input.length == 51 && input[0] == '9' ? fromBin(base58check.decode(input).payload)
|
||||
: input.length == 52 && has('LK', input[0]) ? fromBin(base58check.decode(input).payload.slice(0, 32))
|
||||
: input.length == 52 && input[0] == 'c' ? fromBin(base58check.decode(input).payload.slice(0, 32))
|
||||
: has([64,65],input.length) ? fromBin(convert.hexToBytes(input.slice(0, 64)))
|
||||
: null
|
||||
|
||||
|
@ -76,7 +76,7 @@ ECKey.version_bytes = {
|
|||
ECKey.prototype.toWif = function(version) {
|
||||
version = version || Network.mainnet.addressVersion
|
||||
|
||||
return base58.checkEncode(this.toBytes(), ECKey.version_bytes[version])
|
||||
return base58check.encode(this.toBytes(), ECKey.version_bytes[version])
|
||||
}
|
||||
|
||||
ECKey.prototype.toHex = function() {
|
||||
|
@ -167,7 +167,7 @@ ECPubKey.prototype.toBin = function(compressed) {
|
|||
ECPubKey.prototype.toWif = function(version) {
|
||||
version = version || Network.mainnet.addressVersion
|
||||
|
||||
return base58.checkEncode(this.toBytes(), version)
|
||||
return base58check.encode(this.toBytes(), version)
|
||||
}
|
||||
|
||||
ECPubKey.prototype.toString = ECPubKey.prototype.toHex
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue