jcc_wallet
Preface
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
Installtion
npm install jcc_wallet
Table of Contents
API of JingChang Wallet Tool
Description
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.
Usage
const JcWalletTool = JcWalletTool// import { JcWalletTool } from 'jcc_wallet'let inst = jcWallet
setJCWallet
inst
Parameters
jcWallet
- object
validatePassword
inst
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
removeWallet
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
Parameters
type
- string
default
-swt
Return
promise
resolve new object of jc wallet
importEthKeystore
inst
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
importSecret
inst
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
changePassword
inst
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
API of JingChang Wallet
Data Structure of JingChang Wallet
Usage
const jcWallet = jcWalletor
isValidJCWallet
jcWallet
Parameters
jcWallet
- any
Return
Boolean
buildJCWallet
jcWallet
Parameters
password
- string
wallet
- object
-
secret
:string
-
address
:string
callback
- function
Void
isValidJCKeystore
jcWallet
Parameters
text
- any
Return
Boolean
getSecret
jcWallet
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
getAddress
jcWallet
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
getJCWallet
get jingchang wallet from localstorage
jcWallet
Return
Object | null
return jc wallet if the wallet is valid from localstorage, otherwise return null
setJCWallet
save jingchang wallet to localstorage
jcWallet
Parameters
jcWallet
- object
callback
- function
Void
clearJCWallet
clear jingchang wallet from localstorage
jcWallet
encryptWallet
encrypt wallet
jcWallet
Parameters
password
- string
keypairs
- object
options
- object
Return
Object
encryptContact
encrypt contact
jcWallet
Parameters
password
- string
contacts
- object
options
- object
Return
Object
API of Jingtum and Consortium Blockchains Wallet
Usage
const jtWallet = jtWalletor
isValidAddress
jtWallet
Parameters
address
- any
chain
- string
swt
:jingtum chain(default)
bwt
:bizain chain
Return
Boolean
isValidSecret
jtWallet
Parameters
secret
- any
chain
- string
swt
:jingtum chain(default)
bwt
:bizain chain
Return
Boolean
getAddress
jtWallet
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
createWallet
create wallet of stream chain
jtWallet
Parameters
chain
- string
swt
:jingtum chain(default)
bwt
:bizain chain
Return
Object
-
secret
:string
-
address
:string
API of Call Wallet
Usage
const callWallet = callWalletor
isValidAddress
callWallet
Parameters
address
- any
Return
Boolean
isValidSecret
callWallet
Parameters
secret
- any
Return
Boolean
getAddress
callWallet
Parameters
secret
- string
Return
string | null
return address if the secret is valid, otherwise return null
createWallet
create wallet of call chain
callWallet
Return
Object | null
-
secret
:string
-
address
:string
return object if success, otherwise return null
API of Stream Wallet
Usage
const stmWallet = stmWalletor
isValidAddress
stmWallet
Parameters
address
- any
Return
Boolean
isValidSecret
stmWallet
Parameters
secret
- any
Return
Boolean
getAddress
stmWallet
Parameters
secret
- string
Return
string | null
return address if the secret is valid, otherwise return null
createWallet
create wallet of stream chain
stmWallet
Return
Object
-
secret
:string
-
address
:string
API of Ethereum Wallet
Usage
const ethWallet = ethWalletor
isValidAddress
ethWallet
Parameters
address
- any
Return
Boolean
isValidSecret
ethWallet
Parameters
secret
- any
Return
Boolean
getAddress
ethWallet
Parameters
secret
- string
Return
string | null
return address if the secret is valid, otherwise return null
decryptKeystore
get secret from ethereum keystore file with password
ethWallet
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
API of Moac Wallet
Usage
const moacWallet = moacWalletor
isValidAddress
moacWallet
Parameters
address
- any
Return
Boolean
isValidSecret
moacWallet
Parameters
secret
- any
Return
Boolean
getAddress
moacWallet
Parameters
secret
- string
Return
string | null
return address if the secret is valid, otherwise return null