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
72 lines (64 loc) · 2.75 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
65
66
67
68
69
70
71
72
// 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::ParseAmountError;
use bitcoin::hex::HexToArrayError;
use bitcoin::{Amount, FeeRate, Txid, Wtxid};
/// Models the result of JSON-RPC method `sendrawtransaction`.
#[derive(Clone, Debug, PartialEq)]
pub struct SendRawTransaction(pub Txid);
#[derive(Clone, Debug, PartialEq)]
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`].
pub tx_results: HashMap<Wtxid, SubmitPackageTxResult>,
/// List of txids of replaced transactions.
pub replaced_transactions: Vec<Txid>,
}
/// Models the per-transaction result included in the JSON-RPC method `submitpackage`.
#[derive(Clone, Debug, PartialEq)]
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.
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)]
pub struct SubmitPackageTxResultFees {
/// Transaction fee.
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.
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.
pub effective_includes: Vec<Wtxid>,
}
/// Error when converting a `SubmitPackageTxResultFees` type into the model type.
#[derive(Debug)]
pub enum SubmitPackageError {
/// Conversion of a `Txid` failed.
Txid(HexToArrayError),
/// Conversion of a `Wtxid` failed.
Wtxid(HexToArrayError),
/// Conversion of the `base_fee` field failed.
BaseFee(ParseAmountError),
/// Conversion of the `vsize` field failed.
Vsize,
}