Description
API Methods
getnewaccountGenerate a new account from this wallet if account is specified.
Generate a new address and private key if account is not specified.- Parameters (optional)
-lor[--language]Options are ‘en’, ‘es’, ‘ja’, ‘zh_Hans’, ‘zh_Hant’ and ‘any’, defaults to ‘en’.
- Parameters (positional)
ACCOUNTNAMEAccount name, default “”.ACCOUNTAUTHAccount password/authorization, default “”.params:[
"ACCOUNTNAME",
"ACCOUNTAUTH"
]
- Returns
Object-
mnemonic- the master private key of your accountdefault_address- address of the account
- Example: generate a new account
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"getnewaccount",
"params":["test", "123456", {"language": "en"}],"id":7}' http://127.0.0.1:8820/rpc/v3
// Response
{
"jsonrpc" : "2.0",
"id": 7,
"result": {
"name": "test",
"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",
"addresses":
[
"MDtdyESeZB73RCYR1G4b7443ModzGwYWrF"
]
}
}
* Example: generate a new address and private key.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"getnewaccount",
"params":[{"language": "en"}],"id":7}' http://127.0.0.1:8820/rpc/v3
// Response
{
"id" : 7,
"jsonrpc" : "2.0",
"result" :
{
"address" : "MLycTCqV9BiQrfnRPxi6AFBLC7m1cG6btQ",
"mnemonic" : "deal elite opinion exhaust shop usage habit hard muscle glimpse want matter brain shoot uncle insect corn glare depth asthma move input person pill",
"private_key" : "76fb26353250f00529c51362411a517b4d005d72fe33e5ccea28eaab3b33f8ac",
"public_key" : "03643ceeab22462641c5259bfcb7a7898b23b9fbbf5360eb35b3df86eba24522c9",
"wif" : "L1CzdkB3f2gRS2NtZUe2fGubzGMYZAWPqbyXNiKC7c9w9Z6F6gHC"
}
}
getnewaddressGenerate new address for this account.
- Parameters (optional)
-nor[--number]The address count.
- Parameters (positional)
ACCOUNTNAMEAccount name.ACCOUNTAUTHAccount 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}' http://127.0.0.1:8820/rpc/v3
// Response
{
"jsonrpc" : "2.0",
"id": 8,
"result": [
"MM6VxRZ9b1GzbapkVCnWwqo3gbe5sDgf9G",
"MDuwgNWVp4rHGLcDRro7joees9Z75s9o9X"
]
}
listaddressesList available addresses of this account.
- Parameters (positional)
ACCOUNTNAMEAccount name.ACCOUNTAUTHAccount 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}' http://127.0.0.1:8820/rpc/v3
// Response
{
"jsonrpc" : "2.0",
"id": 11,
"result": [
"MBVDxEdhpyA1SvAnFhRxuUmsh5TsaURieV",
"MEhwjsxeqVwPzWFqxzAPcFqnh3HSdgUuS2"
]
}
validateaddressvalidate address
- Parameters (positional)
ADDRESSaddressparams:[
"ADDRESS"
]
- Returns
Object-
address_type- address typeis_valid- the address is valid or notmessage- message like “valid address”testnet- if the address is in test-net
- Example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"validateaddress",
"params":["MEhwjsxeqVwPzWFqxzAPcFqnh3HSdgUuS2"],"id":16}' http://127.0.0.1:8820/rpc/v3
// Response
{
"jsonrpc" : "2.0",
"id": 16,
"result":
{
"address_type" : "p2kh(test-net)",
"is_valid" : true,
"message" : "valid address ",
"testnet" : true
}
}
importaccountimportaccount
- Parameters (optional)
-ior[--hd_index]Teh HD index for the account.-lor[--language]The language identifier of the dictionary of the mnemonic. Options are ‘en’, ‘es’, ‘ja’, ‘zh_Hans’, ‘zh_Hant’ and ‘any’, defaults to ‘any’.-nor[--accountname]Account name.-por[--password]Account password.
- Parameters (positional)
WORDThe 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 keyaddresses- 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}' http://127.0.0.1:8820/rpc/v3
// 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"
}
}
importkeyfileimport account from file
- Parameters (positional)
ACCOUNTNAMEAccount name.ACCOUNTAUTHAccount password/authorization. This is also used to decrypt the keyfile.FILEkey file path.FILECONTENTkey file content. This will omit theFILEargument if specified.params:[
"ACCOUNTNAME",
"ACCOUNTAUTH",
"FILE",
"FILECONTENT"
]
Returns
null-Example
// import key file by file path
curl -X POST --data '{"jsonrpc":"2.0","method":"importkeyfile",
"params":["test", "123456", "~/.metaverse/mvs-test.json"],"id":10}' http://127.0.0.1:8820/rpc/v3
// Response
{
"jsonrpc" : "2.0",
"id": 10,
"result": null
}
dumpkeyfileexport account as file, file name is
mvs_keystore_$accountname.json.- Parameters (positional)
ACCOUNTNAMEAccount name.ACCOUNTAUTHAccount password/authorization. This is also used to encrypt the keyfile.LASTWORDThe last word of your master private-key phrase.DESTINATIONaccount 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}' http://127.0.0.1:8820/rpc/v3
// Response
{
"jsonrpc" : "2.0",
"id": 4,
"result": "~/.metaverse/mvs_keystore_test.json"
}
changepasswdchangepasswd
- Parameters (optional)
-por[--password]New password/authorization.
- Parameters (positional)
ACCOUNTNAMEAccount name.ACCOUNTAUTHAccount 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}' http://127.0.0.1:8820/rpc/v3
// Response
{
"jsonrpc" : "2.0",
"id": 1,
"result":
{
"name": "test",
"status": "changed successfully"
}
}
deleteaccountdeleteaccount
- Parameters (positional)
ACCOUNTNAMEAccount name.ACCOUNTAUTHAccount password/authorization.LASTWORDThe 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}' http://127.0.0.1:8820/rpc/v3
// Response
{
"jsonrpc" : "2.0",
"id": 2,
"result":
{
"name": "test",
"status": "removed successfully"
}
}
getaccountShow account details
- Parameters (positional)
ACCOUNTNAMEAccount name.ACCOUNTAUTHAccount password/authorization.LASTWORDThe last word of your master private-key phrase.params:[
"ACCOUNTNAME",
"ACCOUNTAUTH",
"LASTWORD"
]
- Returns
Object-
name- account namemnemonic- 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}' http://127.0.0.1:8820/rpc/v3
// Response
{
"jsonrpc" : "2.0",
"id": 5,
"result": {
"name": "test",
"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",
"address_count": "2"
}
}
getpublickeyShow public key of address
If wallet version >= 0.9.0, the ADDRESS paramenter can be Did/Address/Publickey/PrivateKey(WIF).- Parameters (positional)
ACCOUNTNAMEAccount name.ACCOUNTAUTHAccount password/authorization.ADDRESSAddress.params:[
"ACCOUNTNAME",
"ACCOUNTAUTH",
"ADDRESS"
]
Returns
Object- stringExample
// 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"
}
}