-
Notifications
You must be signed in to change notification settings - Fork 66
Simplewallet JSON RPC API
To start wallet JSON RPC API server you should specify a port on which server binds (additionally to standard wallet's arguments). You can choose any free port. To do that execute the following command from the command line:
simplewallet --wallet-file=example_wallet.bin --pass=12345 --rpc-bind-port=32348
Having done that you're ready to operate with the wallet through the following API URLs (e.g., your IP address is 95.46.98.64):
http://95.46.98.64:32348/json_rpc
http://localhost:32348/json_rpc
- getbalance
- transfer
- store
- reset
- get_payments
- get_transfers
- get_height
- get_transaction
- get_address
- get_paymentid
- get_tx_key
- query_key
- sign_message
- verify_message
- change_password
- estimate_fusion
- send_fusion
Please note, there is no "refresh" RPC method. RPC wallet refresh is performed automatically each 20 seconds.
Return balance.
URL:
/json_rpc
Input:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Karbowanec wallet api",
"description": "Schema for transfer method in Karbowanec wallet",
"type": "object",
"properties" : {
"jsonrpc" : {
"type" : "string"
},
"method" : {
"type" : "string"
}
}
}
Output:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Karbowanec wallet api",
"description": "Schema for transfer method in Karbowanec wallet",
"type": "object",
"properties" : {
"locked_amount" : {
"type" : "integer"
},
"available_balance" : {
"type" : "integer"
}
}
}
Transfer money to several destinations with specified fee, mixin ambiguity degree, and unlock time.
Please note: fee param is a mandatory and should not be less than current minimal fee which can be obtained from node.
URL:
/json_rpc
Input:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Karbowanec wallet api",
"description": "Schema for transfer method in Karbowanec wallet",
"type": "object",
"properties" : {
"jsonrpc" : {
"type" : "string"
},
"method" : {
"type" : "string"
},
"destinations" : {
"type" : "array",
"items" : {
"amount" : {
"type" : "integer"
},
"address" : {
"type" : "string"
}
},
"minItems" : 1
},
"payment_id": {
"type" : "string"
}
"fee" : {
"type" : "integer"
},
"mixin" : {
"type" : "integer"
},
"unlock_time" : {
"type" : "integer"
"description" : "Unix timestamp"
}
}
}
Output:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Karbowanec wallet api",
"description": "Schema for transfer method in Karbowanec wallet",
"type": "object",
"properties" : {
"tx_hash" : {
"type" : "string"
},
"tx_key" : {
"type" : "string"
},
}
}
Store wallet data.
URL:
/json_rpc
Input:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Karbowanec wallet api",
"description": "Schema for transfer method in Karbowanec wallet",
"type": "object",
"properties" : {
"jsonrpc" : {
"type" : "string"
},
"method" : {
"type" : "string"
}
}
}
Output:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Karbowanec wallet api",
"description": "Schema for transfer method in Karbowanec wallet",
"type": "object",
"properties" : {}
}
Erases simplewallet's internal state but keeps safe the wallet.bin. The method should be used to re-synchronize the wallet from scratch. The next refresh (which is automatically called each 20 seconds) will update the simplewallet state.
URL:
/json_rpc
Input:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Karbowanec wallet api",
"description": "Schema for transfer method in Karbowanec wallet",
"type": "object",
"properties" : {
"jsonrpc" : {
"type" : "string"
},
"method" : {
"type" : "string"
}
}
}
Output:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Karbowanec wallet api",
"description": "Schema for transfer method in Karbowanec wallet",
"type": "object",
"properties" : {}
}
Receives all the payments with a corresponding payment_id that were sent to the wallet. This method is used to get the BCN payments for the 3rd party services. As Karbowanec uses only one address to receive BCN deposits, a unique payment_id should be assigned and shown to each user. The method will return all the payments for this user.
URL:
/json_rpc
Input:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Karbowanec wallet api",
"description": "Schema for transfer method in Karbowanec wallet",
"type": "object",
"properties" : {
"jsonrpc" : {
"type" : "string"
},
"method" : {
"type" : "string"
},
"payment_id" : {
"type" : "string"
}
}
}
Output:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Karbowanec wallet api",
"description": "Schema for transfer method in Karbowanec wallet",
"type": "object",
"properties" : {
"payments" : {
"type" : "array",
"items" : {
"amount" : {
"type" : "integer"
},
"block_height" : {
"type" : "integer"
},
"tx_hash" : {
"type" : "string"
},
"unlock_time" : {
"type" : "integer"
}
}
}
}
}
Returns the list of all the wallet's incoming and outgoing transfers. This data is available starting from v.1.0.2 build. For the transfers created by simplewallet of previous versions this method returns not exact transfers amounts but the transaction amounts (transfer amount + change).
URL:
/json_rpc
Input:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Karbowanec wallet api",
"description": "Schema for transfer method in Karbowanec wallet",
"type": "object",
"properties" : {
"jsonrpc" : {
"type" : "string"
},
"method" : {
"type" : "string"
}
}
}
Output:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Karbowanec wallet api",
"description": "Schema for transfer method in Karbowanec wallet",
"type": "object",
"properties" : {
"result" : {
"type" : "transfers"
"transfers" : {
"type" : "array",
"items" : {
"address" : {
"type" : "string"
},
"amount" : {
"type" : "integer"
},
"blockIndex" : {
"type" : "integer"
},
"fee" : {
"type" : "integer"
},
"output" : {
"type" : "boolean"
},
"paymentId" : {
"type" : "string"
},
"time" : {
"type" : "integer"
},
"transactionHash" : {
"type" : "string"
},
"unlockTime" : {
"type" : "integer"
},
}
}
}
}
}
Returns the last top known block height for simplewallet. This method can be used to verify that simplewallet is correctly synchronized.
URL:
/json_rpc
Input:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Karbowanec wallet api",
"description": "Schema for transfer method in Karbowanec wallet",
"type": "object",
"properties" : {
"jsonrpc" : {
"type" : "string"
},
"method" : {
"type" : "string"
}
}
}
Output:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Karbowanec wallet api",
"description": "Schema for transfer method in Karbowanec wallet",
"type": "object",
"properties" : {
"height" : {
"type" : "integer"
}
}
}
Returns the transaction details.
URL:
/json_rpc
Input example:
{
"jsonrpc":"2.0",
"id":"test",
"method":"get_transaction",
"params":{
"tx_hash":"f86ef58c98c724c2261f3eb009b47e475472f75d3b4b2ff0fc749d607367090d"
}
}
Output example:
{
"id":"test",
"jsonrpc":"2.0",
"result":{
"destinations":[
{
"address":"Kcwr4Awjn7QefxbAEvHSAcTrVbhzYukfmbDvwWkrDhjFXe1FVUj5ggxCrEv4w2zv6iVZgoF4v7b3cNAbaU3LKQGS9EU9KAd",
"amount":2010542676062
},
{
"address":"Kdev1L9V5ow3cdKNqDpLcFFxZCqu5W2GE9xMKewsB2pUXWxcXvJaUWHcSrHuZw91eYfQFzRtGfTemReSSMN4kE445i6Etb3",
"amount":57000000000
}
],
"transaction_details":{
"address":"Kcwr4Awjn7QefxbAEvHSAcTrVbhzYukfmbDvwWkrDhjFXe1FVUj5ggxCrEv4w2zv6iVZgoF4v7b3cNAbaU3LKQGS9EU9KAd",
"amount":2124542676062,
"blockIndex":271652,
"confirmations":25433,
"fee":57000000000,
"output":true,
"paymentId":"",
"time":1536706367,
"transactionHash":"f86ef58c98c724c2261f3eb009b47e475472f75d3b4b2ff0fc749d607367090d",
"txKey":"01f0eede5679da2c9cfcd06fb1961d64316e0d4dc54a308247319cb25220bf9503",
"unlockTime":0
}
}
}
Returns the wallet's public address.
URL:
/json_rpc
Input example:
{
"jsonrpc":"2.0",
"id":"test",
"method":"get_address",
"params":{
}
}
Output example:
{
"id":"test",
"jsonrpc":"2.0",
"result":{
"address":"KaqCQAbx3BSKKv7ED98oQP9QSP3igqgo47hPYZ8q6KZyUY6GnDaQkh9WbVR4DxvmCq8mZcKPg3wfWFJQ5CsyrxPqKcXC3rx"
}
}
Returns the new randomly generated Payment ID.
URL:
/json_rpc
Input example:
{
"jsonrpc":"2.0",
"id":"test",
"method":"get_paymentid",
"params":{
}
}
Output example:
{
"id":"test",
"jsonrpc":"2.0",
"result":{
"payment_id":"f373ff6def6499f7984d448808f5f24221fc690c231b76e6916b4c00cffe439b"
}
}
Returns the transaction's secret key if it is stored in wallet's cache; which can be used to prove that you paid the receiver. The transaction ID and the receiver's public address are also needed as a parameter.
URL:
/json_rpc
Input example:
{
"jsonrpc": "2.0",
"id": "test",
"method": "get_tx_key",
"params": {
"tx_hash": "F86EF58C98C724C2261F3EB009B47E475472F75D3B4B2FF0FC749D607367090D"
}
}
Output example:
{
"id":"test",
"jsonrpc":"2.0",
"result":{
"tx_key":"f0eede5679da2c9cfcd06fb1961d64316e0d4dc54a308247319cb25220bf9503"
}
}
Returns the wallets private keys. Key type should be passed in params. Available key types: paperwallet
and mnemonic
.
URL:
/json_rpc
Input example:
{
"jsonrpc": "2.0",
"id": "test",
"method": "query_key",
"params": {
"key_type": "mnemonic"
}
}
Error output example:
{
"error":{
"code":-1,
"message":"The wallet is non-deterministic. Cannot display seed."
},
"id":"test",
"jsonrpc":"2.0"
}
Output example:
{
"id":"test",
"jsonrpc":"2.0",
"result":{
"key":"KaqCQ..."
}
}
Returns the fusion ready outputs count. Parameter threshold
should be passed with threshold amount to optimize. If it is not passed it will estimate with default dust threshold.
URL:
/json_rpc
Input example:
{
"jsonrpc": "2.0",
"id": "test",
"method": "estimate_fusion",
"params": {
"threshold":1000000000000
}
}
Output example:
{
"id": "test",
"jsonrpc": "2.0",
"result": {
"fusion_ready_count": 101
}
}
Optimize wallet (fuse many small outputs into fewer larger ones) to be able to send large amounts in a single transaction as with smaller inputs count its size will be smaller.
URL:
/json_rpc
Input:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Karbowanec wallet api",
"description": "Schema for send fusion transaction method in Karbowanec wallet",
"type": "object",
"properties" : {
"jsonrpc" : {
"type" : "string"
},
"method" : {
"type" : "string"
},
"threshold" : {
"type" : "integer"
},
"mixin" : {
"type" : "integer"
},
"unlock_time" : {
"type" : "integer"
"description" : "Unix timestamp"
}
}
}
Output:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Karbowanec wallet api",
"description": "Schema for send fusion transaction method in Karbowanec wallet",
"type": "object",
"properties" : {
"tx_hash" : {
"type" : "string"
}
}
}
{
"jsonrpc": "2.0",
"method": "getbalance",
"params": {}
}
Please note, payment_id is an optional argument and can be left out.
{
"jsonrpc":"2.0",
"method":"transfer",
"params":{
"destinations":[
{
"amount":11111,
"address":"KfXkT5VmdqmA7bWqSH37p87hSXBdTpTogN4mGHPARUSJaLse6jbXaVbVkLs3DwcmuD88xfu835Zvh6qBPCUXw6CHK8koDCt"
},
{
"amount":22222,
"address":"KfXkT5VmdqmA7bWqSH37p87hSXBdTpTogN4mGHPARUSJaLse6jbXaVbVkLs3DwcmuD88xfu835Zvh6qBPCUXw6CHK8koDCt"
}
],
"payment_id":"",
"fee":1000000,
"mixin":0,
"unlock_time":0
}
}
{
"jsonrpc": "2.0",
"method": "store",
"params": {}
}
{
"jsonrpc": "2.0",
"method": "reset",
"params": {}
}
{
"jsonrpc":"2.0",
"method":"get_payments",
"params":{
"payment_id": "78cc4b76a48bd50ab955ac61a0c04e4a82079fbcf27298f87b39c76aefccbcc9"
}
}
{
"jsonrpc": "2.0",
"method": "get_transfers",
"params": {}
}
{
"jsonrpc": "2.0",
"method": "get_height",
"params": {}
}
Input example:
{
"jsonrpc": "2.0",
"id": "test",
"method": "send_fusion",
"params": {
"threshold":1000000000000,
"mixin":3,
"unlock_time":0
}
}
Output example:
{
"id": "test",
"jsonrpc": "2.0",
"result": {
"tx_hash": "2bc081ba8fcd29ce254d0db28c5568489be19121be74d5a2577dbf969330eb30"
}
}