kaspa_consensus_core/
coinbase.rs

1use crate::tx::{ScriptPublicKey, Transaction};
2use serde::{Deserialize, Serialize};
3
4#[derive(PartialEq, Eq, Debug, Clone)]
5pub struct MinerData<T: AsRef<[u8]> = Vec<u8>> {
6    pub script_public_key: ScriptPublicKey,
7    pub extra_data: T,
8}
9
10impl<T: AsRef<[u8]>> MinerData<T> {
11    pub fn new(script_public_key: ScriptPublicKey, extra_data: T) -> Self {
12        Self { script_public_key, extra_data }
13    }
14}
15
16#[derive(PartialEq, Eq, Debug)]
17pub struct CoinbaseData<T: AsRef<[u8]> = Vec<u8>> {
18    pub blue_score: u64,
19    pub subsidy: u64,
20    pub miner_data: MinerData<T>,
21}
22
23#[derive(Clone, Serialize, Deserialize, Debug)]
24pub struct BlockRewardData {
25    pub subsidy: u64,
26    pub total_fees: u64,
27    pub script_public_key: ScriptPublicKey,
28}
29
30impl BlockRewardData {
31    pub fn new(subsidy: u64, total_fees: u64, script_public_key: ScriptPublicKey) -> Self {
32        Self { subsidy, total_fees, script_public_key }
33    }
34}
35
36/// Holds a coinbase transaction along with meta-data obtained during creation
37pub struct CoinbaseTransactionTemplate {
38    pub tx: Transaction,
39    pub has_red_reward: bool, // Does the last output contain reward for red blocks
40}