diff --git a/src/HTTP/type.ts b/src/HTTP/type.ts index ea71a360..a727660e 100644 --- a/src/HTTP/type.ts +++ b/src/HTTP/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/IPC/type.ts b/src/IPC/type.ts index ea71a360..a727660e 100644 --- a/src/IPC/type.ts +++ b/src/IPC/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/WS/type.ts b/src/WS/type.ts index ea71a360..a727660e 100644 --- a/src/WS/type.ts +++ b/src/WS/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/abi/type.ts b/src/abi/type.ts index ea71a360..a727660e 100644 --- a/src/abi/type.ts +++ b/src/abi/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/account/index.ts b/src/account/index.ts index 5dd7f264..2fd47e2f 100644 --- a/src/account/index.ts +++ b/src/account/index.ts @@ -35,15 +35,15 @@ class AccountClass extends addrAccount { this.privateKey = null; this.publicKey = null; } else { - const { pubKey, privKey, hexAddr } = privToAddr.createAddressByPrivateKey(privateKey); + const addrObj = privToAddr.createAddressByPrivateKey(privateKey); - if (privateKey && address && hexAddr !== address) { + if (privateKey && address && addrObj.address !== address) { throw new Error(`Private key does not match address ${ address }`); } - super({ address: hexAddr, client }); - this.privateKey = privKey; - this.publicKey = pubKey; + super({ address: addrObj.address, client }); + this.privateKey = addrObj.privateKey; + this.publicKey = addrObj.publicKey; } this._lock = true; @@ -66,13 +66,13 @@ class AccountClass extends addrAccount { return; } - const { pubKey, privKey, hexAddr } = privToAddr.createAddressByPrivateKey(privateKey); - if (hexAddr !== this.address) { + const addrObj = privToAddr.createAddressByPrivateKey(privateKey); + if (addrObj.address !== this.address) { throw new Error(`Private key does not match address ${ this.address }`); } - this.privateKey = privKey; - this.publicKey = pubKey; + this.privateKey = addrObj.privateKey; + this.publicKey = addrObj.publicKey; } getPublicKey() { diff --git a/src/account/type.ts b/src/account/type.ts index ea71a360..a727660e 100644 --- a/src/account/type.ts +++ b/src/account/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/accountBlock/type.ts b/src/accountBlock/type.ts index ea71a360..a727660e 100644 --- a/src/accountBlock/type.ts +++ b/src/accountBlock/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/addrAccount/type.ts b/src/addrAccount/type.ts index ea71a360..a727660e 100644 --- a/src/addrAccount/type.ts +++ b/src/addrAccount/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/address/mnemonic.ts b/src/address/mnemonic.ts new file mode 100644 index 00000000..e69de29b diff --git a/src/address/type.ts b/src/address/type.ts index ea71a360..a727660e 100644 --- a/src/address/type.ts +++ b/src/address/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/client/type.ts b/src/client/type.ts index ea71a360..a727660e 100644 --- a/src/client/type.ts +++ b/src/client/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/communication/type.ts b/src/communication/type.ts index ea71a360..a727660e 100644 --- a/src/communication/type.ts +++ b/src/communication/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/constant/type.ts b/src/constant/type.ts index ea71a360..a727660e 100644 --- a/src/constant/type.ts +++ b/src/constant/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/error/type.ts b/src/error/type.ts index ea71a360..a727660e 100644 --- a/src/error/type.ts +++ b/src/error/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/hdAccount/index.ts b/src/hdAccount/index.ts index 400e3f1b..c078376f 100644 --- a/src/hdAccount/index.ts +++ b/src/hdAccount/index.ts @@ -138,7 +138,7 @@ class HdAccountClass { let i; for (i = 0; i < this.activeAccountList.length; i++) { const account = this.activeAccountList[i]; - if (account.address === addrObj.hexAddr) { + if (account.address === addrObj.address) { break; } } @@ -148,7 +148,7 @@ class HdAccountClass { } return new Account({ - privateKey: addrObj.privKey, + privateKey: addrObj.privateKey, client: this._client }, { autoPow, usePledgeQuota }); } @@ -186,7 +186,7 @@ class HdAccountClass { let i; for (i = 0; i < this.addrList.length; i++) { - if (this.addrList[i].hexAddr === address) { + if (this.addrList[i].address === address) { break; } } diff --git a/src/hdAccount/type.ts b/src/hdAccount/type.ts index ea71a360..a727660e 100644 --- a/src/hdAccount/type.ts +++ b/src/hdAccount/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/hdAddr/index.ts b/src/hdAddr/index.ts index 2ba8aa2f..881f6321 100644 --- a/src/hdAddr/index.ts +++ b/src/hdAddr/index.ts @@ -2,7 +2,7 @@ const bip39 = require('bip39'); const hd = require('@sisi/ed25519-blake2b-hd-key'); import { createAddressByPrivateKey, isAddress as _isAddress, getRealAddressFromAddress as _getRealAddressFromAddress } from '~@vite/vitejs-privtoaddr'; import { paramsFormat } from '~@vite/vitejs-error'; -import { checkParams, bytesToHex, blake2b } from '~@vite/vitejs-utils'; +import { checkParams, blake2b } from '~@vite/vitejs-utils'; import { AddrObj, Hex } from './type'; @@ -36,9 +36,7 @@ export function getMnemonicFromEntropy(entropy: string, wordlist: Array) return bip39.entropyToMnemonic(entropy, wordlist); } -export function createAddress(bits: number = 256, wordlist: Array, pwd: string = '', isContract?: boolean): { - addr: AddrObj; entropy: string; mnemonic: string; id: Hex; -} { +export function createMnemonic(bits: number = 256, wordlist: Array, pwd: string = '') { const err = checkParams({ bits }, ['bits']); if (err) { throw new Error(err.message); @@ -48,6 +46,22 @@ export function createAddress(bits: number = 256, wordlist: Array, pwd: const mnemonic = bip39.generateMnemonic(bits, null, wordlist); const entropy = bip39.mnemonicToEntropy(mnemonic, wordlist); const seed = bip39.mnemonicToSeedSync(mnemonic, pwd).toString('hex'); + + return { mnemonic, entropy, seed }; +} + +export function deriveKeyPair(seed, index: number) { + const path = getPath(index); + const { key } = hd.derivePath(path, seed); + return hd.getPublicKey(key); +} + +export function createAddress(bits: number = 256, wordlist: Array, pwd: string = '', isContract?: boolean): { + addr: AddrObj; entropy: string; mnemonic: string; id: Hex; +} { + wordlist = wordlist || bip39.wordlists.EN; + const { mnemonic, entropy, seed } = createMnemonic(bits, wordlist, pwd); + const path = getPath(0); const addr = getAddrFromPath(path, seed, isContract); const id = getId(mnemonic, wordlist); @@ -113,15 +127,14 @@ export const getRealAddressFromAddress = _getRealAddressFromAddress; export const isAddress = _isAddress; +function getPath(index: number): string { + return `${ ROOT_PATH }/${ index }\'`; +} + function getAddrFromPath(path: string, seed: string, isContract?: boolean): AddrObj { const { key } = hd.derivePath(path, seed); const { privateKey } = hd.getPublicKey(key); - const priv = bytesToHex(privateKey); - return createAddressByPrivateKey(priv, isContract); -} - -function getPath(index: number): string { - return `${ ROOT_PATH }/${ index }\'`; + return createAddressByPrivateKey(privateKey, isContract); } function _getId(mnemonic: string, wordlist: Array, pwd: string = '', isContract?: boolean): Hex { @@ -136,7 +149,7 @@ function _getId(mnemonic: string, wordlist: Array, pwd: string = '', isC } const addrObj = getAddrFromMnemonic(mnemonic, 0, wordlist, pwd, isContract); - const keyBuffer = Buffer.from(addrObj.hexAddr); + const keyBuffer = Buffer.from(addrObj.address); const idByte = blake2b(keyBuffer, null, 32); return Buffer.from(idByte).toString('hex'); } diff --git a/src/hdAddr/type.ts b/src/hdAddr/type.ts index ea71a360..a727660e 100644 --- a/src/hdAddr/type.ts +++ b/src/hdAddr/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/keystore/encrypt.ts b/src/keystore/encrypt.ts index fe802d09..559429e5 100644 --- a/src/keystore/encrypt.ts +++ b/src/keystore/encrypt.ts @@ -79,7 +79,7 @@ export function encryptOldKeystore(privKey, pwd, selfScryptsy) { throw new Error(err.message); } - const key = createAddressByPrivateKey(privKey); + const addrObj = createAddressByPrivateKey(privKey); const scryptParams = { n, @@ -92,7 +92,7 @@ export function encryptOldKeystore(privKey, pwd, selfScryptsy) { const getResult = (_encryptPwd, res) => { const nonce = random(12); const text = cipheriv({ - rawText: key.privKey, + rawText: addrObj.privateKey, pwd: _encryptPwd, nonce, algorithm @@ -107,7 +107,7 @@ export function encryptOldKeystore(privKey, pwd, selfScryptsy) { }; const encryptedKeyJSON = { - hexAddress: key.hexAddr, + hexAddress: addrObj.address, crypto: cryptoJSON, id: new UUID(1).format(), keystoreVersion: 1, diff --git a/src/keystore/type.ts b/src/keystore/type.ts index ea71a360..a727660e 100644 --- a/src/keystore/type.ts +++ b/src/keystore/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/privToAddr/index.ts b/src/privToAddr/index.ts index b8183daa..ecbf4440 100644 --- a/src/privToAddr/index.ts +++ b/src/privToAddr/index.ts @@ -13,14 +13,14 @@ export function createAddressByPrivateKey(priv?: Hex | Buffer, isContract?: bool // checkSum = isContract ? reverse(Blake2b(address[0:20])(len:5)) : Blake2b(address[0:20])(len:5) const checkSum = getAddrCheckSum(realAddr, isContract); - // hexAddr = 'vite_' + Hex(realAddr[0:20] + checkSum) - const hexAddr = getHexAddr(realAddr, checkSum); + // address = 'vite_' + Hex(realAddr[0:20] + checkSum) + const address = getHexAddr(realAddr, checkSum); return { - addr: realAddr.toString('hex'), - pubKey: getPublicKey(privKey), - privKey: privKey.toString('hex'), - hexAddr + realAddress: realAddr.toString('hex'), + publicKey: getPublicKey(privKey), + privateKey: privKey.toString('hex'), + address }; } diff --git a/src/privToAddr/type.ts b/src/privToAddr/type.ts index ea71a360..a727660e 100644 --- a/src/privToAddr/type.ts +++ b/src/privToAddr/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/subscription/type.ts b/src/subscription/type.ts index ea71a360..a727660e 100644 --- a/src/subscription/type.ts +++ b/src/subscription/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/transaction/type.ts b/src/transaction/type.ts index ea71a360..a727660e 100644 --- a/src/transaction/type.ts +++ b/src/transaction/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/type.ts b/src/type.ts index ea71a360..a727660e 100644 --- a/src/type.ts +++ b/src/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/utils/type.ts b/src/utils/type.ts index ea71a360..a727660e 100644 --- a/src/utils/type.ts +++ b/src/utils/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/vitejs/type.ts b/src/vitejs/type.ts index ea71a360..a727660e 100644 --- a/src/vitejs/type.ts +++ b/src/vitejs/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/src/wallet/type.ts b/src/wallet/type.ts index ea71a360..a727660e 100644 --- a/src/wallet/type.ts +++ b/src/wallet/type.ts @@ -253,10 +253,10 @@ export declare type changeTransferOwnerBlock = { } export declare type AddrObj = { - addr: string; - pubKey: Hex; - privKey: Hex; - hexAddr: Address; + realAddress: string; + publicKey: Hex; + privateKey: Hex; + address: Address; } export enum BlockType { diff --git a/test/RPC/accountBlock.js b/test/RPC/accountBlock.js index 63c04a84..d2a7225d 100644 --- a/test/RPC/accountBlock.js +++ b/test/RPC/accountBlock.js @@ -55,7 +55,7 @@ it('SBPreg', function(done) { it('updateReg', function(done) { myAccount.getBlock.updateReg({ nodeName: 'CS_TEST_NODE', - toAddress: myHdAccount.addrList[1].hexAddr, + toAddress: myHdAccount.addrList[1].address, height, prevHash }).then((block) => { done(assert.equal(getTxType(block), 'UpdateReg')); @@ -78,7 +78,7 @@ it('revokeReg', function(done) { it('retrieveReward', function(done) { myAccount.getBlock.retrieveReward({ nodeName: 'CS_TEST_NODE', - toAddress: myHdAccount.addrList[1].hexAddr, + toAddress: myHdAccount.addrList[1].address, height, prevHash }).then((block) => { done(assert.equal(getTxType(block), 'RetrieveReward')); diff --git a/test/RPC/wallet.js b/test/RPC/wallet.js index 01c6bfc0..148daddb 100644 --- a/test/RPC/wallet.js +++ b/test/RPC/wallet.js @@ -170,7 +170,7 @@ async function revokeReg() { async function updateReg() { const result = await myAccount.updateReg({ nodeName: 'CS_TEST_NODE', - toAddress: myHdAccount.addrList[1].hexAddr + toAddress: myHdAccount.addrList[1].address }); console.log('[LOG] updateReg', result, '\n'); diff --git a/test/packages/account.js b/test/packages/account.js index 8d26fa27..6f56de0b 100644 --- a/test/packages/account.js +++ b/test/packages/account.js @@ -12,7 +12,7 @@ const myHTTPClient = new Client(new HTTP_RPC()); describe('New Account with privateKey', function () { const addrObj = createAddressByPrivateKey(); const myAccount = new Account({ - privateKey: addrObj.privKey, + privateKey: addrObj.privateKey, client: myHTTPClient }); @@ -20,13 +20,13 @@ describe('New Account with privateKey', function () { assert(myAccount instanceof AddrAccount, true); }); it('property realAddress', function () { - assert(myAccount.realAddress, addrObj.addr); + assert(myAccount.realAddress, addrObj.realAddress); }); it('property privateKey', function () { - assert(myAccount.privateKey, addrObj.privKey); + assert(myAccount.privateKey, addrObj.privateKey); }); it('property getPublicKey', function () { - assert(myAccount.getPublicKey(), addrObj.pubKey); + assert(myAccount.getPublicKey(), addrObj.publicKey); }); it('property _client', function () { assert.deepEqual(myAccount._client, myHTTPClient); @@ -44,10 +44,10 @@ describe('New Account without privateKey', function () { const addrObj = createAddressByPrivateKey(myAccount.privateKey); it('property realAddress', function () { - assert(myAccount.realAddress, addrObj.addr); + assert(myAccount.realAddress, addrObj.realAddress); }); it('property getPublicKey', function () { - assert(myAccount.getPublicKey(), addrObj.pubKey); + assert(myAccount.getPublicKey(), addrObj.publicKey); }); testFunctions(myAccount); diff --git a/test/packages/addrAccount.js b/test/packages/addrAccount.js index 5d8ace04..846a27ca 100644 --- a/test/packages/addrAccount.js +++ b/test/packages/addrAccount.js @@ -9,17 +9,17 @@ const addrObj = createAddressByPrivateKey(); const myHTTPClient = new Client(new HTTP_RPC()); const myAddrAccount = new AddrAccount({ - address: addrObj.hexAddr, + address: addrObj.address, client: myHTTPClient }); describe('New AddrAccount: property', function () { it('address', function () { - assert(myAddrAccount.address, addrObj.hexAddr); + assert(myAddrAccount.address, addrObj.address); }); it('realAddress', function () { - assert(myAddrAccount.realAddress, addrObj.addr); + assert(myAddrAccount.realAddress, addrObj.realAddress); }); it('_client', function () { diff --git a/test/packages/hdAccount.js b/test/packages/hdAccount.js index 830baece..eb66269a 100644 --- a/test/packages/hdAccount.js +++ b/test/packages/hdAccount.js @@ -24,8 +24,8 @@ describe('New HdAccount with mnemonic', function () { it('property addrList.length === 1', function () { assert.equal(myHdAccount.addrList.length, 1); }); - it('property addrList[0].hexAddr', function () { - assert.equal(myHdAccount.addrList[0].hexAddr, addrObj.addr.hexAddr); + it('property addrList[0].address', function () { + assert.equal(myHdAccount.addrList[0].address, addrObj.addr.address); }); it('property id', function () { assert.equal(myHdAccount.id, getId(addrObj.mnemonic)); diff --git a/test/packages/hdAddr.js b/test/packages/hdAddr.js index f4fd4c5f..95377568 100644 --- a/test/packages/hdAddr.js +++ b/test/packages/hdAddr.js @@ -148,7 +148,7 @@ describe('function', function () { const as = getAddrsFromMnemonic('horn equal mystery success pride regret renew great witness hire man moon'); const arr = []; as.forEach(item => { - arr.push(item.hexAddr); + arr.push(item.address); }); assert.deepEqual(arr, [ diff --git a/test/packages/keystore.js b/test/packages/keystore.js index 8b6f341e..aed10148 100644 --- a/test/packages/keystore.js +++ b/test/packages/keystore.js @@ -100,7 +100,7 @@ if (process.env.NODE_ENV !== 'testWatch') { it('only decrypt', function (done) { decrypt(oldks, OLD_PWD).then(privKey => { const k = createAddressByPrivateKey(privKey); - done(assert.equal(k.hexAddr, oldKeyJSON.hexaddress)); + done(assert.equal(k.address, oldKeyJSON.hexaddress)); }).catch(err => { done(err); }); diff --git a/test/packages/privToAddr.js b/test/packages/privToAddr.js index 29894c14..b392f33f 100644 --- a/test/packages/privToAddr.js +++ b/test/packages/privToAddr.js @@ -12,37 +12,37 @@ const addrPrivContract = createAddressByPrivateKey(privKey, true); describe('createAddressByPrivateKey', function () { it('with privateKey, isContract = false', function () { - assert.equal(addrPriv.privKey, privKey); + assert.equal(addrPriv.privateKey, privKey); }); it('with privateKey, isContract = true', function () { - assert.equal(addrPrivContract.privKey, privKey); + assert.equal(addrPrivContract.privateKey, privKey); }); it('without privateKey, isContract = false', function () { - assert.equal(typeof addr.privKey, 'string'); + assert.equal(typeof addr.privateKey, 'string'); }); it('without privateKey, isContract = true', function () { - assert.equal(typeof addrContract.privKey, 'string'); + assert.equal(typeof addrContract.privateKey, 'string'); }); }); describe('isAddress', function () { it('createAddressByPrivateKey addr', function () { - assert.equal(isAddress(addr.hexAddr), 1); + assert.equal(isAddress(addr.address), 1); }); it('createAddressByPrivateKey addrContract', function () { - assert.equal(isAddress(addrContract.hexAddr), 2); + assert.equal(isAddress(addrContract.address), 2); }); it('createAddressByPrivateKey addrPriv', function () { - assert.equal(isAddress(addrPriv.hexAddr), 1); + assert.equal(isAddress(addrPriv.address), 1); }); it('createAddressByPrivateKey addrPrivContract', function () { - assert.equal(isAddress(addrPrivContract.hexAddr), 2); + assert.equal(isAddress(addrPrivContract.address), 2); }); it('Old user address: case 1', function () { @@ -64,7 +64,7 @@ describe('isAddress', function () { describe('getRealAddressFromAddress', function () { it('createAddressByPrivateKey', function () { - assert.equal(getRealAddressFromAddress(addr.hexAddr), addr.addr); + assert.equal(getRealAddressFromAddress(addr.address), addr.realAddress); }); it('user address 1', function () { @@ -86,7 +86,7 @@ describe('getRealAddressFromAddress', function () { describe('getAddressFromRealAddress', function () { it('createAddressByPrivateKey', function () { - assert.equal(getAddressFromRealAddress(addr.addr), addr.hexAddr); + assert.equal(getAddressFromRealAddress(addr.realAddress), addr.address); }); it('case 1', function () { @@ -97,6 +97,6 @@ describe('getAddressFromRealAddress', function () { describe('createAddressByPublicKey', function () { it('createAddressByPrivateKey', function () { - assert.equal(createAddressByPublicKey(addr.pubKey), addr.hexAddr); + assert.equal(createAddressByPublicKey(addr.publicKey), addr.address); }); });