|  | 
| 5 | 5 | //! These structs model the types returned by the JSON-RPC API but have concrete types | 
| 6 | 6 | //! and are not specific to a specific version of Bitcoin Core. | 
| 7 | 7 | 
 | 
| 8 |  | -use bitcoin::Txid; | 
|  | 8 | +use std::collections::HashMap; | 
|  | 9 | + | 
|  | 10 | +use bitcoin::{Amount, FeeRate, Txid, Wtxid}; | 
| 9 | 11 | use serde::{Deserialize, Serialize}; | 
| 10 | 12 | 
 | 
| 11 | 13 | /// Models the result of JSON-RPC method `sendrawtransaction`. | 
| 12 | 14 | #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | 
| 13 | 15 | pub struct SendRawTransaction(pub Txid); | 
|  | 16 | + | 
|  | 17 | +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | 
|  | 18 | +pub struct SubmitPackage { | 
|  | 19 | +    /// The transaction package result message. "success" indicates all transactions were accepted into or are already in the mempool. | 
|  | 20 | +    pub package_msg: String, | 
|  | 21 | +    /// Transaction results keyed by [`Wtxid`]. | 
|  | 22 | +    #[serde(rename = "tx-results")] | 
|  | 23 | +    pub tx_results: HashMap<Wtxid, SubmitPackageTxResult>, | 
|  | 24 | +    /// List of txids of replaced transactions. | 
|  | 25 | +    #[serde(rename = "replaced-transactions")] | 
|  | 26 | +    pub replaced_transactions: Vec<Txid>, | 
|  | 27 | +} | 
|  | 28 | + | 
|  | 29 | +/// Models the per-transaction result included in the JSON-RPC method `submitpackage`. | 
|  | 30 | +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | 
|  | 31 | +pub struct SubmitPackageTxResult { | 
|  | 32 | +    /// The transaction id. | 
|  | 33 | +    pub txid: Txid, | 
|  | 34 | +    /// The [`Wtxid`] of a different transaction with the same [`Txid`] but different witness found in the mempool. | 
|  | 35 | +    /// | 
|  | 36 | +    /// If set, this means the submitted transaction was ignored. | 
|  | 37 | +    #[serde(rename = "other-wtxid")] | 
|  | 38 | +    pub other_wtxid: Option<Wtxid>, | 
|  | 39 | +    /// Sigops-adjusted virtual transaction size. | 
|  | 40 | +    pub vsize: Option<usize>, | 
|  | 41 | +    /// Transaction fees. | 
|  | 42 | +    pub fees: Option<SubmitPackageTxResultFees>, | 
|  | 43 | +    /// The transaction error string, if it was rejected by the mempool | 
|  | 44 | +    pub error: Option<String>, | 
|  | 45 | +} | 
|  | 46 | + | 
|  | 47 | +/// Models the fees included in the per-transaction result of the JSON-RPC method `submitpackage`. | 
|  | 48 | +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | 
|  | 49 | +pub struct SubmitPackageTxResultFees { | 
|  | 50 | +    /// Transaction fee. | 
|  | 51 | +    #[serde(rename = "base")] | 
|  | 52 | +    pub base_fee: Amount, | 
|  | 53 | +    /// The effective feerate. | 
|  | 54 | +    /// | 
|  | 55 | +    /// Will be `None` if the transaction was already in the mempool. | 
|  | 56 | +    /// | 
|  | 57 | +    /// For example, the package feerate and/or feerate with modified fees from the `prioritisetransaction` JSON-RPC method. | 
|  | 58 | +    #[serde(rename = "effective-feerate")] | 
|  | 59 | +    pub effective_feerate: Option<FeeRate>, | 
|  | 60 | +    /// If [`Self::effective_feerate`] is provided, this holds the [`Wtxid`]s of the transactions | 
|  | 61 | +    /// whose fees and vsizes are included in effective-feerate. | 
|  | 62 | +    #[serde(rename = "effective-includes")] | 
|  | 63 | +    pub effective_includes: Vec<Wtxid>, | 
|  | 64 | +} | 
0 commit comments