rename seckey_to_pubkey to prikey_to_pubkey

This commit is contained in:
陆柯 2022-08-16 15:28:29 +08:00
parent 6bcc378170
commit bb8b1da5f5
2 changed files with 7 additions and 7 deletions

6
btc.js
View File

@ -10,9 +10,9 @@ const BTC_TXFEE = 30
class BTC { class BTC {
constructor (privateKey) { constructor (privateKey) {
if (!ticc.is_seckey({ prikey: privateKey })) if (!ticc.is_prikey({ prikey: privateKey }))
throw new Error('Invalid PrivateKey') throw new Error('Invalid PrivateKey')
var publicKey = ticc.seckey_to_pubkey(privateKey) var publicKey = ticc.prikey_to_pubkey(privateKey)
Object.defineProperties(this, { Object.defineProperties(this, {
privateKey: { privateKey: {
enumerable: true, enumerable: true,
@ -22,7 +22,7 @@ class BTC {
publicKey: { publicKey: {
enumerable: true, enumerable: true,
writable: false, writable: false,
value: ticc.seckey_to_pubkey({ prikey: privateKey, coin: 'BTC' }) value: ticc.prikey_to_pubkey({ prikey: privateKey, coin: 'BTC' })
}, },
address: { address: {
enumerable: true, enumerable: true,

8
tic.js
View File

@ -8,7 +8,7 @@ const TIC_NODE = require('./netConfig').TIC_NODE
class TIC { class TIC {
constructor (prikey, option = {}) { constructor (prikey, option = {}) {
if (!prikey || !ticc.is_seckey({ prikey })) throw 'ERROR:Invalid Seckey' if (!prikey || !ticc.is_prikey({ prikey })) throw 'ERROR:Invalid Seckey'
Object.defineProperties(this, { Object.defineProperties(this, {
prikey: { prikey: {
value: prikey, value: prikey,
@ -16,13 +16,13 @@ class TIC {
writable: false writable: false
}, },
pubkey: { pubkey: {
value: ticc.seckey_to_pubkey({ prikey }), value: ticc.prikey_to_pubkey({ prikey }),
enumerable: true, enumerable: true,
writable: false writable: false
}, },
address: { address: {
value: ticc.pubkey_to_address({ value: ticc.pubkey_to_address({
pubkey: ticc.seckey_to_pubkey(prikey) pubkey: ticc.prikey_to_pubkey(prikey)
}), }),
enumerable: true, enumerable: true,
writable: false writable: false
@ -93,7 +93,7 @@ class TIC {
} }
static isValidAddress (address) { static isValidAddress (address) {
return ticc.is_chain_address({ address }) return ticc.which_chain_address({ address })
} }
async sendTransaction (toAddress, amount, option = { gasFee: TIC_TXFEE }) { async sendTransaction (toAddress, amount, option = { gasFee: TIC_TXFEE }) {