Trait snarkos_rpc::ProtectedRpcFunctions [−][src]
pub trait ProtectedRpcFunctions {
fn create_account<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<RpcAccount, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn create_raw_transaction<'life0, 'async_trait>(
&'life0 self,
transaction_input: TransactionInputs
) -> Pin<Box<dyn Future<Output = Result<CreateRawTransactionOuput, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn create_transaction_kernel<'life0, 'async_trait>(
&'life0 self,
transaction_input: TransactionInputs
) -> Pin<Box<dyn Future<Output = Result<String, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn create_transaction<'life0, 'async_trait>(
&'life0 self,
private_keys: [String; 2],
transaction_kernel: String
) -> Pin<Box<dyn Future<Output = Result<CreateRawTransactionOuput, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_record_commitments<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_record_commitment_count<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<usize, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn get_raw_record<'life0, 'async_trait>(
&'life0 self,
record_commitment: String
) -> Pin<Box<dyn Future<Output = Result<String, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn decode_record<'life0, 'async_trait>(
&'life0 self,
record_bytes: String
) -> Pin<Box<dyn Future<Output = Result<RecordInfo, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn decrypt_record<'life0, 'async_trait>(
&'life0 self,
decryption_input: DecryptRecordInput
) -> Pin<Box<dyn Future<Output = Result<String, RpcError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn disconnect<'life0, 'async_trait>(
&'life0 self,
address: SocketAddr
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn connect<'life0, 'async_trait>(
&'life0 self,
addresses: Vec<SocketAddr>
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
}
Expand description
Definition of private RPC endpoints that require authentication.
Required methods
fn create_account<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<RpcAccount, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn create_account<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<RpcAccount, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Creates a new account private key and its corresponding account address.
Protected Endpoint
Yes
Arguments
None
Response
Parameter | Type | Description |
---|---|---|
private_key | string | An Aleo account private key |
view_key | string | An Aleo account view key |
address | string | An Aleo account address |
Example
curl --user username:password --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "createaccount", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/
fn create_raw_transaction<'life0, 'async_trait>(
&'life0 self,
transaction_input: TransactionInputs
) -> Pin<Box<dyn Future<Output = Result<CreateRawTransactionOuput, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn create_raw_transaction<'life0, 'async_trait>(
&'life0 self,
transaction_input: TransactionInputs
) -> Pin<Box<dyn Future<Output = Result<CreateRawTransactionOuput, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Creates a new transaction and returns the encoded transaction along with the encoded records.
Protected Endpoint
Yes
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
old_records | array | Yes | An array of hex encoded records to be spent |
old_account_private_keys | array | Yes | An array of private keys authorized to spend the records |
recipients | array | Yes | The array of transaction recipient objects |
memo | string | No | The transaction memo |
network_id | number | Yes | The network id of the transaction |
Transaction Recipient Object
Parameter | Type | Description |
---|---|---|
address | string | The recipient address |
value | number | The amount sent to the recipient |
Response
Parameter | Type | Description |
---|---|---|
encoded_transaction | string | The hex encoding of the generated transaction |
encoded_records | array | The hex encodings of the generated records |
Example
curl --user username:password --data-binary '{
"jsonrpc":"2.0",
"id": "1",
"method": "createrawtransaction",
"params": [
{
"old_records": ["record_hexstring"],
"old_account_private_keys": ["private_key_string"],
"recipients": [{
"address": "address_string",
"amount": amount
}],
"memo": "memo_hexstring",
"network_id": 0
}
]
}' -H 'content-type: application/json' http://127.0.0.1:3030/
fn create_transaction_kernel<'life0, 'async_trait>(
&'life0 self,
transaction_input: TransactionInputs
) -> Pin<Box<dyn Future<Output = Result<String, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn create_transaction_kernel<'life0, 'async_trait>(
&'life0 self,
transaction_input: TransactionInputs
) -> Pin<Box<dyn Future<Output = Result<String, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Create a new transaction kernel.
Protected Endpoint
Yes
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
old_records | array | Yes | An array of hex encoded records to be spent |
old_account_private_keys | array | Yes | An array of private keys authorized to spend the records |
recipients | array | Yes | The array of transaction recipient objects |
memo | string | No | The transaction memo |
network_id | number | Yes | The network id of the transaction |
Transaction Recipient Object
Parameter | Type | Description |
---|---|---|
address | string | The recipient address |
value | number | The amount sent to the recipient |
Response
Parameter | Type | Required | Description |
---|---|---|---|
transaction_kernel | string | Yes | The hex encoded transaction kernel |
Example
curl --user username:password --data-binary '{
"jsonrpc":"2.0",
"id": "1",
"method": "createtransactionkernel",
"params": [
{
"old_records": ["record_hexstring"],
"old_account_private_keys": ["private_key_string"],
"recipients": [{
"address": "address_string",
"amount": amount
}],
"memo": "memo_hexstring",
"network_id": 0
}
]
}' -H 'content-type: application/json' http://127.0.0.1:3030/
Create a new transaction from a given transaction kernel, returning the encoded transaction and the new records.
Protected Endpoint
Yes
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
private_keys | [string] | Yes | An array of private key strings |
transaction_kernel | string | Yes | The hex encoded transaction kernel |
Response
Parameter | Type | Description |
---|---|---|
encoded_transaction | string | The hex encoding of the generated transaction |
encoded_records | array | The hex encodings of the generated records |
Example
curl --user username:password --data-binary '{
"jsonrpc":"2.0",
"id": "1",
"method": "createtransaction",
"params": ["[private_key_0, private_key_1]", "transaction_kernel_hexstring"]
}' -H 'content-type: application/json' http://127.0.0.1:3030/
Returns a list of record commitments that are stored on the full node.
Protected Endpoint
Yes
Arguments
None
Response
Parameter | Type | Description |
---|---|---|
result | array | The list of stored record commitments |
Example
curl --user username:password --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getrecordcommitments", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/
Returns the number of record commitments that are stored on the full node.
Protected Endpoint
Yes
Arguments
None
Response
Parameter | Type | Description |
---|---|---|
result | number | The number of stored record commitments |
Example
curl --user username:password --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getrecordcommitmentcount", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/
Returns the hex encoded bytes of a record from its record commitment.
Protected Endpoint
Yes
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
record_commitment | string | Yes | The record commitment |
Response
Parameter | Type | Description |
---|---|---|
result | string | The hex-encoded record bytes |
Example
curl --user username:password --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getrawrecord", "params": ["86be61d5f3bd795e31615d6834efefca01ad023d57c0383e2231e094bcabfc05"] }' -H 'content-type: application/json' http://127.0.0.1:3030/
fn decode_record<'life0, 'async_trait>(
&'life0 self,
record_bytes: String
) -> Pin<Box<dyn Future<Output = Result<RecordInfo, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn decode_record<'life0, 'async_trait>(
&'life0 self,
record_bytes: String
) -> Pin<Box<dyn Future<Output = Result<RecordInfo, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Returns information about a record from serialized record hex.
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
record_bytes | string | Yes | The raw record hex to decode |
Response
Parameter | Type | Description |
---|---|---|
owner | string | The owner of the record |
is_dummy | number | The height of the next block |
value | number | The current timestamp |
payload | object | The record payload |
birth_program_id | string | The birth program representation |
death_program_id | string | The death program representation |
serial_number_nonce | string | The serial number nonce |
commitment | string | The record commitment |
commitment_randomness | string | The record commitment randomness |
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "decoderecord", "params": ["record_hexstring"] }' -H 'content-type: application/json' http://127.0.0.1:3030/
fn decrypt_record<'life0, 'async_trait>(
&'life0 self,
decryption_input: DecryptRecordInput
) -> Pin<Box<dyn Future<Output = Result<String, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn decrypt_record<'life0, 'async_trait>(
&'life0 self,
decryption_input: DecryptRecordInput
) -> Pin<Box<dyn Future<Output = Result<String, RpcError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Decrypts the encrypted record and returns the hex encoded bytes of the record.
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
encrypted_record | string | Yes | The encrypted record |
account_view_key | string | Yes | The account view key used to decrypt the ciphertext |
Response
Parameter | Type | Description |
---|---|---|
result | string | The hex-encoded record bytes |
Example
curl --user username:password --data-binary '{
"jsonrpc":"2.0",
"id": "1",
"method": "decryptrecord",
"params": [
{
"encrypted_record": "encrypted_record_string",
"account_view_key": "account_view_key_string"
}
]
}' -H 'content-type: application/json' http://127.0.0.1:3030/
fn disconnect<'life0, 'async_trait>(
&'life0 self,
address: SocketAddr
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn disconnect<'life0, 'async_trait>(
&'life0 self,
address: SocketAddr
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Disconnects the node from the given address.
Protected Endpoint
Yes
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
address | string | Yes | The address to disconnect in an IP:port format |
Response
null
Example
curl --user username:password --data-binary '{"jsonrpc": "2.0", "id":"1", "method": "disconnect", "params": ["127.0.0.1:4141"] }' -H 'content-type: application/json' http://127.0.0.1:3030/
Adds the given addresses to the node’s list of peers and attempts to connect to them.
Protected Endpoint
Yes
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
addresses | array | Yes | The addresses to connect to in an IP:port format |
Response
null
Example
curl --user username:password --data-binary '{"jsonrpc": "2.0", "id":"1", "method": "connect", "params": ["127.0.0.1:4141", "127.0.0.1:4142"] }' -H 'content-type: application/json' http://127.0.0.1:3030/
Implementors
Functions that are sensitive and need to be protected with authentication.
The authentication logic is defined in validate_auth