rename seckey to prikey

This commit is contained in:
陆柯 2022-08-14 15:51:14 +08:00
parent bbba2589d5
commit 6bcc378170
2 changed files with 18 additions and 18 deletions

8
btc.js
View File

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

28
tic.js
View File

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