Address & XPUB
You can get address of account using
getAddress()
function.var coinType = DcentWebConnector.coinType.ETHEREUM
var keyPath = "m/44'/60'/0'/0/0" // key path of the account
var result
try{
// Get Ethereum Address corresponding to keyPath
result = await DcentWebConnector.getAddress(coinType, keyPath)
}catch(e){
result = e
}
Returned response object has:
{
"header": {
"version": "1.0",
"response_from": "ethereum",
"status": "success"
},
"body": {
"command": "get_address",
"parameter": {
"address": "0x354609C4c9a15d4265cF6D94010568D5Cf4d0c1B"
}
}
}
The address string format is depend on the coin type.
You can get xpub using
getXPUB()
function. The BIP32 key path must be at least 2 depth or more.var keyPath = "m/44'/0'" // key path of the account
var result
try{
// Get extended public key corresponding to keyPath
result = await DcentWebConnector.getXPUB(keyPath)
}catch(e){
result = e
}
Returned response object has:
{
"header": {
"version": "1.0",
"response_from": "coin",
"status": "success"
},
"body": {
"command": "xpub",
"parameter": {
"public_key": "xpub6Bp87egy.....EdAH4sMeqY3"
}
}
}
The public_key is xpub value.
Show you address list and you can select an address using
selectAddress()
function.var result
try{
// Get extended public key corresponding to keyPath
let addresses = [
{
address: '0x1234567812345678123456781234567812345678',
path: `m'/44'/60'/0'/0/0`
},
{
address: '0xabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd',
path: `m'/44'/8217'/0'/0/0`
}
]
result = await DcentWebConnector.selectAddress(addresses)
}catch(e){
result = e
}
Returned response object has:
{
"header": {
"version": "1.0",
"response_from": "bridge",
"status": "success"
},
"body": {
"command": "select_address",
"parameter": {
"selected_index": 0,
"selected_address": {
"address": "0x1234567812345678123456781234567812345678",
"path": "m'/44'/60'/0'/0/0"
}
}
}
}
The 'selectedIndex' is index of addresses array.
Last modified 4mo ago