-
<constant> btcUtil
-
ccUtil
- Source:
-
api/btcUtil.js
-
<constant> ccUtil
-
ccUtil
- Source:
-
api/ccUtil.js
-
<constant> _WERRNO_LOGIC_BASE
-
Error defination
Copyright (c) 2019, Wanchain.
Liscensed under MIT license.
- Source:
-
api/error.js
-
<constant> hdUtil
-
hdUtil
- Source:
-
api/hdUtil.js
-
<constant> MonitorRecord
-
Used to monitor the cross transaction status.
- Source:
-
core/monitor.js
-
<constant> MonitorRecordNormal
-
Used to monitor the normal transaction status.
- Source:
-
core/monitorNormal.js
-
<constant> MonitorOTA
-
- Source:
-
core/monitorOTA.js
-
logger
-
Get logger after new wallet core, cause we need get logpath
- Source:
-
core/walletCore.js
-
-
Type:
- Source:
-
core/walletCore.js
-
-
Type:
- Source:
-
core/walletCore.js
-
-
Type:
- Source:
-
core/walletCore.js
-
promiseArray
-
Htlc locked time, unit: second
- Source:
-
core/walletCore.js
-
-
Type:
- Source:
-
core/walletCore.js
-
-
Type:
- Source:
-
core/walletCore.js
-
<constant> dbModel
-
model: {
user : [
{
chainID: string,
accounts : {
path : {
walletID : string
}
}
}
],
wallet : [
{
chain : string,
chainID: number,
rootPath: string,
lastScaned : {
account: number,
index : number
},
lastUsed : {
account : index,
}
}
],
mnemonic : [
{
id : number,
mnemonic : string,
exported : true|false
}
],
rawKey : [
{
chainID : chain,
count : number,
keys : {
}
}
],
keystore : [
{
chainID : chain,
keystores : {
}
}
]
}
- Source:
-
db/hdwalletdb.js
-
<constant> dbModel
-
model: {
"name" : "wanOTA",
"dbVersion" : "1.0.0",
"net": "",
"acctInfo" : [
{
"acctID" : ""
"scaned" : {
"begin" : 0,
"end" : 0
}
}
],
"usrOTA": [
{
"txhash" : "",
"toOTA" : "",
"toAcctID" : "",
"value" : 0,
"from" : "",
"blockNo" : 0,
"state" : "",
"timestamp": ""
}
],
"otaData": [
{
"hash" : "",
"blockNumber": "",
"to" : "",
"from" : "",
"input" : "",
}
]
}
- Source:
-
db/wanotadb.js
-
<constant> iWanClient
-
iWan RPC client
Liscensed under MIT license.
Copyright (c) 2019, Wanchain.
- Source:
-
sender/sendGroup/iWanRpc.js
-
srcChainKeyA
-
before stress test, need change srcChainKeyA (Token key)
- Source:
-
trans/test/test.js
-
<constant> crypto
-
Crypto
- Source:
-
util/util.js
-
<constant> BigNumber
-
- Source:
-
util/util.js
-
<constant> WID
-
Wallet
- Source:
-
util/util.js
-
_SDK__CONFIG
-
----------------------------------------------------------------------------
Configuration
----------------------------------------------------------------------------
- Source:
-
util/util.js
-
encodeTopic(type, param)
-
Should be used to encode plain param to topic
Parameters:
| Name |
Type |
Description |
type |
String
|
|
param |
Object
|
|
- Source:
-
api/ccUtil.js
Returns:
encoded plain param
-
Type
-
String
-
generatePrivateKey()
-
generate private key, in sdk , it is named x
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
string
-
getHashKey(key)
-
Build hashKey,in sdk it is named hashX
Parameters:
| Name |
Type |
Description |
key |
string
|
result of ccUtil#generatePrivateKey |
- Source:
-
api/ccUtil.js
Returns:
- in sdk ,it is named hashX
-
Type
-
string
-
createEthAddr(keyPassword)
-
Create Eth address
Parameters:
| Name |
Type |
Description |
keyPassword |
string
|
key password |
- Source:
-
api/ccUtil.js
Returns:
- eth address
-
Type
-
string
-
createWanAddr(keyPassword)
-
Create Wan address
Parameters:
| Name |
Type |
Description |
keyPassword |
string
|
key password |
- Source:
-
api/ccUtil.js
Returns:
- eth address
-
Type
-
string
-
isEthAddress(address)
-
isEthAddress
Parameters:
| Name |
Type |
Description |
address |
string
|
Eth address |
- Source:
-
api/ccUtil.js
Returns:
true: Eth address
false: Non Eth address
-
Type
-
boolean
-
isWanAddress(address)
-
isWanAddress
Parameters:
| Name |
Type |
Description |
address |
string
|
Eth address |
- Source:
-
api/ccUtil.js
Returns:
true: Wan address
false: Non Wan address
-
Type
-
boolean
-
getEthAccounts()
-
get all Eth accounts on local host
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
Array.<string>
-
getWanAccounts()
-
get all Wan accounts on local host
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
Array.<string>
-
<async> getEthAccountsInfo()
-
get all Eth accounts on local host
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
Promise.<Array>
-
<async> getWanAccountsInfo()
-
get all Wan accounts on local host
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
Promise.<Array>
-
getGWeiToWei(amount, exp)
-
Get GWei to Wei , used for gas price.
Parameters:
| Name |
Type |
Description |
amount |
|
|
exp |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
number
-
weiToToken(tokenWei, decimals)
-
weiToToken
Parameters:
| Name |
Type |
Description |
tokenWei |
number
|
|
decimals |
number
|
Must change 18 to the decimals for the actual decimal of token. |
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
string
-
tokenToWei(token, decimals)
-
tokenToWei
Parameters:
| Name |
Type |
Description |
token |
number
|
|
decimals |
number
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
string
-
tokenToWeiHex(token, decimals)
-
tokenToWeiHex
Parameters:
| Name |
Type |
Description |
token |
number
|
amount of token |
decimals |
number
|
the decimals of this token |
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
string
-
getDecimalByScAddr(contractAddr, chainType)
-
get the decimal of the token
Parameters:
| Name |
Type |
Description |
contractAddr |
string
|
the token's contract address |
chainType |
string
|
enum{'ETH', 'WAN','BTC'} |
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
number
-
calculateLocWanFee(value, coin2WanRatio, ctxFeeRatio)
-
When users cross tokens from WAN to others chain, here called outbound
sdk lock the return value, if users leave WAN chain, the return value
should be cost same as gas. if users lock token on WAN, NOT redeem on
destination chain, and revoke on WAN chain. It takes users a little part
return value like gas to avoid malicious cross chain transaction.
Parameters:
| Name |
Type |
Description |
value |
number
|
|
coin2WanRatio |
number
|
|
ctxFeeRatio |
number
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
string
-
getErc20Info(tokenScAddr, chainType)
-
Get ERC20 tokens symbol and decimals.
Parameters:
| Name |
Type |
Description |
tokenScAddr |
|
|
chainType |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
sendTransByWeb3(signedData)
-
Parameters:
| Name |
Type |
Description |
signedData |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
Promise.<any>
-
getDataByFuncInterface(abi, contractAddr, funcName, args)
-
Wrapper of stand web3 interface.
Parameters:
| Name |
Type |
Description |
abi |
|
|
contractAddr |
|
|
funcName |
|
|
args |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getPrivateKey(address, password, keystorePath)
-
Parameters:
| Name |
Type |
Description |
address |
|
|
password |
|
|
keystorePath |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
signFunc(trans, privateKey, TxClass)
-
It is used to sign transaction.
Parameters:
| Name |
Type |
Description |
trans |
|
|
privateKey |
|
|
TxClass |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
string
-
signEthByPrivateKey(trans, privateKey)
-
Parameters:
| Name |
Type |
Description |
trans |
|
|
privateKey |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
|
string
-
signWanByPrivateKey(trans, privateKey)
-
Parameters:
| Name |
Type |
Description |
trans |
|
|
privateKey |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
|
string
-
getSrcChainName()
-
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
Promise.<*>
-
getDstChainName(selectedSrcChainName)
-
Get the left
token info supported by system after users select source chain.
Parameters:
| Name |
Type |
Description |
selectedSrcChainName |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
Map.<string, Map.<string, Object>>
|
Map.<any, any>
-
getStoremanGroupList(srcChainName, dstChainName)
-
Get storeman group list for cross chain.(Source chain -> Destination chain)
Parameters:
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
Promise.<Array>
-
getSrcChainNameByContractAddr(contractAddr, chainType)
-
Get token info. in two layers MAP data structure.
Parameters:
| Name |
Type |
Description |
contractAddr |
|
|
chainType |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
Object
|
null
-
getKeyStorePaths(srcChainName, dstChainName)
-
getKeyStorePaths
Parameters:
| Name |
Type |
Description |
srcChainName |
|
|
dstChainName |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
Array
-
invokeCrossChain(srcChainName, dstChainName, action, input)
-
This function is used to finish cross chain.
Parameters:
| Name |
Type |
Description |
srcChainName |
|
source tokenInfo |
dstChainName |
|
destination tokenInfo |
action |
string
|
enum{APPROVE, LOCK, REDEEM, REVOKE} |
input |
Object
|
users input, see input example |
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
Promise.<*>
-
canRevoke(record)
-
This function is used to check whether the record(representing one transaction) can be revoked or not.
see comments of canRedeem
Parameters:
| Name |
Type |
Description |
record |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
Object
|
transUtil.retResult
|
Object
-
setInitNonceTest(initNonce)
-
Used to set initial nonce for Test Only.
Parameters:
| Name |
Type |
Description |
initNonce |
|
|
- Source:
-
api/ccUtil.js
-
getNonceTest()
-
Get nonce based on initial nonce for Test.
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
|
null
|
number
-
getCrossInvokerConfig(srcChainName, dstChainName)
-
Parameters:
| Name |
Type |
Description |
srcChainName |
|
source tokenInfo |
dstChainName |
|
destination tokenInfo |
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getCrossInvokerClass(crossInvokerConfig, action)
-
getCrossInvokerClass
Parameters:
| Name |
Type |
Description |
crossInvokerConfig |
|
see crossInvokerConfig |
action |
|
APPROVE,LOCK, REDEEM, REVOKE |
- Source:
-
api/ccUtil.js
Returns:
- instance of class CrossChain or sub class of CrossChain.
-
Type
-
CrossChain
|
*
-
getSrcChainDic()
-
get src chain dic. for end users to select source chain.
- Source:
-
api/ccUtil.js
Returns:
- sub collection{'ETH','BTC','WAN'}
-
Type
-
*
-
hiddenProperties(inputObj, properties)
-
Override properies' value to '*******'
Parameters:
| Name |
Type |
Description |
inputObj |
|
|
properties |
|
|
- Source:
-
api/ccUtil.js
-
hiddenProperties(inputObj, properties)
-
Override properies' value to '*******'
Parameters:
| Name |
Type |
Description |
inputObj |
|
|
properties |
|
|
- Source:
-
api/ccUtil.js
-
getTxReceipt(chainType, txhash)
-
Parameters:
| Name |
Type |
Description |
chainType |
|
|
txhash |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getTxInfo(chainType, txhash)
-
Parameters:
| Name |
Type |
Description |
chainType |
|
|
txhash |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getEthBalance(addr, chainType)
-
Get coin balance.
Parameters:
| Name |
Type |
Description |
addr |
|
|
chainType |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getMultiEthBalances(addrs, chainType)
-
Parameters:
| Name |
Type |
Description |
addrs |
|
|
chainType |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getBlockByNumber(blockNumber, chainType)
-
Parameters:
| Name |
Type |
Description |
blockNumber |
|
|
chainType |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getMultiTokenBalanceByTokenScAddr(addrs, tokenScAddr, chainType)
-
Get token balance by contract address and users addresses.
Parameters:
| Name |
Type |
Description |
addrs |
|
|
tokenScAddr |
|
|
chainType |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getRegErc20Tokens()
-
Get all ERC 20 tokens from API server. The return information include token's contract address
and the buddy contract address of the token.
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
syncErc20StoremanGroups(tokenScAddr)
-
Get all storemen groups which provide special token service, this token's address is tokenScAddr.
Parameters:
| Name |
Type |
Description |
tokenScAddr |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getNonce(addr, chainType, includePendingOrNot)
-
Parameters:
| Name |
Type |
Description |
addr |
|
|
chainType |
|
|
includePendingOrNot |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getToken2WanRatio(tokenOrigAddr, crossChain)
-
getToken2WanRatio
Parameters:
| Name |
Type |
Description |
tokenOrigAddr |
|
|
crossChain |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getErc20Allowance(tokenScAddr, ownerAddr, spenderAddr, chainType)
-
ERC standard function allowance.
Parameters:
| Name |
Type |
Description |
tokenScAddr |
|
|
ownerAddr |
|
|
spenderAddr |
|
|
chainType |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
waitConfirm(txHash, waitBlocks, chainType)
-
If return promise resolve, the transaction has been on the block chain.
else it fails to put transaction on the block chain.
Parameters:
| Name |
Type |
Description |
txHash |
|
|
waitBlocks |
|
|
chainType |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
sendTrans(signedData, chainType)
-
Parameters:
| Name |
Type |
Description |
signedData |
|
|
chainType |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getOutStgLockEvent(chainType, hashX)
-
Users lock on source chain, and wait the lock event of storeman on destination chain.
This function is used get the event of lock of storeman.(WAN->ETH coin)
Parameters:
| Name |
Type |
Description |
chainType |
|
|
hashX |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getInStgLockEvent(chainType, hashX)
-
Users lock on source chain, and wait the lock event of storeman on destination chain.
This function is used get the event of lock of storeman.(ETH->WAN coin)
Parameters:
| Name |
Type |
Description |
chainType |
|
|
hashX |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getOutStgLockEventE20(chainType, hashX)
-
Users lock on source chain, and wait the lock event of storeman on destination chain.
This function is used get the event of lock of storeman.(WAN->ETH ERC20 token)
Parameters:
| Name |
Type |
Description |
chainType |
|
|
hashX |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getInStgLockEventE20(chainType, hashX)
-
Users lock on source chain, and wait the lock event of storeman on destination chain.
This function is used get the event of lock of storeman.(ETH->WAN ERC20 token)
Parameters:
| Name |
Type |
Description |
chainType |
|
|
hashX |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getEthLockTime(chainType)
-
Get HTLC locked time, unit seconds.
Parameters:
| Name |
Type |
Description |
chainType |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getE20LockTime(chainType)
-
Get HTLC locked time, unit seconds. (ERC20)
Parameters:
| Name |
Type |
Description |
chainType |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getE20RevokeFeeRatio(chainType)
-
For outbound (from WAN to other chain), when users redeem on other chain, it means that user leave WAN chain.
It takes users wan for leave chain.
If users revoke on WAN chain, it means that users keep on WAN chain.On this scenario, it takes users part wan for revoke transaction. The part is related to the return ratio of this function.
Parameters:
| Name |
Type |
Description |
chainType |
|
|
- Source:
-
api/ccUtil.js
Returns:
-
Type
-
*
-
getMac(:, :)
-
Parameters:
| Name |
Type |
Description |
: |
key
|
buffer, length must greater than 32. |
: |
msg
|
buffer |
- Source:
-
api/hdUtil.js
Returns:
-
Type
-
buffer
-
_initPOSParam()
-
TODO: just for mainnet test
- Source:
-
conf/config.js
-
migrateBTCWallet()
-
- Source:
-
db/upgrade/upgrade.js
-
importBTCHistroyTx()
-
- Source:
-
db/upgrade/upgrade.js
-
createBTCAddress(keyPassword)
-
Create a BTC address and insert into wallet
Parameters:
| Name |
Type |
Description |
keyPassword |
string
|
key password |
- Source:
-
api/btcUtil.js
Returns:
- eth address
-
Type
-
string
-
promiseTimeout()
-
Promise with timeout
- Source:
-
util/util.js
-
createHash(msg, algo)
-
Create hash
Parameters:
| Name |
Type |
Description |
msg |
msg
|
the message to hash |
algo |
algo
|
the HASH algorithm to use |
- Source:
-
util/util.js
Returns:
- digest of hashed message
-
Type
-
string
-
createHashN(msg, n)
-
Create hash with N times
Parameters:
| Name |
Type |
Description |
msg |
msg
|
the message to hash |
n |
algo
|
the HASH algorithm to use |
- Source:
-
util/util.js
Returns:
- digest of hashed message
-
Type
-
string
-
decrypt(key, iv, crypted)
-
Decrypt method
Parameters:
| Name |
Type |
Description |
key |
key
|
The raw key for decipher algorithm, the length is different from algo, refer encrypt for detail. |
iv |
iv
|
Initialized vector |
crypted |
crypted
|
the crypted data to be decrypted |
- Source:
-
util/util.js
Returns:
- decrypted string
-
Type
-
string
-
sec256k1PrivToPub()
-
- Source:
-
util/util.js
-
getLogger()
-
Get a logger for request module
- Source:
-
util/util.js
-
getConfigSetting()
-
Get configuration item specified by 'name'
- Source:
-
util/util.js
-
setConfigSetting()
-
Set config item 'name' to 'value'
- Source:
-
util/util.js
-
isOnMainNet()
-
- Source:
-
util/util.js
-
splitBip44Path(string,)
-
Split BIP44 path m/44'/chainID/...
Parameters:
| Name |
Type |
Description |
string, |
path
|
bip44 path |
- Source:
-
util/util.js
Returns:
, array of number, which each is number in level
-
Type
-
Array
-
hiddenProperties(inputObj, properties)
-
Override properies' value to '*******'
Parameters:
| Name |
Type |
Description |
inputObj |
|
|
properties |
|
|
- Source:
-
util/util.js
-
toBigNumber()
-
Deprecated!!!
- Source:
-
util/util.js
-
constructWalletOpt(boolean)
-
Parameters:
| Name |
Type |
Description |
boolean |
check
|
force check or not |
- Source:
-
util/util.js
-
compositeWalletKey(number, string)
-
Composite key for wallet refered by (wid, path)
Parameters:
| Name |
Type |
Description |
number |
wid
|
wallet ID |
string |
path
|
BIP44 path |
- Source:
-
util/util.js
Returns:
-
Type
-
string
-
decompositeWalletKey(string)
-
Decomposite key to (wid, path)
Parameters:
| Name |
Type |
Description |
string |
value
|
value returned by compositeWalletKey |
- Source:
-
util/util.js
Returns:
- array[0] is wallet ID, array[1] is bip44 path
-
Type
-
array
-
addBIP44Param()
-
Add BIP44 path into object for sign
- Source:
-
util/util.js
-
_getConfig()
-
Get nconf
- Source:
-
util/util.js
-
_newDefaultLogger()
-
- Source:
-
util/util.js
-
encodeParam()
-
- Source:
-
util/web3util.js
-
toWei()
-
- Source:
-
util/web3util.js
-
getDataByFuncInterface(Array, string, string, args)
-
Get encoded data for specified solidity function call
Parameters:
| Name |
Type |
Description |
Array |
abi
|
Solidity ABI |
string |
addr
|
address |
string |
func
|
name of function to be called |
args |
args
|
|
- Source:
-
util/web3util.js
Returns:
- ecoded data for function call
-
Type
-
string
-
getFullName()
-
- Source:
-
util/web3util.js
-
decodeEventLog(--, --)
-
Decode log
Parameters:
| Name |
Type |
Description |
-- |
json
|
ABI of the function |
-- |
log
|
event log |
- Source:
-
util/web3util.js
-
signFunction(JSON)
-
Sign solidity function/event
Parameters:
| Name |
Type |
Description |
JSON |
json
|
object -- ABI |
- Source:
-
util/web3util.js
Returns:
signature of function
-
Type
-
string
-
getMethodABIDefine()
-
- Source:
-
util/web3util.js