jcc_wallet is a wallet toolkit of JCCDex. At present, it can handle the creation and verification of jingtum, moac, ethereum, stm, call & bizain wallet, import and export wallet with keystore file, and set password for wallet.
jcc_wallet是井畅交换平台的钱包处理工具,目前可以处理jingtum, moac, ethereum, stm, call以及bizain钱包的创建和校验,以keystore形式导入和导出钱包,设置钱包交易密码。
jcc_wallet Support running in browsers
井畅应用交流群: 557524730
JCCDex Tech support QQ group ID: 557524730
npm install jcc_wallet
the jc wallet tool to manage multiple wallets, now the wallet type includes jingtum(swt), stream(stm), call(call), ethereum(eth) and bizain(biz) chain.
const JcWalletTool = require('jcc_wallet').JcWalletTool
// import { JcWalletTool } from 'jcc_wallet'
let inst = new JcWalletTool(jcWallet)
inst.setJCWallet(jcWallet)
Parameters
jcWallet
- object
inst.validatePassword(password, type)
Parameters
password
- string
type
- string
default
-swt
Return
promise
resolve secret if success, otherwise reject error message
Error message:
-
password is required
-
wallet is empty
-
password is wrong
it will clear whole wallet if the type is swt, because the wallet of swt is basic. if the type is not swt, will remove it from wallet array.
inst.removeWallet(type)
Parameters
type
- string
default
-swt
Return
promise
resolve new object of jc wallet
inst.importEthKeystore(keystore, jcPassword, ethPassword)
decrypt secret from ethereum keystore file and encrypt ethereum secret and address with jc password, then save encrypt data to jingchang wallet object.
Tips
- Only one for eth type. if already exists, remove it firstly.
Parameters
keystore
- object
jcPassword
- string
ethPassword
- string
Return
promise
resolve new object of jc wallet if success, otherwise reject error message.
Error message:
-
password is required
-
wallet is empty
-
password is wrong
-
keystore is invalid
-
ethereum password is wrong
inst.importSecret(secret, jcPassword, type, getAddress)
decrypt address from secret and encrypt secret and address with jc password, then save encrypt data to jingchang wallet object.
Tips
- Only one for each type. if already exists, remove it firstly.
Parameters
secret
- string
jcPassword
- string
type
- string
getAddress
- function
Return
promise
resolve new object of jc wallet if success, otherwise reject error message.
Error message:
-
password is required
-
wallet is empty
-
password is wrong
-
secret is invalid
inst.changePassword(oldPassword, newPassword)
Parameters
oldPassword
- string
newPassword
- string
Return
promise
resolve new object of jc wallet if success, otherwise reject error message.
Error message:
-
password is required
-
wallet is empty
-
password is wrong
{
"contact": {},
"id": "",
"version": "",
"wallets":[{
"address": "",
"alias": "",
"ciphertext": "",
"crypto":{
"cipher": "",
"iv": "",
"kdf": "",
"kdfparams":{
"dklen": "",
"n": "",
"p": "",
"r": "",
"salt": ""
}
},
"default": true,
"mac": "",
"type": ""
}]
}
const jcWallet = require('jcc_wallet').jcWallet
or
import { jcWallet } from 'jcc_wallet'
jcWallet.isValidJCWallet(jcWallet)
Parameters
jcWallet
- any
Return
Boolean
jcWallet.buildJCWallet(password, wallet, callback)
Parameters
password
- string
wallet
- object
-
secret
:string
-
address
:string
callback
- function
Void
callback(walletID, jcWallet)
jcWallet.isValidJCKeystore(text)
Parameters
text
- any
Return
Boolean
jcWallet.getSecret(jcWallet, password, type)
Parameters
jcWallet
- object
password
- string
type
- string
- default type is swt
Return
string | null | false
return null if the jcWallet is invalid or the given type is not existent, return false if the password is not correct, otherwise return secret
jcWallet.getAddress(jcWallet, type)
Parameters
jcWallet
- object
type
- string
- default type is swt
Return
string | null
return null if the jcWallet is invalid or the given type is not existent, otherwise return address
jcWallet.getJCWallet()
Return
Object | null
return jc wallet if the wallet is valid from localstorage, otherwise return null
jcWallet.setJCWallet(jcWallet, callback)
Parameters
jcWallet
- object
callback
- function
Void
callback(jcWallet)
jcWallet.clearJCWallet()
jcWallet.encryptWallet(password, keypairs, opts)
Parameters
password
- string
keypairs
- object
options
- object
Return
Object
jcWallet.encryptContact(password, contacts, opts)
Parameters
password
- string
contacts
- object
options
- object
Return
Object
const jtWallet = require('jcc_wallet').jtWallet
or
import { jtWallet } from 'jcc_wallet'
jtWallet.isValidAddress(address, chain)
Parameters
address
- any
chain
- string
swt
:jingtum chain(default)
bwt
:bizain chain
Return
Boolean
jtWallet.isValidSecret(secret, chain)
Parameters
secret
- any
chain
- string
swt
:jingtum chain(default)
bwt
:bizain chain
Return
Boolean
jtWallet.getAddress(secret, chain)
Parameters
secret
- string
chain
- string
swt
:jingtum chain(default)
bwt
:bizain chain
Return
string | null
return address if the secret is valid, otherwise return null
create wallet of stream chain
jtWallet.createWallet(chain)
Parameters
chain
- string
swt
:jingtum chain(default)
bwt
:bizain chain
Return
Object
-
secret
:string
-
address
:string
const callWallet = require('jcc_wallet').callWallet
or
import { callWallet } from 'jcc_wallet'
callWallet.isValidAddress(address)
Parameters
address
- any
Return
Boolean
callWallet.isValidSecret(secret)
Parameters
secret
- any
Return
Boolean
callWallet.getAddress(secret)
Parameters
secret
- string
Return
string | null
return address if the secret is valid, otherwise return null
create wallet of call chain
callWallet.createWallet()
Return
Object | null
-
secret
:string
-
address
:string
return object if success, otherwise return null
const stmWallet = require('jcc_wallet').stmWallet
or
import { stmWallet } from 'jcc_wallet'
stmWallet.isValidAddress(address)
Parameters
address
- any
Return
Boolean
stmWallet.isValidSecret(secret)
Parameters
secret
- any
Return
Boolean
stmWallet.getAddress(secret)
Parameters
secret
- string
Return
string | null
return address if the secret is valid, otherwise return null
create wallet of stream chain
stmWallet.createWallet()
Return
Object
-
secret
:string
-
address
:string
const ethWallet = require('jcc_wallet').ethWallet
or
import { ethWallet } from 'jcc_wallet'
ethWallet.isValidAddress(address)
Parameters
address
- any
Return
Boolean
ethWallet.isValidSecret(secret)
Parameters
secret
- any
Return
Boolean
ethWallet.getAddress(secret)
Parameters
secret
- string
Return
string | null
return address if the secret is valid, otherwise return null
get secret from ethereum keystore file with password
ethWallet.decryptKeystore(password, encryptData)
Parameters
password
- string
encryptData
- object
Return
string | null | false
return secret if the keystore file is valid and the password is correct, return false if the password is not correct, otherwise return null
const moacWallet = require('jcc_wallet').moacWallet
or
import { moacWallet } from 'jcc_wallet'
moacWallet.isValidAddress(address)
Parameters
address
- any
Return
Boolean
moacWallet.isValidSecret(secret)
Parameters
secret
- any
Return
Boolean
moacWallet.getAddress(secret)
Parameters
secret
- string
Return
string | null
return address if the secret is valid, otherwise return null