Skip to content

Latest commit

 

History

History
397 lines (234 loc) · 5.45 KB

deprecatedAPI.md

File metadata and controls

397 lines (234 loc) · 5.45 KB

deprecated api

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 = require('jcc_wallet').JcWalletTool
// import { JcWalletTool } from 'jcc_wallet'
let inst = new JcWalletTool(jcWallet)

setJCWallet

inst.setJCWallet(jcWallet)

Parameters

jcWallet- object

validatePassword

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

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.removeWallet(type)

Parameters

type- string

  • default- swt

Return

promise

resolve new object of jc wallet

importEthKeystore

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

importSecret

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

changePassword

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

API of JingChang Wallet

Data Structure of JingChang Wallet

{
    "contact": {},
    "id": "",
    "version": "",
    "wallets":[{
        "address": "",
        "alias": "",
        "ciphertext": "",
        "crypto":{
            "cipher": "",
            "iv": "",
            "kdf": "",
            "kdfparams":{
                "dklen": "",
                "n": "",
                "p": "",
                "r": "",
                "salt": ""
            }
        },
        "default": true,
        "mac": "",
        "type": ""
    }]
}

Usage

const jcWallet = require('jcc_wallet').jcWallet
or
import { jcWallet } from 'jcc_wallet'

isValidJCWallet

jcWallet.isValidJCWallet(jcWallet)

Parameters

jcWallet- any

Return

Boolean

buildJCWallet

jcWallet.buildJCWallet(password, wallet, callback)

Parameters

password- string

wallet- object

  • secret: string

  • address: string

callback- function

Void

callback(walletID, jcWallet)

isValidJCKeystore

jcWallet.isValidJCKeystore(text)

Parameters

text- any

Return

Boolean

getSecret

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

getAddress

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

getJCWallet

get jingchang wallet from localstorage

jcWallet.getJCWallet()

Return

Object | null

return jc wallet if the wallet is valid from localstorage, otherwise return null

setJCWallet

save jingchang wallet to localstorage

jcWallet.setJCWallet(jcWallet, callback)

Parameters

jcWallet- object

callback- function

Void

callback(jcWallet)

clearJCWallet

clear jingchang wallet from localstorage

jcWallet.clearJCWallet()

encryptWallet

encrypt wallet

jcWallet.encryptWallet(password, keypairs, opts)

Parameters

password- string

keypairs- object

options- object

Return

Object

encryptContact

encrypt contact

jcWallet.encryptContact(password, contacts, opts)

Parameters

password- string

contacts- object

options- object

Return

Object