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