-
Notifications
You must be signed in to change notification settings - Fork 0
API : Account
王辰 edited this page Jan 6, 2020
·
3 revisions
- getCryptoByPwd
- dumpAddrFromPrivKey
- dumpPubKeyFromPrivKey
- dumpCryptoFromPrivKey
- dumpPubKeyHashFromPrivKey
- dumpPubKeyHashFromAddr
- dumpPrivKeyFromCrypto
Create an account
* password <string>
private-key <string>
key-store <object>
{
P2PKH: privK.privKey.toP2PKHAddress,
P2SH: privK.privKey.toP2SHAddress,
privateKey,
cryptoJSON
}
// Create an account by password
await boxdjs.Account.getCryptoByPwd('box1234')
// Import an account by (password + private-key)
await boxdjs.Account.getCryptoByPwd(
'box1234',
'40b5608b183efc7b1940d09d29cc49c9ebbdaf8fb7d43e0dc079f56025ed6a4b'
)
// Import an account by (password + key-store)
await boxdjs.Account.getCryptoByPwd(
'box1234',
await boxdjs.Account.dumpPrivKeyFromCrypto(<key-store>, 'box1234')
)Dump P2PKH-address from private-key
* private-key <string | Buffer>
P2PKH-address <string>
await boxdjs.Account.dumpAddrFromPrivKey('40b5608b183efc7b1940d09d29cc49c9ebbdaf8fb7d43e0dc079f56025ed6a4b')
await boxdjs.Account.dumpAddrFromPrivKey(Buffer.from('40b5608b183efc7b1940d09d29cc49c9ebbdaf8fb7d43e0dc079f56025ed6a4b', 'hex'))Dump public-key from private-key
* private-key <string | Buffer>
public-key <string>
await boxdjs.Account.dumpPubKeyFromPrivKey('40b5608b183efc7b1940d09d29cc49c9ebbdaf8fb7d43e0dc079f56025ed6a4b')
await boxdjs.Account.dumpPubKeyFromPrivKey(Buffer.from('40b5608b183efc7b1940d09d29cc49c9ebbdaf8fb7d43e0dc079f56025ed6a4b', 'hex'))Dump crypto-json from (private-key + password)
* private-key <string | Buffer>
* password <string>
crypto-json <object>
await boxdjs.Account.dumpCryptoFromPrivKey('40b5608b183efc7b1940d09d29cc49c9ebbdaf8fb7d43e0dc079f56025ed6a4b', 'box1234')
await boxdjs.Account.dumpCryptoFromPrivKey(Buffer.from('40b5608b183efc7b1940d09d29cc49c9ebbdaf8fb7d43e0dc079f56025ed6a4b', 'hex'), 'box1234')Dump public-key-hash from private-key
* private-key <string | Buffer>
public-key-hash <string>
await boxdjs.Account.dumpPubKeyHashFromPrivKey('40b5608b183efc7b1940d09d29cc49c9ebbdaf8fb7d43e0dc079f56025ed6a4b')
await boxdjs.Account.dumpPubKeyHashFromPrivKey(Buffer.from('40b5608b183efc7b1940d09d29cc49c9ebbdaf8fb7d43e0dc079f56025ed6a4b', 'hex'))Dump public-key-hash from P2PKH-address
* P2PKH-address <string>
public-key-hash <string>
await boxdjs.Account.dumpPubKeyHashFromAddr('b1cRrJ9rhksTgaawpJ8B4sANUUMLGgCmsVA')Dump private-key from (private-key+password)
* key-store <object>
* password <string>
private-key <string>
await boxdjs.Account.dumpPrivKeyFromCrypto(<key-store>, 'box1234')By Contentbox