Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rpc): Implement the getblocksubsidy RPC #6032

Merged
merged 15 commits into from
Jan 31, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Format getblocksubsidy fields in Zec
teor2345 committed Jan 26, 2023

Verified

This commit was signed with the committer’s verified signature.
Lord-Kamina Gregorio Litenstein
commit 1920c0103d4a13e21ec41a46bb12f3ce6ae0de5e
4 changes: 2 additions & 2 deletions zebra-rpc/src/methods/get_block_template_rpcs.rs
Original file line number Diff line number Diff line change
@@ -812,8 +812,8 @@ where
.collect();

Ok(BlockSubsidy {
miner,
founders,
miner: miner.into(),
founders: founders.into(),
funding_streams,
})
}
13 changes: 5 additions & 8 deletions zebra-rpc/src/methods/get_block_template_rpcs/types/subsidy.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Types for the `getblocksubsidy` RPC.

use zebra_chain::{
amount::{Amount, NonNegative},
amount::{Amount, NonNegative, Zec},
transparent,
};
use zebra_consensus::{funding_stream_recipient_info, FundingStreamReceiver};
@@ -12,16 +12,13 @@ pub struct BlockSubsidy {
/// The mining reward amount in ZEC.
///
/// This does not include the miner fee.
//
// TODO: format ZEC amounts as fixed-point decimal, like `zcashd`:
// https://github.com/zcash/zcash/blob/f6a4f68115ea4c58d55c8538579d0877ba9c8f79/src/rpc/server.cpp#L127-L135
pub miner: Amount<NonNegative>,
pub miner: Zec<NonNegative>,

/// The founders' reward amount in ZEC.
///
/// Zebra returns an error when asked for founders reward heights,
/// because it checkpoints those blocks instead.
pub founders: Amount<NonNegative>,
pub founders: Zec<NonNegative>,

/// An array of funding stream descriptions.
/// Always present, because Zebra returns an error for heights before the first halving.
@@ -39,7 +36,7 @@ pub struct FundingStream {
pub specification: String,

/// The funding stream amount in ZEC.
pub value: Amount<NonNegative>,
pub value: Zec<NonNegative>,

/// The funding stream amount in zatoshis.
#[serde(rename = "valueZat")]
@@ -64,7 +61,7 @@ impl FundingStream {
FundingStream {
recipient: recipient.to_string(),
specification: specification.to_string(),
value,
value: value.into(),
value_zat: value,
address,
}