diff --git a/rpc/src/v1/types/block_template.rs b/rpc/src/v1/types/block_template.rs new file mode 100644 index 00000000..0647f1a7 --- /dev/null +++ b/rpc/src/v1/types/block_template.rs @@ -0,0 +1,79 @@ +// TODO: remove after implementing getblocktmplate RPC +#![warn(dead_code)] + +use std::collections::HashMap; +use super::hash::H256; +use super::raw_transaction::RawTransaction; + +/// Block template as described in: +/// https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki +/// https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki +/// https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes +/// https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki +pub struct BlockTemplate { + /// The preferred block version + pub version: u32, + /// Specific block rules that are to be enforced + pub rules: Vec, + /// Set of pending, supported versionbit (BIP 9) softfork deployments + /// Keys: named softfork rules + /// Values: identifies the bit number as indicating acceptance and readiness for given key + pub vbavailable: Option>, + /// Bit mask of versionbits the server requires set in submissions + pub vbrequired: Option, + /// The hash of previous (best known) block + pub previousblockhash: H256, + /// Contents of non-coinbase transactions that should be included in the next block + pub transactions: Vec, + /// Data that should be included in the coinbase's scriptSig content + /// Keys: ignored + /// Values: value to be included in scriptSig + pub coinbaseaux: Option>, + /// Maximum allowable input to coinbase transaction, including the generation award and transaction fees (in Satoshis) + pub coinbasevalue: Option, + /// information for coinbase transaction + pub coinbasetxn: Option, + /// The hash target + pub target: H256, + /// The minimum timestamp appropriate for next block time in seconds since epoch (Jan 1 1970 GMT) + pub mintime: Option, + /// List of ways the block template may be changed, e.g. 'time', 'transactions', 'prevblock' + pub mutable: Option>, + /// A range of valid nonces (constant 00000000ffffffff) + pub noncerange: Option, + /// Limit of sigops in blocks + pub sigoplimit: Option, + /// Limit of block size + pub sizelimit: Option, + /// Limit of block weight + pub weightlimit: Option, + /// Current timestamp in seconds since epoch (Jan 1 1970 GMT) + pub curtime: i64, + /// Compressed target of next block + pub bits: u32, + /// The height of the next block + pub height: u32, +} + +/// Transaction data as included in `BlockTemplate` +pub struct BlockTemplateTransaction { + /// Transaction data encoded in hexadecimal + pub data: RawTransaction, + /// Transaction id encoded in little-endian hexadecimal + pub txid: Option, + /// Hash encoded in little-endian hexadecimal (including witness data) + pub hash: Option, + /// Transactions before this one (by 1-based index in 'transactions' list) that must be present in the final block if this one is + pub depends: Option>, + /// Difference in value between transaction inputs and outputs (in Satoshis). + /// For coinbase transactions, this is a negative Number of the total collected block fees (ie, not including the block subsidy). + /// If key is not present, fee is unknown and clients MUST NOT assume there isn't one + pub fee: Option>, + /// Total SigOps cost, as counted for purposes of block limits. + /// If key is not present, sigop cost is unknown and clients MUST NOT assume it is zero. + pub sigops: Option>, + /// Total transaction weight, as counted for purposes of block limits. + pub weight: Option, + /// If provided and true, this transaction must be in the final block + pub required: Option>, +} diff --git a/rpc/src/v1/types/mod.rs.in b/rpc/src/v1/types/mod.rs.in index 82b9a583..d89bd53e 100644 --- a/rpc/src/v1/types/mod.rs.in +++ b/rpc/src/v1/types/mod.rs.in @@ -1,7 +1,9 @@ +mod block_template; mod bytes; mod hash; mod raw_transaction; +pub use self::block_template::{BlockTemplate, BlockTemplateTransaction}; pub use self::bytes::Bytes; pub use self::hash::H256; pub use self::raw_transaction::RawTransaction;