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

Creates a new account private key and its corresponding account address.

Protected Endpoint

Yes

Arguments

None

Response
ParameterTypeDescription
private_keystringAn Aleo account private key
view_keystringAn Aleo account view key
addressstringAn 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/ 

Creates a new transaction and returns the encoded transaction along with the encoded records.

Protected Endpoint

Yes

Arguments
ParameterTypeRequiredDescription
old_recordsarrayYesAn array of hex encoded records to be spent
old_account_private_keysarrayYesAn array of private keys authorized to spend the records
recipientsarrayYesThe array of transaction recipient objects
memostringNoThe transaction memo
network_idnumberYesThe network id of the transaction

Transaction Recipient Object

ParameterTypeDescription
addressstringThe recipient address
valuenumberThe amount sent to the recipient
Response
ParameterTypeDescription
encoded_transactionstringThe hex encoding of the generated transaction
encoded_recordsarrayThe 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/

Create a new transaction kernel.

Protected Endpoint

Yes

Arguments
ParameterTypeRequiredDescription
old_recordsarrayYesAn array of hex encoded records to be spent
old_account_private_keysarrayYesAn array of private keys authorized to spend the records
recipientsarrayYesThe array of transaction recipient objects
memostringNoThe transaction memo
network_idnumberYesThe network id of the transaction

Transaction Recipient Object

ParameterTypeDescription
addressstringThe recipient address
valuenumberThe amount sent to the recipient
Response
ParameterTypeRequiredDescription
transaction_kernelstringYesThe 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
ParameterTypeRequiredDescription
private_keys[string]YesAn array of private key strings
transaction_kernelstringYesThe hex encoded transaction kernel
Response
ParameterTypeDescription
encoded_transactionstringThe hex encoding of the generated transaction
encoded_recordsarrayThe 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
ParameterTypeDescription
resultarrayThe 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
ParameterTypeDescription
resultnumberThe 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
ParameterTypeRequiredDescription
record_commitmentstringYesThe record commitment
Response
ParameterTypeDescription
resultstringThe 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/ 

Returns information about a record from serialized record hex.

Arguments
ParameterTypeRequiredDescription
record_bytesstringYesThe raw record hex to decode
Response
ParameterTypeDescription
ownerstringThe owner of the record
is_dummynumberThe height of the next block
valuenumberThe current timestamp
payloadobjectThe record payload
birth_program_idstringThe birth program representation
death_program_idstringThe death program representation
serial_number_noncestringThe serial number nonce
commitmentstringThe record commitment
commitment_randomnessstringThe 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/

Decrypts the encrypted record and returns the hex encoded bytes of the record.

Arguments
ParameterTypeRequiredDescription
encrypted_recordstringYesThe encrypted record
account_view_keystringYesThe account view key used to decrypt the ciphertext
Response
ParameterTypeDescription
resultstringThe 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/

Disconnects the node from the given address.

Protected Endpoint

Yes

Arguments
ParameterTypeRequiredDescription
addressstringYesThe 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
ParameterTypeRequiredDescription
addressesarrayYesThe 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