* Add base64 (binary64) encoding for getConfirmedTransaction/getConfirmedBlock (cherry picked from commitb5f3ced860
) # Conflicts: # transaction-status/Cargo.toml * decode-transaction now supports binary64 (cherry picked from commit2ebc68a9e2
) # Conflicts: # cli/src/cli.rs * Rework UiAccountData encode/decode such that it works from Rust (cherry picked from commit757e147b3b
) # Conflicts: # cli/src/cli.rs * Rename Binary64 to Base64. Establish Base58 encoding (cherry picked from commitadc984a225
) * Remove "binary" encoding. Document "encoding" as required (cherry picked from commite5281157fa
) * resolve conflicts Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -4431,6 +4431,7 @@ name = "solana-transaction-status"
|
|||||||
version = "1.2.24"
|
version = "1.2.24"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"Inflector",
|
"Inflector",
|
||||||
|
"base64 0.12.3",
|
||||||
"bincode",
|
"bincode",
|
||||||
"bs58",
|
"bs58",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
@ -32,17 +32,18 @@ pub struct UiAccount {
|
|||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase", untagged)]
|
#[serde(rename_all = "camelCase", untagged)]
|
||||||
pub enum UiAccountData {
|
pub enum UiAccountData {
|
||||||
Binary(String),
|
LegacyBinary(String), // Legacy. Retained for RPC backwards compatibility
|
||||||
Json(ParsedAccount),
|
Json(ParsedAccount),
|
||||||
Binary64(String),
|
Binary(String, UiAccountEncoding),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum UiAccountEncoding {
|
pub enum UiAccountEncoding {
|
||||||
Binary, // SLOW! Avoid this encoding
|
Binary, // Legacy. Retained for RPC backwards compatibility
|
||||||
|
Base58,
|
||||||
|
Base64,
|
||||||
JsonParsed,
|
JsonParsed,
|
||||||
Binary64,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UiAccount {
|
impl UiAccount {
|
||||||
@ -54,20 +55,24 @@ impl UiAccount {
|
|||||||
data_slice_config: Option<UiDataSliceConfig>,
|
data_slice_config: Option<UiDataSliceConfig>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let data = match encoding {
|
let data = match encoding {
|
||||||
UiAccountEncoding::Binary => UiAccountData::Binary(
|
UiAccountEncoding::Binary => UiAccountData::LegacyBinary(
|
||||||
bs58::encode(slice_data(&account.data, data_slice_config)).into_string(),
|
bs58::encode(slice_data(&account.data, data_slice_config)).into_string(),
|
||||||
),
|
),
|
||||||
UiAccountEncoding::Binary64 => UiAccountData::Binary64(base64::encode(slice_data(
|
UiAccountEncoding::Base58 => UiAccountData::Binary(
|
||||||
&account.data,
|
bs58::encode(slice_data(&account.data, data_slice_config)).into_string(),
|
||||||
data_slice_config,
|
encoding,
|
||||||
))),
|
),
|
||||||
|
UiAccountEncoding::Base64 => UiAccountData::Binary(
|
||||||
|
base64::encode(slice_data(&account.data, data_slice_config)),
|
||||||
|
encoding,
|
||||||
|
),
|
||||||
UiAccountEncoding::JsonParsed => {
|
UiAccountEncoding::JsonParsed => {
|
||||||
if let Ok(parsed_data) =
|
if let Ok(parsed_data) =
|
||||||
parse_account_data(pubkey, &account.owner, &account.data, additional_data)
|
parse_account_data(pubkey, &account.owner, &account.data, additional_data)
|
||||||
{
|
{
|
||||||
UiAccountData::Json(parsed_data)
|
UiAccountData::Json(parsed_data)
|
||||||
} else {
|
} else {
|
||||||
UiAccountData::Binary64(base64::encode(&account.data))
|
UiAccountData::Binary(base64::encode(&account.data), UiAccountEncoding::Base64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -83,8 +88,12 @@ impl UiAccount {
|
|||||||
pub fn decode(&self) -> Option<Account> {
|
pub fn decode(&self) -> Option<Account> {
|
||||||
let data = match &self.data {
|
let data = match &self.data {
|
||||||
UiAccountData::Json(_) => None,
|
UiAccountData::Json(_) => None,
|
||||||
UiAccountData::Binary(blob) => bs58::decode(blob).into_vec().ok(),
|
UiAccountData::LegacyBinary(blob) => bs58::decode(blob).into_vec().ok(),
|
||||||
UiAccountData::Binary64(blob) => base64::decode(blob).ok(),
|
UiAccountData::Binary(blob, encoding) => match encoding {
|
||||||
|
UiAccountEncoding::Base58 => bs58::decode(blob).into_vec().ok(),
|
||||||
|
UiAccountEncoding::Base64 => base64::decode(blob).ok(),
|
||||||
|
UiAccountEncoding::Binary | UiAccountEncoding::JsonParsed => None,
|
||||||
|
},
|
||||||
}?;
|
}?;
|
||||||
Some(Account {
|
Some(Account {
|
||||||
lamports: self.lamports,
|
lamports: self.lamports,
|
||||||
|
@ -11,7 +11,7 @@ use crate::{
|
|||||||
vote::*,
|
vote::*,
|
||||||
};
|
};
|
||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
|
use clap::{value_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand};
|
||||||
use log::*;
|
use log::*;
|
||||||
use num_traits::FromPrimitive;
|
use num_traits::FromPrimitive;
|
||||||
use serde_json::{self, json, Value};
|
use serde_json::{self, json, Value};
|
||||||
@ -845,9 +845,14 @@ pub fn parse_command(
|
|||||||
_ => Err(CliError::BadParameter("Invalid signature".to_string())),
|
_ => Err(CliError::BadParameter("Invalid signature".to_string())),
|
||||||
},
|
},
|
||||||
("decode-transaction", Some(matches)) => {
|
("decode-transaction", Some(matches)) => {
|
||||||
let encoded_transaction = EncodedTransaction::Binary(
|
let blob = value_t_or_exit!(matches, "transaction", String);
|
||||||
matches.value_of("base58_transaction").unwrap().to_string(),
|
let encoding = match matches.value_of("encoding").unwrap() {
|
||||||
);
|
"base58" => UiTransactionEncoding::Binary,
|
||||||
|
"base64" => UiTransactionEncoding::Base64,
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let encoded_transaction = EncodedTransaction::Binary(blob, encoding);
|
||||||
if let Some(transaction) = encoded_transaction.decode() {
|
if let Some(transaction) = encoded_transaction.decode() {
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::DecodeTransaction(transaction),
|
command: CliCommand::DecodeTransaction(transaction),
|
||||||
@ -1178,7 +1183,7 @@ fn process_confirm(
|
|||||||
if let Some(transaction_status) = status {
|
if let Some(transaction_status) = status {
|
||||||
if config.verbose {
|
if config.verbose {
|
||||||
match rpc_client
|
match rpc_client
|
||||||
.get_confirmed_transaction(signature, UiTransactionEncoding::Binary)
|
.get_confirmed_transaction(signature, UiTransactionEncoding::Base64)
|
||||||
{
|
{
|
||||||
Ok(confirmed_transaction) => {
|
Ok(confirmed_transaction) => {
|
||||||
println!(
|
println!(
|
||||||
@ -1234,7 +1239,7 @@ fn process_show_account(
|
|||||||
account: UiAccount::encode(
|
account: UiAccount::encode(
|
||||||
account_pubkey,
|
account_pubkey,
|
||||||
account,
|
account,
|
||||||
UiAccountEncoding::Binary64,
|
UiAccountEncoding::Base64,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
@ -2549,12 +2554,22 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
|
|||||||
SubCommand::with_name("decode-transaction")
|
SubCommand::with_name("decode-transaction")
|
||||||
.about("Decode a base-58 binary transaction")
|
.about("Decode a base-58 binary transaction")
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("base58_transaction")
|
Arg::with_name("transaction")
|
||||||
.index(1)
|
.index(1)
|
||||||
.value_name("BASE58_TRANSACTION")
|
.value_name("TRANSACTION")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.required(true)
|
.required(true)
|
||||||
.help("The transaction to decode"),
|
.help("transaction to decode"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("encoding")
|
||||||
|
.index(2)
|
||||||
|
.value_name("ENCODING")
|
||||||
|
.possible_values(&["base58", "base64"]) // Subset of `UiTransactionEncoding` enum
|
||||||
|
.default_value("base58")
|
||||||
|
.takes_value(true)
|
||||||
|
.required(true)
|
||||||
|
.help("transaction encoding"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
|
@ -348,7 +348,7 @@ mod tests {
|
|||||||
let rpc_nonce_account = UiAccount::encode(
|
let rpc_nonce_account = UiAccount::encode(
|
||||||
&nonce_pubkey,
|
&nonce_pubkey,
|
||||||
nonce_account,
|
nonce_account,
|
||||||
UiAccountEncoding::Binary64,
|
UiAccountEncoding::Base64,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -15,12 +15,7 @@ use bincode::serialize;
|
|||||||
use indicatif::{ProgressBar, ProgressStyle};
|
use indicatif::{ProgressBar, ProgressStyle};
|
||||||
use log::*;
|
use log::*;
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
use solana_account_decoder::{
|
use solana_account_decoder::{parse_token::UiTokenAmount, UiAccount, UiAccountEncoding};
|
||||||
parse_token::UiTokenAmount,
|
|
||||||
UiAccount,
|
|
||||||
UiAccountData::{Binary, Binary64},
|
|
||||||
UiAccountEncoding,
|
|
||||||
};
|
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::Account,
|
account::Account,
|
||||||
clock::{
|
clock::{
|
||||||
@ -477,7 +472,7 @@ impl RpcClient {
|
|||||||
commitment_config: CommitmentConfig,
|
commitment_config: CommitmentConfig,
|
||||||
) -> RpcResult<Option<Account>> {
|
) -> RpcResult<Option<Account>> {
|
||||||
let config = RpcAccountInfoConfig {
|
let config = RpcAccountInfoConfig {
|
||||||
encoding: Some(UiAccountEncoding::Binary64),
|
encoding: Some(UiAccountEncoding::Base64),
|
||||||
commitment: Some(commitment_config),
|
commitment: Some(commitment_config),
|
||||||
data_slice: None,
|
data_slice: None,
|
||||||
};
|
};
|
||||||
@ -495,17 +490,8 @@ impl RpcClient {
|
|||||||
}
|
}
|
||||||
let Response {
|
let Response {
|
||||||
context,
|
context,
|
||||||
value: mut rpc_account,
|
value: rpc_account,
|
||||||
} = serde_json::from_value::<Response<Option<UiAccount>>>(result_json)?;
|
} = serde_json::from_value::<Response<Option<UiAccount>>>(result_json)?;
|
||||||
if let Some(ref mut account) = rpc_account {
|
|
||||||
if let Binary(_) = &account.data {
|
|
||||||
let tmp = Binary64(String::new());
|
|
||||||
match std::mem::replace(&mut account.data, tmp) {
|
|
||||||
Binary(new_data) => account.data = Binary64(new_data),
|
|
||||||
_ => panic!("should have gotten binary here."),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trace!("Response account {:?} {:?}", pubkey, rpc_account);
|
trace!("Response account {:?} {:?}", pubkey, rpc_account);
|
||||||
let account = rpc_account.and_then(|rpc_account| rpc_account.decode());
|
let account = rpc_account.and_then(|rpc_account| rpc_account.decode());
|
||||||
Ok(Response {
|
Ok(Response {
|
||||||
|
@ -195,8 +195,11 @@ impl JsonRpcRequestProcessor {
|
|||||||
if let Some(account) = bank.get_account(pubkey) {
|
if let Some(account) = bank.get_account(pubkey) {
|
||||||
if account.owner == spl_token_id_v1_0() && encoding == UiAccountEncoding::JsonParsed {
|
if account.owner == spl_token_id_v1_0() && encoding == UiAccountEncoding::JsonParsed {
|
||||||
response = Some(get_parsed_token_account(bank.clone(), pubkey, account));
|
response = Some(get_parsed_token_account(bank.clone(), pubkey, account));
|
||||||
} else if encoding == UiAccountEncoding::Binary && account.data.len() > 128 {
|
} else if (encoding == UiAccountEncoding::Binary
|
||||||
let message = "Encoded binary (base 58) data should be less than 128 bytes, please use Binary64 encoding.".to_string();
|
|| encoding == UiAccountEncoding::Base58)
|
||||||
|
&& account.data.len() > 128
|
||||||
|
{
|
||||||
|
let message = "Encoded binary (base 58) data should be less than 128 bytes, please use Base64 encoding.".to_string();
|
||||||
return Err(error::Error {
|
return Err(error::Error {
|
||||||
code: error::ErrorCode::InvalidRequest,
|
code: error::ErrorCode::InvalidRequest,
|
||||||
message,
|
message,
|
||||||
@ -1239,7 +1242,7 @@ fn check_slice_and_encoding(encoding: &UiAccountEncoding, data_slice_is_some: bo
|
|||||||
UiAccountEncoding::JsonParsed => {
|
UiAccountEncoding::JsonParsed => {
|
||||||
if data_slice_is_some {
|
if data_slice_is_some {
|
||||||
let message =
|
let message =
|
||||||
"Sliced account data can only be encoded using binary (base 58) or binary64 encoding."
|
"Sliced account data can only be encoded using binary (base 58) or base64 encoding."
|
||||||
.to_string();
|
.to_string();
|
||||||
Err(error::Error {
|
Err(error::Error {
|
||||||
code: error::ErrorCode::InvalidRequest,
|
code: error::ErrorCode::InvalidRequest,
|
||||||
@ -1250,7 +1253,7 @@ fn check_slice_and_encoding(encoding: &UiAccountEncoding, data_slice_is_some: bo
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UiAccountEncoding::Binary | UiAccountEncoding::Binary64 => Ok(()),
|
UiAccountEncoding::Binary | UiAccountEncoding::Base58 | UiAccountEncoding::Base64 => Ok(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3095,16 +3098,7 @@ pub mod tests {
|
|||||||
bank.store_account(&address, &account);
|
bank.store_account(&address, &account);
|
||||||
|
|
||||||
let req = format!(
|
let req = format!(
|
||||||
r#"{{"jsonrpc":"2.0","id":1,"method":"getAccountInfo","params":["{}", {{"encoding":"binary64"}}]}}"#,
|
r#"{{"jsonrpc":"2.0","id":1,"method":"getAccountInfo","params":["{}", {{"encoding":"base64"}}]}}"#,
|
||||||
address
|
|
||||||
);
|
|
||||||
let res = io.handle_request_sync(&req, meta.clone());
|
|
||||||
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
|
||||||
.expect("actual response deserialization");
|
|
||||||
assert_eq!(result["result"]["value"]["data"], base64::encode(&data));
|
|
||||||
|
|
||||||
let req = format!(
|
|
||||||
r#"{{"jsonrpc":"2.0","id":1,"method":"getAccountInfo","params":["{}", {{"encoding":"binary64", "dataSlice": {{"length": 2, "offset": 1}}}}]}}"#,
|
|
||||||
address
|
address
|
||||||
);
|
);
|
||||||
let res = io.handle_request_sync(&req, meta.clone());
|
let res = io.handle_request_sync(&req, meta.clone());
|
||||||
@ -3112,7 +3106,19 @@ pub mod tests {
|
|||||||
.expect("actual response deserialization");
|
.expect("actual response deserialization");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result["result"]["value"]["data"],
|
result["result"]["value"]["data"],
|
||||||
base64::encode(&data[1..3]),
|
json!([base64::encode(&data), "base64"]),
|
||||||
|
);
|
||||||
|
|
||||||
|
let req = format!(
|
||||||
|
r#"{{"jsonrpc":"2.0","id":1,"method":"getAccountInfo","params":["{}", {{"encoding":"base64", "dataSlice": {{"length": 2, "offset": 1}}}}]}}"#,
|
||||||
|
address
|
||||||
|
);
|
||||||
|
let res = io.handle_request_sync(&req, meta.clone());
|
||||||
|
let result: Value = serde_json::from_str(&res.expect("actual response"))
|
||||||
|
.expect("actual response deserialization");
|
||||||
|
assert_eq!(
|
||||||
|
result["result"]["value"]["data"],
|
||||||
|
json!([base64::encode(&data[1..3]), "base64"]),
|
||||||
);
|
);
|
||||||
|
|
||||||
let req = format!(
|
let req = format!(
|
||||||
@ -4327,7 +4333,7 @@ pub mod tests {
|
|||||||
for TransactionWithStatusMeta { transaction, meta } in
|
for TransactionWithStatusMeta { transaction, meta } in
|
||||||
confirmed_block.transactions.into_iter()
|
confirmed_block.transactions.into_iter()
|
||||||
{
|
{
|
||||||
if let EncodedTransaction::Binary(transaction) = transaction {
|
if let EncodedTransaction::LegacyBinary(transaction) = transaction {
|
||||||
let decoded_transaction: Transaction =
|
let decoded_transaction: Transaction =
|
||||||
deserialize(&bs58::decode(&transaction).into_vec().unwrap()).unwrap();
|
deserialize(&bs58::decode(&transaction).into_vec().unwrap()).unwrap();
|
||||||
if decoded_transaction.signatures[0] == confirmed_block_signatures[0] {
|
if decoded_transaction.signatures[0] == confirmed_block_signatures[0] {
|
||||||
|
@ -103,7 +103,7 @@ fn test_rpc_send_tx() {
|
|||||||
use solana_account_decoder::UiAccountEncoding;
|
use solana_account_decoder::UiAccountEncoding;
|
||||||
use solana_client::rpc_config::RpcAccountInfoConfig;
|
use solana_client::rpc_config::RpcAccountInfoConfig;
|
||||||
let config = RpcAccountInfoConfig {
|
let config = RpcAccountInfoConfig {
|
||||||
encoding: Some(UiAccountEncoding::Binary64),
|
encoding: Some(UiAccountEncoding::Base64),
|
||||||
commitment: None,
|
commitment: None,
|
||||||
data_slice: None,
|
data_slice: None,
|
||||||
};
|
};
|
||||||
|
@ -157,9 +157,9 @@ Returns all information associated with the account of provided Pubkey
|
|||||||
- `<string>` - Pubkey of account to query, as base-58 encoded string
|
- `<string>` - Pubkey of account to query, as base-58 encoded string
|
||||||
- `<object>` - (optional) Configuration object containing the following optional fields:
|
- `<object>` - (optional) Configuration object containing the following optional fields:
|
||||||
- (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment)
|
- (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment)
|
||||||
- (optional) `encoding: <string>` - encoding for Account data, either "binary", "binary64", or jsonParsed". If parameter not provided, the default encoding is "binary". "binary" is base-58 encoded and limited to Account data of less than 128 bytes. "binary64" will return base64 encoded data for Account data of any size.
|
- `encoding: <string>` - encoding for Account data, either "base58" (*slow*), "base64", or jsonParsed". "base58" is limited to Account data of less than 128 bytes. "base64" will return base64 encoded data for Account data of any size.
|
||||||
Parsed-JSON encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If parsed-JSON is requested but a parser cannot be found, the field falls back to binary encoding, detectable when the `data` field is type `<string>`. **jsonParsed encoding is UNSTABLE**
|
Parsed-JSON encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If parsed-JSON is requested but a parser cannot be found, the field falls back to base64 encoding, detectable when the `data` field is type `<string>`. **jsonParsed encoding is UNSTABLE**
|
||||||
- (optional) `dataSlice: <object>` - limit the returned account data using the provided `offset: <usize>` and `length: <usize>` fields; only available for "binary" or "binary64" encoding.
|
- (optional) `dataSlice: <object>` - limit the returned account data using the provided `offset: <usize>` and `length: <usize>` fields; only available for "base58" or "base64" encoding.
|
||||||
|
|
||||||
#### Results:
|
#### Results:
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ The result will be an RpcResponse JSON object with `value` equal to:
|
|||||||
- `<object>` - otherwise, a JSON object containing:
|
- `<object>` - otherwise, a JSON object containing:
|
||||||
- `lamports: <u64>`, number of lamports assigned to this account, as a u64
|
- `lamports: <u64>`, number of lamports assigned to this account, as a u64
|
||||||
- `owner: <string>`, base-58 encoded Pubkey of the program this account has been assigned to
|
- `owner: <string>`, base-58 encoded Pubkey of the program this account has been assigned to
|
||||||
- `data: <string|object>`, data associated with the account, either as base-58 encoded binary data or JSON format `{<program>: <state>}`, depending on encoding parameter
|
- `data: <[string, encoding]|object>`, data associated with the account, either as encoded binary data or JSON format `{<program>: <state>}`, depending on encoding parameter
|
||||||
- `executable: <bool>`, boolean indicating if the account contains a program \(and is strictly read-only\)
|
- `executable: <bool>`, boolean indicating if the account contains a program \(and is strictly read-only\)
|
||||||
- `rentEpoch: <u64>`, the epoch at which this account will next owe rent, as u64
|
- `rentEpoch: <u64>`, the epoch at which this account will next owe rent, as u64
|
||||||
|
|
||||||
@ -177,10 +177,10 @@ The result will be an RpcResponse JSON object with `value` equal to:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
// Request
|
// Request
|
||||||
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"getAccountInfo", "params":["4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA"]}' http://localhost:8899
|
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"getAccountInfo", "params":["vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",{"encoding": "base58"}]}' http://localhost:8899
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
{"jsonrpc":"2.0","result":{"context":{"slot":1},"value":{"data":"11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHRTPuR3oZ1EioKtYGiYxpxMG5vpbZLsbcBYBEmZZcMKaSoGx9JZeAuWf","executable":false,"lamports":1000000000,"owner":"11111111111111111111111111111111","rentEpoch":2}},"id":1}
|
{"jsonrpc":"2.0","result":{"context":{"slot":1},"value":{"data":["11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHRTPuR3oZ1EioKtYGiYxpxMG5vpbZLsbcBYBEmZZcMKaSoGx9JZeAuWf","base58"],"executable":false,"lamports":1000000000,"owner":"11111111111111111111111111111111","rentEpoch":2}},"id":1}
|
||||||
|
|
||||||
// Request
|
// Request
|
||||||
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"getAccountInfo", "params":["4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA",{"encoding":"json"}]}' http://localhost:8899
|
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"getAccountInfo", "params":["4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA",{"encoding":"json"}]}' http://localhost:8899
|
||||||
@ -307,7 +307,7 @@ Returns identity and transaction information about a confirmed block in the ledg
|
|||||||
#### Parameters:
|
#### Parameters:
|
||||||
|
|
||||||
- `<u64>` - slot, as u64 integer
|
- `<u64>` - slot, as u64 integer
|
||||||
- `<string>` - (optional) encoding for each returned Transaction, either "json", "jsonParsed", or "binary". If parameter not provided, the default encoding is JSON. **jsonParsed encoding is UNSTABLE**
|
- `<string>` - encoding for each returned Transaction, either "json", "jsonParsed", "base58" (*slow*), or "base64". If parameter not provided, the default encoding is JSON. **jsonParsed encoding is UNSTABLE**
|
||||||
Parsed-JSON encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If parsed-JSON is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields).
|
Parsed-JSON encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If parsed-JSON is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields).
|
||||||
|
|
||||||
#### Results:
|
#### Results:
|
||||||
@ -320,7 +320,7 @@ The result field will be an object with the following fields:
|
|||||||
- `previousBlockhash: <string>` - the blockhash of this block's parent, as base-58 encoded string; if the parent block is not available due to ledger cleanup, this field will return "11111111111111111111111111111111"
|
- `previousBlockhash: <string>` - the blockhash of this block's parent, as base-58 encoded string; if the parent block is not available due to ledger cleanup, this field will return "11111111111111111111111111111111"
|
||||||
- `parentSlot: <u64>` - the slot index of this block's parent
|
- `parentSlot: <u64>` - the slot index of this block's parent
|
||||||
- `transactions: <array>` - an array of JSON objects containing:
|
- `transactions: <array>` - an array of JSON objects containing:
|
||||||
- `transaction: <object|string>` - [Transaction](#transaction-structure) object, either in JSON format or base-58 encoded binary data, depending on encoding parameter
|
- `transaction: <object|[string,encoding]>` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter
|
||||||
- `meta: <object>` - transaction status metadata object, containing `null` or:
|
- `meta: <object>` - transaction status metadata object, containing `null` or:
|
||||||
- `err: <object | null>` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/master/sdk/src/transaction.rs#L14)
|
- `err: <object | null>` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/master/sdk/src/transaction.rs#L14)
|
||||||
- `fee: <u64>` - fee this transaction was charged, as u64 integer
|
- `fee: <u64>` - fee this transaction was charged, as u64 integer
|
||||||
@ -341,13 +341,13 @@ The result field will be an object with the following fields:
|
|||||||
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0","id":1,"method":"getConfirmedBlock","params":[430, "json"]}' localhost:8899
|
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0","id":1,"method":"getConfirmedBlock","params":[430, "json"]}' localhost:8899
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
{"jsonrpc":"2.0","result":{"blockhash":"Gp3t5bfDsJv1ovP8cB1SuRhXVuoTqDv7p3tymyubYg5","parentSlot":429,"previousBlockhash":"EFejToxii1L5aUF2NrK9dsbAEmZSNyN5nsipmZHQR1eA","transactions":[{"transaction":{"message":{"accountKeys":["6H94zdiaYfRfPfKjYLjyr2VFBg6JHXygy84r3qhc3NsC","39UAy8hsoYPywGPGdmun747omSr79zLSjqvPJN3zetoH","SysvarS1otHashes111111111111111111111111111","SysvarC1ock11111111111111111111111111111111","Vote111111111111111111111111111111111111111"],"header":{"numReadonlySignedAccounts":0,"numReadonlyUnsignedAccounts":3,"numRequiredSignatures":2},"instructions":[{"accounts":[1,2,3],"data":"29z5mr1JoRmJYQ6ynmk3pf31cGFRziAF1M3mT3L6sFXf5cKLdkEaMXMT8AqLpD4CpcupHmuMEmtZHpomrwfdZetSomNy3d","programIdIndex":4}],"recentBlockhash":"EFejToxii1L5aUF2NrK9dsbAEmZSNyN5nsipmZHQR1eA"},"signatures":["35YGay1Lwjwgxe9zaH6APSHbt9gYQUCtBWTNL3aVwVGn9xTFw2fgds7qK5AL29mP63A9j3rh8KpN1TgSR62XCaby","4vANMjSKiwEchGSXwVrQkwHnmsbKQmy9vdrsYxWdCup1bLsFzX8gKrFTSVDCZCae2dbxJB9mPNhqB2sD1vvr4sAD"]},"meta":{"err":null,"fee":18000,"postBalances":[499999972500,15298080,1,1,1],"preBalances":[499999990500,15298080,1,1,1],"status":{"Ok":null}}}]},"id":1}
|
{"jsonrpc":"2.0","result":{"blockTime":null,"blockhash":"3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA","parentSlot":429,"previousBlockhash":"mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B","rewards":[],"transactions":[{"meta":{"err":null,"fee":5000,"postBalances":[499998932500,26858640,1,1,1],"preBalances":[499998937500,26858640,1,1,1],"status":{"Ok":null}},"transaction":{"message":{"accountKeys":["3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe","AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc","SysvarS1otHashes111111111111111111111111111","SysvarC1ock11111111111111111111111111111111","Vote111111111111111111111111111111111111111"],"header":{"numReadonlySignedAccounts":0,"numReadonlyUnsignedAccounts":3,"numRequiredSignatures":1},"instructions":[{"accounts":[1,2,3,0],"data":"37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1","programIdIndex":4}],"recentBlockhash":"mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B"},"signatures":["2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv"]}}]},"id":1}
|
||||||
|
|
||||||
// Request
|
// Request
|
||||||
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0","id":1,"method":"getConfirmedBlock","params":[430, "binary"]}' localhost:8899
|
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0","id":1,"method":"getConfirmedBlock","params":[430, "base64"]}' localhost:8899
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
{"jsonrpc":"2.0","result":{"blockhash":"Gp3t5bfDsJv1ovP8cB1SuRhXVuoTqDv7p3tymyubYg5","parentSlot":429,"previousBlockhash":"EFejToxii1L5aUF2NrK9dsbAEmZSNyN5nsipmZHQR1eA","transactions":[{"transaction":"81UZJt4dh4Do66jDhrgkQudS8J2N6iG3jaVav7gJrqJSFY4Ug53iA9JFJZh2gxKWcaFdLJwhHx9mRdg9JwDAWB4ywiu5154CRwXV4FMdnPLg7bhxRLwhhYaLsVgMF5AyNRcTzjCVoBvqFgDU7P8VEKDEiMvD3qxzm1pLZVxDG1LTQpT3Dz4Uviv4KQbFQNuC22KupBoyHFB7Zh6KFdMqux4M9PvhoqcoJsJKwXjWpKu7xmEKnnrSbfLadkgjBmmjhW3fdTrFvnhQdTkhtdJxUL1xS9GMuJQer8YgSKNtUXB1eXZQwXU8bU2BjYkZE6Q5Xww8hu9Z4E4Mo4QsooVtHoP6BM3NKw8zjVbWfoCQqxTrwuSzrNCWCWt58C24LHecH67CTt2uXbYSviixvrYkK7A3t68BxTJcF1dXJitEPTFe2ceTkauLJqrJgnER4iUrsjr26T8YgWvpY9wkkWFSviQW6wV5RASTCUasVEcrDiaKj8EQMkgyDoe9HyKitSVg67vMWJFpUXpQobseWJUs5FTWWzmfHmFp8FZ","meta":{"err":null,"fee":18000,"postBalances":[499999972500,15298080,1,1,1],"preBalances":[499999990500,15298080,1,1,1],"status":{"Ok":null}}}]},"id":1}
|
{"jsonrpc":"2.0","result":{"blockTime":null,"blockhash":"3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA","parentSlot":429,"previousBlockhash":"mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B","rewards":[],"transactions":[{"meta":{"err":null,"fee":5000,"postBalances":[499998932500,26858640,1,1,1],"preBalances":[499998937500,26858640,1,1,1],"status":{"Ok":null}},"transaction":["AVj7dxHlQ9IrvdYVIjuiRFs1jLaDMHixgrv+qtHBwz51L4/ImLZhszwiyEJDIp7xeBSpm/TX5B7mYzxa+fPOMw0BAAMFJMJVqLw+hJYheizSoYlLm53KzgT82cDVmazarqQKG2GQsLgiqktA+a+FDR4/7xnDX7rsusMwryYVUdixfz1B1Qan1RcZLwqvxvJl4/t3zHragsUp0L47E24tAFUgAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAHYUgdNXR0u3xNdiTr072z2DVec9EQQ/wNo1OAAAAAAAtxOUhPBp2WSjUNJEgfvy70BbxI00fZyEPvFHNfxrtEAQQEAQIDADUCAAAAAQAAAAAAAACtAQAAAAAAAAdUE18R96XTJCe+YfRfUp6WP+YKCy/72ucOL8AoBFSpAA==","base64"]}]},"id":1}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Transaction Structure
|
#### Transaction Structure
|
||||||
@ -465,14 +465,14 @@ Returns transaction details for a confirmed transaction
|
|||||||
|
|
||||||
- `<string>` - transaction signature as base-58 encoded string
|
- `<string>` - transaction signature as base-58 encoded string
|
||||||
N encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If parsed-JSON is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields).
|
N encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If parsed-JSON is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields).
|
||||||
- `<string>` - (optional) encoding for the returned Transaction, either "json", "jsonParsed", or "binary". **jsonParsed encoding is UNSTABLE**
|
- `<string>` - (optional) encoding for the returned Transaction, either "json", "jsonParsed", "base58" (*slow*), or "base64". If parameter not provided, the default encoding is JSON. **jsonParsed encoding is UNSTABLE**
|
||||||
|
|
||||||
#### Results:
|
#### Results:
|
||||||
|
|
||||||
- `<null>` - if transaction is not found or not confirmed
|
- `<null>` - if transaction is not found or not confirmed
|
||||||
- `<object>` - if transaction is confirmed, an object with the following fields:
|
- `<object>` - if transaction is confirmed, an object with the following fields:
|
||||||
- `slot: <u64>` - the slot this transaction was processed in
|
- `slot: <u64>` - the slot this transaction was processed in
|
||||||
- `transaction: <object|string>` - [Transaction](#transaction-structure) object, either in JSON format or base-58 encoded binary data, depending on encoding parameter
|
- `transaction: <object|[string,encoding]>` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter
|
||||||
- `meta: <object | null>` - transaction status metadata object:
|
- `meta: <object | null>` - transaction status metadata object:
|
||||||
- `err: <object | null>` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/master/sdk/src/transaction.rs#L14)
|
- `err: <object | null>` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/master/sdk/src/transaction.rs#L14)
|
||||||
- `fee: <u64>` - fee this transaction was charged, as u64 integer
|
- `fee: <u64>` - fee this transaction was charged, as u64 integer
|
||||||
@ -486,16 +486,16 @@ N encoding attempts to use program-specific instruction parsers to return more h
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
// Request
|
// Request
|
||||||
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0","id":1,"method":"getConfirmedTransaction","params":["35YGay1Lwjwgxe9zaH6APSHbt9gYQUCtBWTNL3aVwVGn9xTFw2fgds7qK5AL29mP63A9j3rh8KpN1TgSR62XCaby", "json"]}' localhost:8899
|
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0","id":1,"method":"getConfirmedTransaction","params":["2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv", "json"]}' localhost:8899
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
{"jsonrpc":"2.0","result":{"slot":430,"transaction":{"message":{"accountKeys":["6H94zdiaYfRfPfKjYLjyr2VFBg6JHXygy84r3qhc3NsC","39UAy8hsoYPywGPGdmun747omSr79zLSjqvPJN3zetoH","SysvarS1otHashes111111111111111111111111111","SysvarC1ock11111111111111111111111111111111","Vote111111111111111111111111111111111111111"],"header":{"numReadonlySignedAccounts":0,"numReadonlyUnsignedAccounts":3,"numRequiredSignatures":2},"instructions":[{"accounts":[1,2,3],"data":"29z5mr1JoRmJYQ6ynmk3pf31cGFRziAF1M3mT3L6sFXf5cKLdkEaMXMT8AqLpD4CpcupHmuMEmtZHpomrwfdZetSomNy3d","programIdIndex":4}],"recentBlockhash":"EFejToxii1L5aUF2NrK9dsbAEmZSNyN5nsipmZHQR1eA"},"signatures":["35YGay1Lwjwgxe9zaH6APSHbt9gYQUCtBWTNL3aVwVGn9xTFw2fgds7qK5AL29mP63A9j3rh8KpN1TgSR62XCaby","4vANMjSKiwEchGSXwVrQkwHnmsbKQmy9vdrsYxWdCup1bLsFzX8gKrFTSVDCZCae2dbxJB9mPNhqB2sD1vvr4sAD"]},"meta":{"err":null,"fee":18000,"postBalances":[499999972500,15298080,1,1,1],"preBalances":[499999990500,15298080,1,1,1],"status":{"Ok":null}}},"id":1}
|
{"jsonrpc":"2.0","result":{"meta":{"err":null,"fee":5000,"postBalances":[499998932500,26858640,1,1,1],"preBalances":[499998937500,26858640,1,1,1],"status":{"Ok":null}},"slot":430,"transaction":{"message":{"accountKeys":["3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe","AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc","SysvarS1otHashes111111111111111111111111111","SysvarC1ock11111111111111111111111111111111","Vote111111111111111111111111111111111111111"],"header":{"numReadonlySignedAccounts":0,"numReadonlyUnsignedAccounts":3,"numRequiredSignatures":1},"instructions":[{"accounts":[1,2,3,0],"data":"37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1","programIdIndex":4}],"recentBlockhash":"mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B"},"signatures":["2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv"]}},"id":1}
|
||||||
|
|
||||||
// Request
|
// Request
|
||||||
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0","id":1,"method":"getConfirmedTransaction","params":["35YGay1Lwjwgxe9zaH6APSHbt9gYQUCtBWTNL3aVwVGn9xTFw2fgds7qK5AL29mP63A9j3rh8KpN1TgSR62XCaby", "binary"]}' localhost:8899
|
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0","id":1,"method":"getConfirmedTransaction","params":["2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv", "base64"]}' localhost:8899
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
{"jsonrpc":"2.0","result":{"slot":430,"transaction":"81UZJt4dh4Do66jDhrgkQudS8J2N6iG3jaVav7gJrqJSFY4Ug53iA9JFJZh2gxKWcaFdLJwhHx9mRdg9JwDAWB4ywiu5154CRwXV4FMdnPLg7bhxRLwhhYaLsVgMF5AyNRcTzjCVoBvqFgDU7P8VEKDEiMvD3qxzm1pLZVxDG1LTQpT3Dz4Uviv4KQbFQNuC22KupBoyHFB7Zh6KFdMqux4M9PvhoqcoJsJKwXjWpKu7xmEKnnrSbfLadkgjBmmjhW3fdTrFvnhQdTkhtdJxUL1xS9GMuJQer8YgSKNtUXB1eXZQwXU8bU2BjYkZE6Q5Xww8hu9Z4E4Mo4QsooVtHoP6BM3NKw8zjVbWfoCQqxTrwuSzrNCWCWt58C24LHecH67CTt2uXbYSviixvrYkK7A3t68BxTJcF1dXJitEPTFe2ceTkauLJqrJgnER4iUrsjr26T8YgWvpY9wkkWFSviQW6wV5RASTCUasVEcrDiaKj8EQMkgyDoe9HyKitSVg67vMWJFpUXpQobseWJUs5FTWWzmfHmFp8FZ","meta":{"err":null,"fee":18000,"postBalances":[499999972500,15298080,1,1,1],"preBalances":[499999990500,15298080,1,1,1],"status":{"Ok":null}}},"id":1}
|
{"jsonrpc":"2.0","result":{"meta":{"err":null,"fee":5000,"postBalances":[499998932500,26858640,1,1,1],"preBalances":[499998937500,26858640,1,1,1],"status":{"Ok":null}},"slot":430,"transaction":["AVj7dxHlQ9IrvdYVIjuiRFs1jLaDMHixgrv+qtHBwz51L4/ImLZhszwiyEJDIp7xeBSpm/TX5B7mYzxa+fPOMw0BAAMFJMJVqLw+hJYheizSoYlLm53KzgT82cDVmazarqQKG2GQsLgiqktA+a+FDR4/7xnDX7rsusMwryYVUdixfz1B1Qan1RcZLwqvxvJl4/t3zHragsUp0L47E24tAFUgAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAHYUgdNXR0u3xNdiTr072z2DVec9EQQ/wNo1OAAAAAAAtxOUhPBp2WSjUNJEgfvy70BbxI00fZyEPvFHNfxrtEAQQEAQIDADUCAAAAAQAAAAAAAACtAQAAAAAAAAdUE18R96XTJCe+YfRfUp6WP+YKCy/72ucOL8AoBFSpAA==","base64"]},"id":1}
|
||||||
```
|
```
|
||||||
|
|
||||||
### getEpochInfo
|
### getEpochInfo
|
||||||
@ -845,9 +845,9 @@ Returns all accounts owned by the provided program Pubkey
|
|||||||
- `<string>` - Pubkey of program, as base-58 encoded string
|
- `<string>` - Pubkey of program, as base-58 encoded string
|
||||||
- `<object>` - (optional) Configuration object containing the following optional fields:
|
- `<object>` - (optional) Configuration object containing the following optional fields:
|
||||||
- (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment)
|
- (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment)
|
||||||
- (optional) `encoding: <string>` - encoding for Account data, either "binary" or jsonParsed". If parameter not provided, the default encoding is binary.
|
- `encoding: <string>` - encoding for Account data, either "base58" (*slow*), "base64" or jsonParsed".
|
||||||
Parsed-JSON encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If parsed-JSON is requested but a parser cannot be found, the field falls back to binary encoding, detectable when the `data` field is type `<string>`. **jsonParsed encoding is UNSTABLE**
|
Parsed-JSON encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If parsed-JSON is requested but a parser cannot be found, the field falls back to base64 encoding, detectable when the `data` field is type `<string>`. **jsonParsed encoding is UNSTABLE**
|
||||||
- (optional) `dataSlice: <object>` - limit the returned account data using the provided `offset: <usize>` and `length: <usize>` fields; only available for "binary" or "binary64" encoding.
|
- (optional) `dataSlice: <object>` - limit the returned account data using the provided `offset: <usize>` and `length: <usize>` fields; only available for "base58" or "base64" encoding.
|
||||||
- (optional) `filters: <array>` - filter results using various [filter objects](jsonrpc-api.md#filters); account must meet all filter criteria to be included in results
|
- (optional) `filters: <array>` - filter results using various [filter objects](jsonrpc-api.md#filters); account must meet all filter criteria to be included in results
|
||||||
|
|
||||||
##### Filters:
|
##### Filters:
|
||||||
@ -865,7 +865,7 @@ The result field will be an array of JSON objects, which will contain:
|
|||||||
- `account: <object>` - a JSON object, with the following sub fields:
|
- `account: <object>` - a JSON object, with the following sub fields:
|
||||||
- `lamports: <u64>`, number of lamports assigned to this account, as a u64
|
- `lamports: <u64>`, number of lamports assigned to this account, as a u64
|
||||||
- `owner: <string>`, base-58 encoded Pubkey of the program this account has been assigned to
|
- `owner: <string>`, base-58 encoded Pubkey of the program this account has been assigned to
|
||||||
`data: <string|object>`, data associated with the account, either as base-58 encoded binary data or JSON format `{<program>: <state>}`, depending on encoding parameter
|
`data: <[string,encoding]|object>`, data associated with the account, either as encoded binary data or JSON format `{<program>: <state>}`, depending on encoding parameter
|
||||||
- `executable: <bool>`, boolean indicating if the account contains a program \(and is strictly read-only\)
|
- `executable: <bool>`, boolean indicating if the account contains a program \(and is strictly read-only\)
|
||||||
- `rentEpoch: <u64>`, the epoch at which this account will next owe rent, as u64
|
- `rentEpoch: <u64>`, the epoch at which this account will next owe rent, as u64
|
||||||
|
|
||||||
@ -1100,9 +1100,9 @@ Returns all SPL Token accounts by approved Delegate. **UNSTABLE**
|
|||||||
* `programId: <string>` - Pubkey of the Token program ID that owns the accounts, as base-58 encoded string
|
* `programId: <string>` - Pubkey of the Token program ID that owns the accounts, as base-58 encoded string
|
||||||
- `<object>` - (optional) Configuration object containing the following optional fields:
|
- `<object>` - (optional) Configuration object containing the following optional fields:
|
||||||
- (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment)
|
- (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment)
|
||||||
- (optional) `encoding: <string>` - encoding for Account data, either "binary" or jsonParsed". If parameter not provided, the default encoding is binary.
|
- `encoding: <string>` - encoding for Account data, either "base58" (*slow*), "base64" or jsonParsed".
|
||||||
Parsed-JSON encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If parsed-JSON is requested but a parser cannot be found, the field falls back to binary encoding, detectable when the `data` field is type `<string>`. **jsonParsed encoding is UNSTABLE**
|
Parsed-JSON encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If parsed-JSON is requested but a parser cannot be found, the field falls back to binary encoding, detectable when the `data` field is type `<string>`. **jsonParsed encoding is UNSTABLE**
|
||||||
- (optional) `dataSlice: <object>` - limit the returned account data using the provided `offset: <usize>` and `length: <usize>` fields; only available for "binary" or "binary64" encoding.
|
- (optional) `dataSlice: <object>` - limit the returned account data using the provided `offset: <usize>` and `length: <usize>` fields; only available for "base58" or "base64" encoding.
|
||||||
|
|
||||||
#### Results:
|
#### Results:
|
||||||
|
|
||||||
@ -1112,7 +1112,7 @@ The result will be an RpcResponse JSON object with `value` equal to an array of
|
|||||||
- `account: <object>` - a JSON object, with the following sub fields:
|
- `account: <object>` - a JSON object, with the following sub fields:
|
||||||
- `lamports: <u64>`, number of lamports assigned to this account, as a u64
|
- `lamports: <u64>`, number of lamports assigned to this account, as a u64
|
||||||
- `owner: <string>`, base-58 encoded Pubkey of the program this account has been assigned to
|
- `owner: <string>`, base-58 encoded Pubkey of the program this account has been assigned to
|
||||||
- `data: <object>`, Token state data associated with the account, either as base-58 encoded binary data or in JSON format `{<program>: <state>}`
|
- `data: <object>`, Token state data associated with the account, either as encoded binary data or in JSON format `{<program>: <state>}`
|
||||||
- `executable: <bool>`, boolean indicating if the account contains a program \(and is strictly read-only\)
|
- `executable: <bool>`, boolean indicating if the account contains a program \(and is strictly read-only\)
|
||||||
- `rentEpoch: <u64>`, the epoch at which this account will next owe rent, as u64
|
- `rentEpoch: <u64>`, the epoch at which this account will next owe rent, as u64
|
||||||
|
|
||||||
@ -1137,9 +1137,9 @@ Returns all SPL Token accounts by token owner. **UNSTABLE**
|
|||||||
* `programId: <string>` - Pubkey of the Token program ID that owns the accounts, as base-58 encoded string
|
* `programId: <string>` - Pubkey of the Token program ID that owns the accounts, as base-58 encoded string
|
||||||
- `<object>` - (optional) Configuration object containing the following optional fields:
|
- `<object>` - (optional) Configuration object containing the following optional fields:
|
||||||
- (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment)
|
- (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment)
|
||||||
- (optional) `encoding: <string>` - encoding for Account data, either "binary" or jsonParsed". If parameter not provided, the default encoding is binary.
|
- `encoding: <string>` - encoding for Account data, either "base58" (*slow*), "base64" or jsonParsed".
|
||||||
Parsed-JSON encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If parsed-JSON is requested but a parser cannot be found, the field falls back to binary encoding, detectable when the `data` field is type `<string>`. **jsonParsed encoding is UNSTABLE**
|
Parsed-JSON encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If parsed-JSON is requested but a parser cannot be found, the field falls back to binary encoding, detectable when the `data` field is type `<string>`. **jsonParsed encoding is UNSTABLE**
|
||||||
- (optional) `dataSlice: <object>` - limit the returned account data using the provided `offset: <usize>` and `length: <usize>` fields; only available for "binary" or "binary64" encoding.
|
- (optional) `dataSlice: <object>` - limit the returned account data using the provided `offset: <usize>` and `length: <usize>` fields; only available for "base58" or "base64" encoding.
|
||||||
|
|
||||||
#### Results:
|
#### Results:
|
||||||
|
|
||||||
@ -1149,7 +1149,7 @@ The result will be an RpcResponse JSON object with `value` equal to an array of
|
|||||||
- `account: <object>` - a JSON object, with the following sub fields:
|
- `account: <object>` - a JSON object, with the following sub fields:
|
||||||
- `lamports: <u64>`, number of lamports assigned to this account, as a u64
|
- `lamports: <u64>`, number of lamports assigned to this account, as a u64
|
||||||
- `owner: <string>`, base-58 encoded Pubkey of the program this account has been assigned to
|
- `owner: <string>`, base-58 encoded Pubkey of the program this account has been assigned to
|
||||||
- `data: <object>`, Token state data associated with the account, either as base-58 encoded binary data or in JSON format `{<program>: <state>}`
|
- `data: <object>`, Token state data associated with the account, either as encoded binary data or in JSON format `{<program>: <state>}`
|
||||||
- `executable: <bool>`, boolean indicating if the account contains a program \(and is strictly read-only\)
|
- `executable: <bool>`, boolean indicating if the account contains a program \(and is strictly read-only\)
|
||||||
- `rentEpoch: <u64>`, the epoch at which this account will next owe rent, as u64
|
- `rentEpoch: <u64>`, the epoch at which this account will next owe rent, as u64
|
||||||
|
|
||||||
@ -1457,7 +1457,7 @@ Subscribe to an account to receive notifications when the lamports or data for a
|
|||||||
- `<string>` - account Pubkey, as base-58 encoded string
|
- `<string>` - account Pubkey, as base-58 encoded string
|
||||||
- `<object>` - (optional) Configuration object containing the following optional fields:
|
- `<object>` - (optional) Configuration object containing the following optional fields:
|
||||||
- `<object>` - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment)
|
- `<object>` - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment)
|
||||||
- (optional) `encoding: <string>` - encoding for Account data, either "binary" or jsonParsed". If parameter not provided, the default encoding is binary.
|
- `encoding: <string>` - encoding for Account data, either "base58" (*slow*), "base64" or jsonParsed".
|
||||||
Parsed-JSON encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If parsed-JSON is requested but a parser cannot be found, the field falls back to binary encoding, detectable when the `data` field is type `<string>`. **jsonParsed encoding is UNSTABLE**
|
Parsed-JSON encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If parsed-JSON is requested but a parser cannot be found, the field falls back to binary encoding, detectable when the `data` field is type `<string>`. **jsonParsed encoding is UNSTABLE**
|
||||||
|
|
||||||
#### Results:
|
#### Results:
|
||||||
@ -1468,9 +1468,9 @@ Subscribe to an account to receive notifications when the lamports or data for a
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
// Request
|
// Request
|
||||||
{"jsonrpc":"2.0", "id":1, "method":"accountSubscribe", "params":["CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12"]}
|
{"jsonrpc":"2.0", "id":1, "method":"accountSubscribe", "params":["CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12", {"encoding":"base58"}]}
|
||||||
|
|
||||||
{"jsonrpc":"2.0", "id":1, "method":"accountSubscribe", "params":["CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12", {"commitment": "single"}]}
|
{"jsonrpc":"2.0", "id":1, "method":"accountSubscribe", "params":["CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12", {"encoding":"base64", "commitment": "single"}]}
|
||||||
|
|
||||||
{"jsonrpc":"2.0", "id":1, "method":"accountSubscribe", "params":["CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12", {"encoding":"jsonParsed"}]}
|
{"jsonrpc":"2.0", "id":1, "method":"accountSubscribe", "params":["CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12", {"encoding":"jsonParsed"}]}
|
||||||
|
|
||||||
@ -1481,7 +1481,7 @@ Subscribe to an account to receive notifications when the lamports or data for a
|
|||||||
#### Notification Format:
|
#### Notification Format:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
// Binary encoding
|
// Base58 encoding
|
||||||
{
|
{
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"method": "accountNotification",
|
"method": "accountNotification",
|
||||||
@ -1491,7 +1491,7 @@ Subscribe to an account to receive notifications when the lamports or data for a
|
|||||||
"slot": 5199307
|
"slot": 5199307
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
"data": "11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHPXHRDEHrBesJhZyqnnq9qJeUuF7WHxiuLuL5twc38w2TXNLxnDbjmuR",
|
"data": ["11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHPXHRDEHrBesJhZyqnnq9qJeUuF7WHxiuLuL5twc38w2TXNLxnDbjmuR", "base58"],
|
||||||
"executable": false,
|
"executable": false,
|
||||||
"lamports": 33594,
|
"lamports": 33594,
|
||||||
"owner": "11111111111111111111111111111111",
|
"owner": "11111111111111111111111111111111",
|
||||||
@ -1567,8 +1567,8 @@ Subscribe to a program to receive notifications when the lamports or data for a
|
|||||||
- `<string>` - program_id Pubkey, as base-58 encoded string
|
- `<string>` - program_id Pubkey, as base-58 encoded string
|
||||||
- `<object>` - (optional) Configuration object containing the following optional fields:
|
- `<object>` - (optional) Configuration object containing the following optional fields:
|
||||||
- (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment)
|
- (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment)
|
||||||
- (optional) `encoding: <string>` - encoding for Account data, either "binary" or jsonParsed". If parameter not provided, the default encoding is binary.
|
- `encoding: <string>` - encoding for Account data, either "base58" (*slow*), "base64" or jsonParsed".
|
||||||
Parsed-JSON encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If parsed-JSON is requested but a parser cannot be found, the field falls back to binary encoding, detectable when the `data` field is type `<string>`. **jsonParsed encoding is UNSTABLE**
|
Parsed-JSON encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If parsed-JSON is requested but a parser cannot be found, the field falls back to base64 encoding, detectable when the `data` field is type `<string>`. **jsonParsed encoding is UNSTABLE**
|
||||||
- (optional) `filters: <array>` - filter results using various [filter objects](jsonrpc-api.md#filters); account must meet all filter criteria to be included in results
|
- (optional) `filters: <array>` - filter results using various [filter objects](jsonrpc-api.md#filters); account must meet all filter criteria to be included in results
|
||||||
|
|
||||||
#### Results:
|
#### Results:
|
||||||
@ -1579,13 +1579,11 @@ Subscribe to a program to receive notifications when the lamports or data for a
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
// Request
|
// Request
|
||||||
{"jsonrpc":"2.0", "id":1, "method":"programSubscribe", "params":["11111111111111111111111111111111"]}
|
{"jsonrpc":"2.0", "id":1, "method":"programSubscribe", "params":["11111111111111111111111111111111", {"encoding":"base64", "commitment": "single"}]}
|
||||||
|
|
||||||
{"jsonrpc":"2.0", "id":1, "method":"programSubscribe", "params":["11111111111111111111111111111111", {"commitment": "single"}]}
|
|
||||||
|
|
||||||
{"jsonrpc":"2.0", "id":1, "method":"programSubscribe", "params":["11111111111111111111111111111111", {"encoding":"jsonParsed"}]}
|
{"jsonrpc":"2.0", "id":1, "method":"programSubscribe", "params":["11111111111111111111111111111111", {"encoding":"jsonParsed"}]}
|
||||||
|
|
||||||
{"jsonrpc":"2.0", "id":1, "method":"programSubscribe", "params":["11111111111111111111111111111111", {"filters":[{"dataSize":80}]}]}
|
{"jsonrpc":"2.0", "id":1, "method":"programSubscribe", "params":["11111111111111111111111111111111", {"encoding":"base64", "filters":[{"dataSize":80}]}]}
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
{"jsonrpc": "2.0","result": 24040,"id": 1}
|
{"jsonrpc": "2.0","result": 24040,"id": 1}
|
||||||
@ -1594,7 +1592,7 @@ Subscribe to a program to receive notifications when the lamports or data for a
|
|||||||
#### Notification Format:
|
#### Notification Format:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
// Binary encoding
|
// Base58 encoding
|
||||||
{
|
{
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"method": "programNotification",
|
"method": "programNotification",
|
||||||
@ -1606,7 +1604,7 @@ Subscribe to a program to receive notifications when the lamports or data for a
|
|||||||
"value": {
|
"value": {
|
||||||
"pubkey": "H4vnBqifaSACnKa7acsxstsY1iV1bvJNxsCY7enrd1hq"
|
"pubkey": "H4vnBqifaSACnKa7acsxstsY1iV1bvJNxsCY7enrd1hq"
|
||||||
"account": {
|
"account": {
|
||||||
"data": "11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHPXHRDEHrBesJhZyqnnq9qJeUuF7WHxiuLuL5twc38w2TXNLxnDbjmuR",
|
"data": ["11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHPXHRDEHrBesJhZyqnnq9qJeUuF7WHxiuLuL5twc38w2TXNLxnDbjmuR", "base58"],
|
||||||
"executable": false,
|
"executable": false,
|
||||||
"lamports": 33594,
|
"lamports": 33594,
|
||||||
"owner": "11111111111111111111111111111111",
|
"owner": "11111111111111111111111111111111",
|
||||||
|
@ -134,7 +134,7 @@ async fn upload(
|
|||||||
for (i, slot) in blocks_to_upload.iter().enumerate() {
|
for (i, slot) in blocks_to_upload.iter().enumerate() {
|
||||||
let _ = match blockstore.get_confirmed_block(
|
let _ = match blockstore.get_confirmed_block(
|
||||||
*slot,
|
*slot,
|
||||||
Some(solana_transaction_status::UiTransactionEncoding::Binary),
|
Some(solana_transaction_status::UiTransactionEncoding::Base64),
|
||||||
) {
|
) {
|
||||||
Ok(confirmed_block) => sender.send((*slot, Some(confirmed_block))),
|
Ok(confirmed_block) => sender.send((*slot, Some(confirmed_block))),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@ -231,7 +231,7 @@ async fn block(slot: Slot) -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.map_err(|err| format!("Failed to connect to storage: {:?}", err))?;
|
.map_err(|err| format!("Failed to connect to storage: {:?}", err))?;
|
||||||
|
|
||||||
let block = bigtable
|
let block = bigtable
|
||||||
.get_confirmed_block(slot, UiTransactionEncoding::Binary)
|
.get_confirmed_block(slot, UiTransactionEncoding::Base64)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
println!("Slot: {}", slot);
|
println!("Slot: {}", slot);
|
||||||
@ -276,7 +276,7 @@ async fn confirm(signature: &Signature, verbose: bool) -> Result<(), Box<dyn std
|
|||||||
|
|
||||||
if verbose {
|
if verbose {
|
||||||
match bigtable
|
match bigtable
|
||||||
.get_confirmed_transaction(signature, UiTransactionEncoding::Binary)
|
.get_confirmed_transaction(signature, UiTransactionEncoding::Base64)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(Some(confirmed_transaction)) => {
|
Ok(Some(confirmed_transaction)) => {
|
||||||
|
@ -1959,7 +1959,7 @@ impl Blockstore {
|
|||||||
None => return Ok(vec![]),
|
None => return Ok(vec![]),
|
||||||
Some((slot, _)) => {
|
Some((slot, _)) => {
|
||||||
let confirmed_block = self
|
let confirmed_block = self
|
||||||
.get_confirmed_block(slot, Some(UiTransactionEncoding::Binary))
|
.get_confirmed_block(slot, Some(UiTransactionEncoding::Base64))
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
BlockstoreError::IO(IOError::new(
|
BlockstoreError::IO(IOError::new(
|
||||||
ErrorKind::Other,
|
ErrorKind::Other,
|
||||||
@ -2013,7 +2013,7 @@ impl Blockstore {
|
|||||||
None => (0, HashSet::new()),
|
None => (0, HashSet::new()),
|
||||||
Some((slot, _)) => {
|
Some((slot, _)) => {
|
||||||
let confirmed_block = self
|
let confirmed_block = self
|
||||||
.get_confirmed_block(slot, Some(UiTransactionEncoding::Binary))
|
.get_confirmed_block(slot, Some(UiTransactionEncoding::Base64))
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
BlockstoreError::IO(IOError::new(
|
BlockstoreError::IO(IOError::new(
|
||||||
ErrorKind::Other,
|
ErrorKind::Other,
|
||||||
|
@ -267,6 +267,8 @@ fn process_confirmed_block(
|
|||||||
("err", "Transaction signature verification failed", String)
|
("err", "Transaction signature verification failed", String)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
error!("Transaction decode failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,7 +291,7 @@ fn load_blocks(
|
|||||||
let mut blocks = vec![];
|
let mut blocks = vec![];
|
||||||
for slot in slots.into_iter() {
|
for slot in slots.into_iter() {
|
||||||
let block =
|
let block =
|
||||||
rpc_client.get_confirmed_block_with_encoding(slot, UiTransactionEncoding::Binary)?;
|
rpc_client.get_confirmed_block_with_encoding(slot, UiTransactionEncoding::Base64)?;
|
||||||
blocks.push((slot, block));
|
blocks.push((slot, block));
|
||||||
}
|
}
|
||||||
Ok(blocks)
|
Ok(blocks)
|
||||||
|
@ -9,6 +9,7 @@ license = "Apache-2.0"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
base64 = "0.12.3"
|
||||||
bincode = "1.2.1"
|
bincode = "1.2.1"
|
||||||
bs58 = "0.3.1"
|
bs58 = "0.3.1"
|
||||||
Inflector = "0.11.4"
|
Inflector = "0.11.4"
|
||||||
|
@ -217,7 +217,9 @@ pub struct TransactionWithStatusMeta {
|
|||||||
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq)]
|
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum UiTransactionEncoding {
|
pub enum UiTransactionEncoding {
|
||||||
Binary,
|
Binary, // Legacy. Retained for RPC backwards compatibility
|
||||||
|
Base64,
|
||||||
|
Base58,
|
||||||
Json,
|
Json,
|
||||||
JsonParsed,
|
JsonParsed,
|
||||||
}
|
}
|
||||||
@ -225,17 +227,26 @@ pub enum UiTransactionEncoding {
|
|||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase", untagged)]
|
#[serde(rename_all = "camelCase", untagged)]
|
||||||
pub enum EncodedTransaction {
|
pub enum EncodedTransaction {
|
||||||
Binary(String),
|
LegacyBinary(String), // Old way of expressing base-58, retained for RPC backwards compatibility
|
||||||
|
Binary(String, UiTransactionEncoding),
|
||||||
Json(UiTransaction),
|
Json(UiTransaction),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EncodedTransaction {
|
impl EncodedTransaction {
|
||||||
pub fn encode(transaction: Transaction, encoding: UiTransactionEncoding) -> Self {
|
pub fn encode(transaction: Transaction, encoding: UiTransactionEncoding) -> Self {
|
||||||
match encoding {
|
match encoding {
|
||||||
UiTransactionEncoding::Binary => EncodedTransaction::Binary(
|
UiTransactionEncoding::Binary => EncodedTransaction::LegacyBinary(
|
||||||
bs58::encode(bincode::serialize(&transaction).unwrap()).into_string(),
|
bs58::encode(bincode::serialize(&transaction).unwrap()).into_string(),
|
||||||
),
|
),
|
||||||
_ => {
|
UiTransactionEncoding::Base58 => EncodedTransaction::Binary(
|
||||||
|
bs58::encode(bincode::serialize(&transaction).unwrap()).into_string(),
|
||||||
|
encoding,
|
||||||
|
),
|
||||||
|
UiTransactionEncoding::Base64 => EncodedTransaction::Binary(
|
||||||
|
base64::encode(bincode::serialize(&transaction).unwrap()),
|
||||||
|
encoding,
|
||||||
|
),
|
||||||
|
UiTransactionEncoding::Json | UiTransactionEncoding::JsonParsed => {
|
||||||
let message = if encoding == UiTransactionEncoding::Json {
|
let message = if encoding == UiTransactionEncoding::Json {
|
||||||
UiMessage::Raw(UiRawMessage {
|
UiMessage::Raw(UiRawMessage {
|
||||||
header: transaction.message.header,
|
header: transaction.message.header,
|
||||||
@ -298,10 +309,22 @@ impl EncodedTransaction {
|
|||||||
pub fn decode(&self) -> Option<Transaction> {
|
pub fn decode(&self) -> Option<Transaction> {
|
||||||
match self {
|
match self {
|
||||||
EncodedTransaction::Json(_) => None,
|
EncodedTransaction::Json(_) => None,
|
||||||
EncodedTransaction::Binary(blob) => bs58::decode(blob)
|
EncodedTransaction::LegacyBinary(blob) => bs58::decode(blob)
|
||||||
.into_vec()
|
.into_vec()
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|bytes| bincode::deserialize(&bytes).ok()),
|
.and_then(|bytes| bincode::deserialize(&bytes).ok()),
|
||||||
|
EncodedTransaction::Binary(blob, encoding) => match *encoding {
|
||||||
|
UiTransactionEncoding::Base58 => bs58::decode(blob)
|
||||||
|
.into_vec()
|
||||||
|
.ok()
|
||||||
|
.and_then(|bytes| bincode::deserialize(&bytes).ok()),
|
||||||
|
UiTransactionEncoding::Base64 => base64::decode(blob)
|
||||||
|
.ok()
|
||||||
|
.and_then(|bytes| bincode::deserialize(&bytes).ok()),
|
||||||
|
UiTransactionEncoding::Binary
|
||||||
|
| UiTransactionEncoding::Json
|
||||||
|
| UiTransactionEncoding::JsonParsed => None,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ fn load_blocks(
|
|||||||
let mut blocks = vec![];
|
let mut blocks = vec![];
|
||||||
for slot in slots.into_iter() {
|
for slot in slots.into_iter() {
|
||||||
let block =
|
let block =
|
||||||
rpc_client.get_confirmed_block_with_encoding(slot, UiTransactionEncoding::Binary)?;
|
rpc_client.get_confirmed_block_with_encoding(slot, UiTransactionEncoding::Base64)?;
|
||||||
blocks.push((slot, block));
|
blocks.push((slot, block));
|
||||||
}
|
}
|
||||||
Ok(blocks)
|
Ok(blocks)
|
||||||
|
Reference in New Issue
Block a user