diff --git a/docs/src/developing/clients/jsonrpc-api.md b/docs/src/developing/clients/jsonrpc-api.md index 51ce4976b0485e..066b175ade29d7 100644 --- a/docs/src/developing/clients/jsonrpc-api.md +++ b/docs/src/developing/clients/jsonrpc-api.md @@ -413,6 +413,12 @@ The result field will be an object with the following fields: - `preTokenBalances: ` - List of [token balances](#token-balances-structure) from before the transaction was processed or omitted if token balance recording was not yet enabled during this transaction - `postTokenBalances: ` - List of [token balances](#token-balances-structure) from after the transaction was processed or omitted if token balance recording was not yet enabled during this transaction - `logMessages: ` - array of string log messages or `null` if log message recording was not enabled during this transaction + - `rewards: ` - transaction-level rewards, populated if rewards are requested; an array of JSON objects containing: + - `pubkey: ` - The public key, as base-58 encoded string, of the account that received the reward + - `lamports: `- number of reward lamports credited or debited by the account, as a i64 + - `postBalance: ` - account balance in lamports after the reward was applied + - `rewardType: ` - type of reward: "fee", "rent", "voting", "staking" + - `commission: ` - vote account commission when the reward was credited, only present for voting and staking rewards - DEPRECATED: `status: ` - Transaction status - `"Ok": ` - Transaction was successful - `"Err": ` - Transaction failed with TransactionError @@ -421,7 +427,7 @@ The result field will be an object with the following fields: - `readonly: ` - Ordered list of base-58 encoded addresses for readonly loaded accounts - `version: <"legacy"|number|undefined>` - Transaction version. Undefined if `maxSupportedTransactionVersion` is not set in request params. - `signatures: ` - present if "signatures" are requested for transaction details; an array of signatures strings, corresponding to the transaction order in the block - - `rewards: ` - present if rewards are requested; an array of JSON objects containing: + - `rewards: ` - block-level rewards, present if rewards are requested; an array of JSON objects containing: - `pubkey: ` - The public key, as base-58 encoded string, of the account that received the reward - `lamports: `- number of reward lamports credited or debited by the account, as a i64 - `postBalance: ` - account balance in lamports after the reward was applied @@ -462,6 +468,7 @@ Result: "postTokenBalances": [], "preBalances": [499998937500, 26858640, 1, 1, 1], "preTokenBalances": [], + "rewards": null, "status": { "Ok": null } @@ -533,6 +540,7 @@ Result: "postTokenBalances": [], "preBalances": [499998937500, 26858640, 1, 1, 1], "preTokenBalances": [], + "rewards": [], "status": { "Ok": null } @@ -2902,7 +2910,7 @@ Returns transaction details for a confirmed transaction - DEPRECATED: `status: ` - Transaction status - `"Ok": ` - Transaction was successful - `"Err": ` - Transaction failed with TransactionError - - `rewards: ` - present if rewards are requested; an array of JSON objects containing: + - `rewards: ` - transaction-level rewards, populated if rewards are requested; an array of JSON objects containing: - `pubkey: ` - The public key, as base-58 encoded string, of the account that received the reward - `lamports: `- number of reward lamports credited or debited by the account, as a i64 - `postBalance: ` - account balance in lamports after the reward was applied @@ -2945,6 +2953,7 @@ Result: "postTokenBalances": [], "preBalances": [499998937500, 26858640, 1, 1, 1], "preTokenBalances": [], + "rewards": [], "status": { "Ok": null } @@ -3015,6 +3024,7 @@ Result: "postTokenBalances": [], "preBalances": [499998937500, 26858640, 1, 1, 1], "preTokenBalances": [], + "rewards": null, "status": { "Ok": null } diff --git a/ledger-tool/src/bigtable.rs b/ledger-tool/src/bigtable.rs index bac7b6cdddfc09..e0551a4b88547a 100644 --- a/ledger-tool/src/bigtable.rs +++ b/ledger-tool/src/bigtable.rs @@ -212,7 +212,7 @@ async fn confirm( let decoded_tx = confirmed_tx.get_transaction(); let encoded_tx_with_meta = confirmed_tx .tx_with_meta - .encode(UiTransactionEncoding::Json, Some(0)) + .encode(UiTransactionEncoding::Json, Some(0), true) .map_err(|_| "Failed to encode transaction in block".to_string())?; transaction = Some(CliTransaction { transaction: encoded_tx_with_meta.transaction, diff --git a/transaction-status/src/lib.rs b/transaction-status/src/lib.rs index 4f1bd7dd20d8dc..d84e4e02042107 100644 --- a/transaction-status/src/lib.rs +++ b/transaction-status/src/lib.rs @@ -349,7 +349,7 @@ impl From<&LoadedAddresses> for UiLoadedAddresses { } impl UiTransactionStatusMeta { - fn parse(meta: TransactionStatusMeta, static_keys: &[Pubkey]) -> Self { + fn parse(meta: TransactionStatusMeta, static_keys: &[Pubkey], show_rewards: bool) -> Self { let account_keys = AccountKeys::new(static_keys, Some(&meta.loaded_addresses)); Self { err: meta.status.clone().err(), @@ -369,7 +369,7 @@ impl UiTransactionStatusMeta { post_token_balances: meta .post_token_balances .map(|balance| balance.into_iter().map(Into::into).collect()), - rewards: meta.rewards, + rewards: if show_rewards { meta.rewards } else { None }, loaded_addresses: None, } } @@ -527,7 +527,11 @@ impl ConfirmedBlock { self.transactions .into_iter() .map(|tx_with_meta| { - tx_with_meta.encode(encoding, options.max_supported_transaction_version) + tx_with_meta.encode( + encoding, + options.max_supported_transaction_version, + options.show_rewards, + ) }) .collect::, _>>()?, ), @@ -646,6 +650,7 @@ impl TransactionWithStatusMeta { self, encoding: UiTransactionEncoding, max_supported_transaction_version: Option, + show_rewards: bool, ) -> Result { match self { Self::MissingMetadata(ref transaction) => Ok(EncodedTransactionWithStatusMeta { @@ -654,7 +659,7 @@ impl TransactionWithStatusMeta { meta: None, }), Self::Complete(tx_with_meta) => { - tx_with_meta.encode(encoding, max_supported_transaction_version) + tx_with_meta.encode(encoding, max_supported_transaction_version, show_rewards) } } } @@ -672,6 +677,7 @@ impl VersionedTransactionWithStatusMeta { self, encoding: UiTransactionEncoding, max_supported_transaction_version: Option, + show_rewards: bool, ) -> Result { let version = match ( max_supported_transaction_version, @@ -698,8 +704,15 @@ impl VersionedTransactionWithStatusMeta { UiTransactionEncoding::JsonParsed => UiTransactionStatusMeta::parse( self.meta, self.transaction.message.static_account_keys(), + show_rewards, ), - _ => UiTransactionStatusMeta::from(self.meta), + _ => { + let mut meta = UiTransactionStatusMeta::from(self.meta); + if !show_rewards { + meta.rewards = None; + } + meta + } }), version, }) @@ -744,9 +757,11 @@ impl ConfirmedTransactionWithStatusMeta { ) -> Result { Ok(EncodedConfirmedTransactionWithStatusMeta { slot: self.slot, - transaction: self - .tx_with_meta - .encode(encoding, max_supported_transaction_version)?, + transaction: self.tx_with_meta.encode( + encoding, + max_supported_transaction_version, + true, + )?, block_time: self.block_time, }) }