Geem Simplewallet JSON RPC API

By December 9, 2018 Documentation, Geem No Comments

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=2046

Having done that you’re ready to operate with the wallet through the following API URLs (e.g., your IP address is 1.2.3.4):

http://1.2.3.4:2046/json_rpc
http://localhost:2046/json_rpc

Available commands

  • 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.

getbalance

Return balance.

URL:

 /json_rpc

Input:

 {
 	"$schema": "http://json-schema.org/draft-04/schema#",
 	"title": "Geem wallet api",
 	"description": "Schema for transfer method in Geem wallet",
 	"type": "object", 
 	
 	"properties" : {
 		"jsonrpc" : {
 			"type" : "string"
 		}, 
 		"method" : {
 			"type" : "string"
 		}
 	}
 }

Output:

 {
 	"$schema": "http://json-schema.org/draft-04/schema#",
 	"title": "Geem wallet api",
 	"description": "Schema for transfer method in Geem wallet",
 	"type": "object",
 	
 	"properties" : {
 		"locked_amount" : {
 			"type" : "integer"
 		},
 		"available_balance" : {
 			"type" : "integer"
 		}
 	}
 }

transfer

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": "Geem wallet api",
 	"description": "Schema for transfer method in Geem 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": "Geem wallet api",
 	"description": "Schema for transfer method in Geem wallet",
 	"type": "object",
 	
 	"properties" : {
 		"tx_hash" : {
 			"type" : "string"
 		}, 
 		"tx_key" : {
 			"type" : "string"
 		},
 	}
 }

store

Store wallet data.

URL:

  /json_rpc

Input:

 {
 	"$schema": "http://json-schema.org/draft-04/schema#",
 	"title": "Geem wallet api",
 	"description": "Schema for transfer method in Geem wallet",
 	"type": "object",
 	
 	"properties" : {
 		"jsonrpc" : {
 			"type" : "string"
 		}, 
 		"method" : {
 			"type" : "string"
 		}
 	}
 }

Output:

 {
 	"$schema": "http://json-schema.org/draft-04/schema#",
 	"title": "Geem wallet api",
 	"description": "Schema for transfer method in Geem wallet",
 	"type": "object",
 	
 	"properties" : {}
 }

reset

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": "Geem wallet api",
 	"description": "Schema for transfer method in Geem wallet",
 	"type": "object",
 	
 	"properties" : {
 		"jsonrpc" : {
 			"type" : "string"
 		}, 
 		"method" : {
 			"type" : "string"
 		}
 	}
 }

Output:

 {
 	"$schema": "http://json-schema.org/draft-04/schema#",
 	"title": "Geem wallet api",
 	"description": "Schema for transfer method in Geem wallet",
 	"type": "object",
 	
 	"properties" : {}
 }

get_payments

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 Geem 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": "Geem wallet api",
 	"description": "Schema for transfer method in Geem wallet",
 	"type": "object", 
 
 	"properties" : {
 		"jsonrpc" : {
 			"type" : "string"
 		}, 
 		"method" : {
 			"type" : "string"
 		},
 
 		"payment_id" :  {
 			"type" : "string"
 		}
 	}
 }

Output:

 {
 	"$schema": "http://json-schema.org/draft-04/schema#",
 	"title": "Geem wallet api",
 	"description": "Schema for transfer method in Geem wallet",
 	"type": "object",
 
 	"properties" : {
 		"payments" : {
 			"type" : "array",
 			"items" : {
 				"amount" : {
 					"type" : "integer"
 				},
 				"block_height" : {
 					"type" : "integer"
 				},
 				"tx_hash" : {
 					"type" : "string"
 				},
 				"unlock_time" : {
 					"type" : "integer"
 				}
 			}
 		}
 	}
 }

get_transfers

Returns the list of all the wallet’s incoming and outgoing transfers. This data is available starting with v.2.3.7 the arrow. 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": "Geem wallet api",
 	"description": "Schema for transfer method in Geem wallet",
 	"type": "object",
 	
 	"properties" : {
 		"jsonrpc" : {
 			"type" : "string"
 		}, 
 		"method" : {
 			"type" : "string"
 		}
 	}
 }

Output:

 {
 	"$schema": "http://json-schema.org/draft-04/schema#",
 	"title": "Geem wallet api",
 	"description": "Schema for transfer method in Geem 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"
 					},
 				}				
 			}				
 		}
 	}
 }

get_height

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": "Geem wallet api",
 	"description": "Schema for transfer method in Geem wallet",
 	"type": "object",
 	
 	"properties" : {
 		"jsonrpc" : {
 			"type" : "string"
 		}, 
 		"method" : {
 			"type" : "string"
 		}
 	}
 }

Output:

 {
 	"$schema": "http://json-schema.org/draft-04/schema#",
 	"title": "Geem wallet api",
 	"description": "Schema for transfer method in Geem wallet",
 	"type": "object",
 	
 	"properties" : {
 		"height" : {
 			"type" : "integer"
 		}
 	}
 }

get_transaction

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":"G95DwiVGzrbPBAYZRaebH2Y5T5nwDvL4wRJo1xcrHynHAv7zqp39WGNaFCX6JeRyKk823aaF6bkN21MR62888rywVatVMGE",
            "amount":2010542676062
         },
         {
            "address":"G95DwiVGzrbPBAYZRaebH2Y5T5nwDvL4wRJo1xcrHynHAv7zqp39WGNaFCX6JeRyKk823aaF6bkN21MR62888rywVatVMGF",
            "amount":57000000000
         }
      ],
      "transaction_details":{
         "address":"G95DwiVGzrbPBAYZRaebH2Y5T5nwDvL4wRJo1xcrHynHAv7zqp39WGNaFCX6JeRyKk823aaF6bkN21MR62888rywVatVMGE",
         "amount":2124542676062,
         "blockIndex":271652,
         "confirmations":25433,
         "fee":57000000000,
         "output":true,
         "paymentId":"",
         "time":1536706367,
         "transactionHash":"f86ef58c98c724c2261f3eb009b47e475472f75d3b4b2ff0fc749d607367090d",
         "txKey":"01f0eede5679da2c9cfcd06fb1961d64316e0d4dc54a308247319cb25220bf9503",
         "unlockTime":0
      }
   }
}

get_address

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":"G95DwiVGzrbPBAYZRaebH2Y5T5nwDvL4wRJo1xcrHynHAv7zqp39WGNaFCX6JeRyKk823aaF6bkN21MR62888rywVatVMGE"
   }
}

get_paymentid

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"
   }
}

get_tx_key

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"
   }
}

query_key

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..."
   }
}

estimate_fusion

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":100000000
  }
}

Output example:

{
  "id": "test",
  "jsonrpc": "2.0",
  "result": {
    "fusion_ready_count": 101
  }
}

send_fusion

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": "Geem wallet api",
 	"description": "Schema for send fusion transaction method in Geem 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": "Geem wallet api",
 	"description": "Schema for send fusion transaction method in Geem wallet",
 	"type": "object",
 	
 	"properties" : {
 		"tx_hash" : {
 			"type" : "string"
 		}
 	}
 }

Examples

getbalance

 {
 	"jsonrpc": "2.0", 
 	"method": "getbalance", 
 	"params": {}
 }

transfer

Please note, payment_id is an optional argument and can be left out.

 {
 	"jsonrpc":"2.0",
 	"method":"transfer",
 	"params":{
 		"destinations":[
 		{
 			"amount":11111,
 			"address":"G95DwiVGzrbPBAYZRaebH2Y5T5nwDvL4wRJo1xcrHynHAv7zqp39WGNaFCX6JeRyKk823aaF6bkN21MR62888rywVatVMGE"
 		},
 		{
 			"amount":22222,
 			"address":"G95DwiVGzrbPBAYZRaebH2Y5T5nwDvL4wRJo1xcrHynHAv7zqp39WGNaFCX6JeRyKk823aaF6bkN21MR62888rywVatVMGE"
 		}
 		],
 		"payment_id":"", 
 		"fee":1000000,
 		"mixin":0,
 		"unlock_time":0
 	}
 }

store

 {
 	"jsonrpc": "2.0", 
 	"method": "store", 
 	"params": {}
 }

reset

 {
 	"jsonrpc": "2.0", 
 	"method": "reset", 
 	"params": {}
 }

get_payments

 {
 	"jsonrpc":"2.0",
 	"method":"get_payments",
 	"params":{
 		"payment_id": "78cc4b76a48bd50ab955ac61a0c04e4a82079fbcf27298f87b39c76aefccbcc9"
 	}
 }

get_transfers

 {
 	"jsonrpc": "2.0", 
 	"method": "get_transfers", 
 	"params": {}
 }

get_height

 {
 	"jsonrpc": "2.0", 
 	"method": "get_height", 
 	"params": {}
 }

send_fusion

Input example:

{
  "jsonrpc": "2.0",
  "id": "test",
  "method": "send_fusion",
  "params": {
    "threshold":100000000,
    "mixin":3,
    "unlock_time":0
  }
}

Output example:

{
  "id": "test",
  "jsonrpc": "2.0",
  "result": {
    "tx_hash": "2bc081ba8fcd29ce254d0db28c5568489be19121be74d5a2577dbf969330eb30"
  }
}
SEE WHAT'S NEXT... START TRADING NOW!