Description
API Methods
getnewaccount
Generate a new account from this wallet.
- Parameters (optional)
-l
or[--language]
Options are ‘en’, ‘es’, ‘ja’, ‘zh_Hans’, ‘zh_Hant’ and ‘any’, defaults to ‘en’.
- Parameters (positional)
ACCOUNTNAME
Account name.ACCOUNTAUTH
Account password/authorization.params:[
"ACCOUNTNAME",
"ACCOUNTAUTH"
]
- Returns
Object
-
mnemonic
- the master private key of your accountdefault-address
- address of the account
- Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"getnewaccount",
"params":["test", "123456", {"language": "en"}],"id":7}'
// Response
{
"jsonrpc": "2.0",
"id": 7,
"result": {
"mnemonic": "actor slam shove essence person between lucky harsh myself hole tomorrow sausage buddy young kitten motor traffic rare wisdom month payment drill vanish oval",
"default-address": "MDtdyESeZB73RCYR1G4b7443ModzGwYWrF"
}
}
getnewaddress
Generate new address for this account.
- Parameters (optional)
-n
or[--number]
The address count.
- Parameters (positional)
ACCOUNTNAME
Account name.ACCOUNTAUTH
Account password/authorization.params:[
"ACCOUNTNAME",
"ACCOUNTAUTH"
]
Returns
Array
- return a list of new addressExample
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"getnewaddress",
"params":["test", "123456", {"number": 2}],"id":8}'
// Response
{
"jsonrpc": "2.0",
"id": 8,
"result": [
"MM6VxRZ9b1GzbapkVCnWwqo3gbe5sDgf9G",
"MDuwgNWVp4rHGLcDRro7joees9Z75s9o9X"
]
}
listaddresses
List available addresses of this account.
- Parameters (positional)
ACCOUNTNAME
Account name.ACCOUNTAUTH
Account password/authorization.params:[
"ACCOUNTNAME",
"ACCOUNTAUTH"
]
Returns
Array
- return the list of generated addressExample
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"listaddresses",
"params":["test", "123456"],"id":11}'
// Response
{
"jsonrpc": "2.0",
"id": 11,
"result": [
"MBVDxEdhpyA1SvAnFhRxuUmsh5TsaURieV",
"MEhwjsxeqVwPzWFqxzAPcFqnh3HSdgUuS2"
]
}
validateaddress
validate address
- Parameters (positional)
ADDRESS
addressparams:[
"ADDRESS"
]
- Returns
Object
-
address-type
- address typeis-valid
- the address is valid or notmessage
- message like “valid address”test-net
- if the address is in test-net
- Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"validateaddress",
"params":["MEhwjsxeqVwPzWFqxzAPcFqnh3HSdgUuS2"],"id":16}'
// Response
{
"jsonrpc": "2.0",
"id": 16,
"result":
{
"address-type" : "p2kh(test-net)",
"is-valid" : true,
"message" : "valid address ",
"test-net" : true
}
}
importaccount
importaccount
- Parameters (optional)
-i
or[--hd_index]
Teh HD index for the account.-l
or[--language]
The language identifier of the dictionary of the mnemonic. Options are ‘en’, ‘es’, ‘ja’, ‘zh_Hans’, ‘zh_Hant’ and ‘any’, defaults to ‘any’.-n
or[--accountname]
Account name.-p
or[--password]
Account password.
- Parameters (positional)
WORD
The set of words that that make up the mnemonic. If not specified the words are read from STDIN.params:[
"WORD"
]
- Returns
Object
-
name
- account name.mnemonic
- master private keyhd_index
- how many addresses generated.address
- address list
- Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"importaccount",
"params":["mother ride despair impose degree truck pet scrub mind art brain galaxy sadness cover crater waste arrest invest hip crush loan brisk pave cheap",
{"accountname":"test","password":"123456","hd_index":3,"language":"en"}],"id":9}'
// Response
{
"jsonrpc": "2.0",
"id": 9,
"result": {
"mnemonic": "mother ride despair impose degree truck pet scrub mind art brain galaxy sadness cover crater waste arrest invest hip crush loan brisk pave cheap",
"addresses": [
"MBVDxEdhpyA1SvAnFhRxuUmsh5TsaURieV",
"MEhwjsxeqVwPzWFqxzAPcFqnh3HSdgUuS2",
"MS9m8zpVPkDYAXhmeHmhE3TgJugP3zHtAL"
],
"name": "test",
"hd_index": 3
}
}
importkeyfile
import account from file
- Parameters (positional)
FILE
account info fileparams:[
"FILE"
]
- Returns
Object
-
name
- account nameaddress-count
- address count generatedunissued-asset-count
- unissued asset count
- Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"importkeyfile",
"params":["~/.metaverse/mvs-test.keystore"],"id":10}'
// Response
{
"jsonrpc": "2.0",
"id": 10,
"result": {
"unissued-asset-count": "0",
"name": "test",
"address-count": "2"
}
}
dumpkeyfile
export account as file, file name is
mvs-$accountname.keystore
.- Parameters (positional)
ACCOUNTNAME
Account name.ACCOUNTAUTH
Account password/authorization.LASTWORD
The last word of your master private-key phrase.DESTINATION
account info storage file directory, optional, default to ~/.metaverse/mvs-htmls/keys/params:[
"ACCOUNTNAME",
"ACCOUNTAUTH",
"LASTWORD",
"DESTINATION"
]
Returns
String
-Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"dumpkeyfile",
"params":["test", "123456", "lastword", "~/.metaverse/"],"id":4}'
// Response
{
"jsonrpc": "2.0",
"id": 4,
"result": "~/.metaverse/mvs-test.keystore"
}
changepasswd
changepasswd
- Parameters (optional)
-p
or[--password]
New password/authorization.
- Parameters (positional)
ACCOUNTNAME
Account name.ACCOUNTAUTH
Account password/authorization.params:[
"ACCOUNTNAME",
"ACCOUNTAUTH"
]
- Returns
Object
-
name
- account namestatus
- operation status
- Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"changepasswd",
"params":["test", "123456", {"password": "test123456"}],"id":1}'
// Response
{
"jsonrpc": "2.0",
"id": 1,
"result":
{
"name": "test",
"status": "password changed"
}
}
deleteaccount
deleteaccount
- Parameters (positional)
ACCOUNTNAME
Account name.ACCOUNTAUTH
Account password/authorization.LASTWORD
The last word of your private-key phrase.params:[
"ACCOUNTNAME",
"ACCOUNTAUTH",
"LASTWORD"
]
- Returns
Object
-
name
- account namestatus
- operation status
- Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"deleteaccount",
"params":["test", "123456", "lastword"],"id":2}'
// Response
{
"jsonrpc": "2.0",
"id": 2,
"result":
{
"name": "test",
"status": "removed successfully"
}
}
getaccount
Show account details
- Parameters (positional)
ACCOUNTNAME
Account name.ACCOUNTAUTH
Account password/authorization.LASTWORD
The last word of your master private-key phrase.params:[
"ACCOUNTNAME",
"ACCOUNTAUTH",
"LASTWORD"
]
- Returns
Object
-
name
- account namemnemonic-key
- master private keyaddress-count
- addresses createduser-status
- 0:locked, 2: normal
- Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"getaccount",
"params":["test", "123456", "lastword"],"id":5}'
// Response
{
"jsonrpc": "2.0",
"id": 5,
"result": {
"user-status": "2",
"name": "test",
"mnemonic-key": "mother ride despair impose degree truck pet scrub mind art brain galaxy sadness cover crater waste arrest invest hip crush loan brisk pave cheap",
"address-count": "2"
}
}
getpublickey
Show public key of address
- Parameters (positional)
ACCOUNTNAME
Account name.ACCOUNTAUTH
Account password/authorization.ADDRESS
Address.params:[
"ACCOUNTNAME",
"ACCOUNTAUTH",
"ADDRESS"
]
Returns
Object
- stringExample
`
js
// Request
curl -X POST –data ‘{
“jsonrpc”:”2.0”,
“method”:”getpublickey”,
“id”:5,
“params”:["test", "123456", "MLTxV5JAu5sFhQmJYNRmPuu31CkNWrF5rj"
]
}’ http://127.0.0.1:8820/rpc/v2// Response
{
“id” : 5,
“jsonrpc” : “2.0”,
“result” :
{"address" : "MLTxV5JAu5sFhQmJYNRmPuu31CkNWrF5rj", "public-key" : "031c7ac7f12a05ea4952289801fa52142aa421f11efe8ab7090fb823562156a321"
}
}`
***