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(
21 default,
22 rename = "fundingstreams",
23 skip_serializing_if = "Vec::is_empty"
24 )]
25 pub(crate) funding_streams: Vec<FundingStream>,
26
27 #[serde(
30 default,
31 rename = "lockboxstreams",
32 skip_serializing_if = "Vec::is_empty"
33 )]
34 pub(crate) lockbox_streams: Vec<FundingStream>,
35
36 #[getter(copy)]
40 pub(crate) miner: Zec<NonNegative>,
41
42 #[getter(copy)]
47 pub(crate) founders: Zec<NonNegative>,
48
49 #[serde(rename = "fundingstreamstotal")]
51 #[getter(copy)]
52 pub(crate) funding_streams_total: Zec<NonNegative>,
53
54 #[serde(rename = "lockboxtotal")]
56 #[getter(copy)]
57 pub(crate) lockbox_total: Zec<NonNegative>,
58
59 #[serde(rename = "totalblocksubsidy")]
63 #[getter(copy)]
64 pub(crate) total_block_subsidy: Zec<NonNegative>,
65}
66
67#[deprecated(note = "Use `GetBlockSubsidyResponse` instead")]
68pub use self::GetBlockSubsidyResponse as BlockSubsidy;
69
70#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, Getters, new)]
72pub struct FundingStream {
73 pub recipient: String,
75
76 pub specification: String,
78
79 #[getter(copy)]
81 pub value: Zec<NonNegative>,
82
83 #[serde(rename = "valueZat")]
85 #[getter(copy)]
86 pub value_zat: Amount<NonNegative>,
87
88 #[serde(skip_serializing_if = "Option::is_none")]
95 pub address: Option<transparent::Address>,
96}
97
98impl FundingStream {
99 pub(crate) fn new_internal(
101 is_post_nu6: bool,
102 receiver: FundingStreamReceiver,
103 value: Amount<NonNegative>,
104 address: Option<&transparent::Address>,
105 ) -> FundingStream {
106 let (name, specification) = receiver.info(is_post_nu6);
107
108 FundingStream {
109 recipient: name.to_string(),
110 specification: specification.to_string(),
111 value: value.into(),
112 value_zat: value,
113 address: address.cloned(),
114 }
115 }
116}