zebra_rpc/methods/types/
subsidy.rs1use derive_getters::Getters;
4use derive_new::new;
5use zebra_chain::{
6 amount::{Amount, NonNegative},
7 parameters::subsidy::FundingStreamReceiver,
8 transparent,
9};
10
11use super::zec::Zec;
12
13#[derive(
15 Clone, Debug, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize, Getters, new,
16)]
17pub struct GetBlockSubsidyResponse {
18 #[serde(rename = "fundingstreams", skip_serializing_if = "Vec::is_empty")]
21 pub(crate) funding_streams: Vec<FundingStream>,
22
23 #[serde(rename = "lockboxstreams", skip_serializing_if = "Vec::is_empty")]
26 pub(crate) lockbox_streams: Vec<FundingStream>,
27
28 #[getter(copy)]
32 pub(crate) miner: Zec<NonNegative>,
33
34 #[getter(copy)]
39 pub(crate) founders: Zec<NonNegative>,
40
41 #[serde(rename = "fundingstreamstotal")]
43 #[getter(copy)]
44 pub(crate) funding_streams_total: Zec<NonNegative>,
45
46 #[serde(rename = "lockboxtotal")]
48 #[getter(copy)]
49 pub(crate) lockbox_total: Zec<NonNegative>,
50
51 #[serde(rename = "totalblocksubsidy")]
55 #[getter(copy)]
56 pub(crate) total_block_subsidy: Zec<NonNegative>,
57}
58
59#[deprecated(note = "Use `GetBlockSubsidyResponse` instead")]
60pub use self::GetBlockSubsidyResponse as BlockSubsidy;
61
62#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, Getters, new)]
64pub struct FundingStream {
65 pub recipient: String,
67
68 pub specification: String,
70
71 #[getter(copy)]
73 pub value: Zec<NonNegative>,
74
75 #[serde(rename = "valueZat")]
77 #[getter(copy)]
78 pub value_zat: Amount<NonNegative>,
79
80 #[serde(skip_serializing_if = "Option::is_none")]
87 pub address: Option<transparent::Address>,
88}
89
90impl FundingStream {
91 pub(crate) fn new_internal(
93 is_post_nu6: bool,
94 receiver: FundingStreamReceiver,
95 value: Amount<NonNegative>,
96 address: Option<&transparent::Address>,
97 ) -> FundingStream {
98 let (name, specification) = receiver.info(is_post_nu6);
99
100 FundingStream {
101 recipient: name.to_string(),
102 specification: specification.to_string(),
103 value: value.into(),
104 value_zat: value,
105 address: address.cloned(),
106 }
107 }
108}