From 6bcc3781700b9aeee67b615aea9e552953473def Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Sun, 14 Aug 2022 15:51:14 +0800 Subject: [PATCH] rename seckey to prikey --- btc.js | 8 ++++---- tic.js | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/btc.js b/btc.js index 4cea30b..609b43d 100644 --- a/btc.js +++ b/btc.js @@ -10,7 +10,7 @@ const BTC_TXFEE = 30 class BTC { constructor (privateKey) { - if (!ticc.is_seckey({ seckey: privateKey })) + if (!ticc.is_seckey({ prikey: privateKey })) throw new Error('Invalid PrivateKey') var publicKey = ticc.seckey_to_pubkey(privateKey) Object.defineProperties(this, { @@ -22,7 +22,7 @@ class BTC { publicKey: { enumerable: true, writable: false, - value: ticc.seckey_to_pubkey({ seckey: privateKey, coin: 'BTC' }) + value: ticc.seckey_to_pubkey({ prikey: privateKey, coin: 'BTC' }) }, address: { enumerable: true, @@ -61,7 +61,7 @@ class BTC { var mnemonic = ticc.randomize_secword() return Object.assign( new BTC( - ticc.secword_to_keypair({ secword: mnemonic, coin: 'BTC' }).seckey + ticc.secword_to_keypair({ secword: mnemonic, coin: 'BTC' }).prikey ), { mnemonic: mnemonic } ) @@ -70,7 +70,7 @@ class BTC { HDNode.isValidMnemonic(mnemonic) return Object.assign( new BTC( - ticc.secword_to_keypair({ secword: mnemonic, coin: 'BTC' }).seckey + ticc.secword_to_keypair({ secword: mnemonic, coin: 'BTC' }).prikey ), { mnemonic: mnemonic } ) diff --git a/tic.js b/tic.js index 396bc0a..ad5cee6 100644 --- a/tic.js +++ b/tic.js @@ -7,22 +7,22 @@ const TIC_TXFEE = 10 const TIC_NODE = require('./netConfig').TIC_NODE class TIC { - constructor (seckey, option = {}) { - if (!seckey || !ticc.is_seckey({ seckey })) throw 'ERROR:Invalid Seckey' + constructor (prikey, option = {}) { + if (!prikey || !ticc.is_seckey({ prikey })) throw 'ERROR:Invalid Seckey' Object.defineProperties(this, { - seckey: { - value: seckey, + prikey: { + value: prikey, enumerable: true, writable: false }, pubkey: { - value: ticc.seckey_to_pubkey({ seckey }), + value: ticc.seckey_to_pubkey({ prikey }), enumerable: true, writable: false }, address: { value: ticc.pubkey_to_address({ - pubkey: ticc.seckey_to_pubkey(seckey) + pubkey: ticc.seckey_to_pubkey(prikey) }), enumerable: true, writable: false @@ -48,13 +48,13 @@ class TIC { static generateNewAccount () { var secword = ticc.randomize_secword() - return Object.assign(new TIC(ticc.secword_to_keypair({ secword }).seckey), { + return Object.assign(new TIC(ticc.secword_to_keypair({ secword }).prikey), { secword: secword }) } static fromMnemonic (secword) { if (!secword || !ticc.is_secword(secword)) throw 'ERROR:Invalid Secword' - return new TIC(ticc.secword_to_keypair({ secword }).seckey) + return new TIC(ticc.secword_to_keypair({ secword }).prikey) } static async getBalance (address) { if (!address) { @@ -107,7 +107,7 @@ class TIC { }) //对交易数据签名,packMe 内的参数是交易发起人的keypair action.packMe({ - seckey: this.seckey, + prikey: this.prikey, pubkey: this.pubkey }) let data = { @@ -137,17 +137,17 @@ class TIC { }) //sign for txBody use function packMe, which needs actor's keypair as parameter action.packMe({ - seckey: this.seckey, + prikey: this.prikey, pubkey: this.pubkey }) return action } - //default key for sign&encrypt is account's seckey,other keys are optional. - sign (message, key = this.seckey) { - return ticc.sign_easy({ data: message, seckey: key }) + //default key for sign&encrypt is account's prikey,other keys are optional. + sign (message, key = this.prikey) { + return ticc.sign_easy({ data: message, prikey: key }) } verify (message, signature) { - return ticc.sign_easy({ data: message, signature, seckey: this.seckey }) + return ticc.sign_easy({ data: message, signature, prikey: this.prikey }) } encrypt (key) { return TIC.encrypt(this, key)