• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bitcoindevkit / bdk / 11582766320

29 Oct 2024 09:28PM UTC coverage: 82.61%. Remained the same
11582766320

push

github

notmandatory
Merge bitcoindevkit/bdk#1657: chore(deps): bump tibdex/github-app-token from 1 to 2

96c65761e ci: fix dependabot clippy_check error (Steve Myers)
80b4ecac4 chore(deps): bump tibdex/github-app-token from 1 to 2 (dependabot[bot])

Pull request description:

  Bumps [tibdex/github-app-token](https://github.com/tibdex/github-app-token) from 1 to 2.
  <details>
  <summary>Release notes</summary>
  <p><em>Sourced from <a href="https://github.com/tibdex/github-app-token/releases">tibdex/github-app-token's releases</a>.</em></p>
  <blockquote>
  <h2>v2.0.0</h2>
  <ul>
  <li><strong>BREAKING</strong>: replaces the <code>installation_id</code> and <code>repository</code> inputs with <code>installation_retrieval_mode</code> and <code>installation_retrieval_payload</code> to also support organization and user installation.</li>
  <li>switches to <code>node20</code>.</li>
  <li>adds a <code>repositories</code> input to scope the created token to a subset of repositories.</li>
  <li>revokes the created token at the end of the job with a <a href="https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runspost"><code>post</code> script</a>.</li>
  </ul>
  <h2>v1.9.0</h2>
  <p>No release notes provided.</p>
  <h2>v1.8.2</h2>
  <p>No release notes provided.</p>
  <h2>v1.8.1</h2>
  <p>No release notes provided.</p>
  <h2>v1.8.0</h2>
  <p>No release notes provided.</p>
  <h2>v1.7.0</h2>
  <p>No release notes provided.</p>
  <h2>v1.6.0</h2>
  <p>No release notes provided.</p>
  <h2>v1.5.2</h2>
  <p>No release notes provided.</p>
  <h2>v1.5.1</h2>
  <p>No release notes provided.</p>
  <h2>v1.5.0</h2>
  <p>No release notes provided.</p>
  <h2>v1.4.0</h2>
  <p>No release notes provided.</p>
  <h2>v1.3.0</h2>
  <p>No release notes provided.</p>
  <h2>v1.2.0</h2>
  <p>No release notes provided.</p>
  <h2>v1.1.1</h2>
  <p>No release notes provided.</p>
  <h2>v1.1.0</h2>
  <p>No releas... (continued)

11301 of 13680 relevant lines covered (82.61%)

14271.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.94
/crates/wallet/src/wallet/error.rs
1
// Bitcoin Dev Kit
2
// Written in 2020 by Alekos Filini <alekos.filini@gmail.com>
3
//
4
// Copyright (c) 2020-2021 Bitcoin Dev Kit Developers
5
//
6
// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
7
// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
9
// You may not use this file except in accordance with one or both of these
10
// licenses.
11

12
//! Errors that can be thrown by the [`Wallet`](crate::wallet::Wallet)
13

14
use crate::descriptor::policy::PolicyError;
15
use crate::descriptor::DescriptorError;
16
use crate::wallet::coin_selection;
17
use crate::{descriptor, KeychainKind};
18
use alloc::string::String;
19
use bitcoin::{absolute, psbt, Amount, OutPoint, Sequence, Txid};
20
use core::fmt;
21

22
/// Errors returned by miniscript when updating inconsistent PSBTs
23
#[derive(Debug, Clone)]
24
pub enum MiniscriptPsbtError {
25
    /// Descriptor key conversion error
26
    Conversion(miniscript::descriptor::ConversionError),
27
    /// Return error type for PsbtExt::update_input_with_descriptor
28
    UtxoUpdate(miniscript::psbt::UtxoUpdateError),
29
    /// Return error type for PsbtExt::update_output_with_descriptor
30
    OutputUpdate(miniscript::psbt::OutputUpdateError),
31
}
32

33
impl fmt::Display for MiniscriptPsbtError {
34
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
×
35
        match self {
×
36
            Self::Conversion(err) => write!(f, "Conversion error: {}", err),
×
37
            Self::UtxoUpdate(err) => write!(f, "UTXO update error: {}", err),
×
38
            Self::OutputUpdate(err) => write!(f, "Output update error: {}", err),
×
39
        }
40
    }
×
41
}
42

43
#[cfg(feature = "std")]
44
impl std::error::Error for MiniscriptPsbtError {}
45

46
#[derive(Debug)]
47
/// Error returned from [`TxBuilder::finish`]
48
///
49
/// [`TxBuilder::finish`]: crate::wallet::tx_builder::TxBuilder::finish
50
pub enum CreateTxError {
51
    /// There was a problem with the descriptors passed in
52
    Descriptor(DescriptorError),
53
    /// There was a problem while extracting and manipulating policies
54
    Policy(PolicyError),
55
    /// Spending policy is not compatible with this [`KeychainKind`]
56
    SpendingPolicyRequired(KeychainKind),
57
    /// Requested invalid transaction version '0'
58
    Version0,
59
    /// Requested transaction version `1`, but at least `2` is needed to use OP_CSV
60
    Version1Csv,
61
    /// Requested `LockTime` is less than is required to spend from this script
62
    LockTime {
63
        /// Requested `LockTime`
64
        requested: absolute::LockTime,
65
        /// Required `LockTime`
66
        required: absolute::LockTime,
67
    },
68
    /// Cannot enable RBF with `Sequence` given a required OP_CSV
69
    RbfSequenceCsv {
70
        /// Given RBF `Sequence`
71
        sequence: Sequence,
72
        /// Required OP_CSV `Sequence`
73
        csv: Sequence,
74
    },
75
    /// When bumping a tx the absolute fee requested is lower than replaced tx absolute fee
76
    FeeTooLow {
77
        /// Required fee absolute value [`Amount`]
78
        required: Amount,
79
    },
80
    /// When bumping a tx the fee rate requested is lower than required
81
    FeeRateTooLow {
82
        /// Required fee rate
83
        required: bitcoin::FeeRate,
84
    },
85
    /// `manually_selected_only` option is selected but no utxo has been passed
86
    NoUtxosSelected,
87
    /// Output created is under the dust limit, 546 satoshis
88
    OutputBelowDustLimit(usize),
89
    /// There was an error with coin selection
90
    CoinSelection(coin_selection::InsufficientFunds),
91
    /// Cannot build a tx without recipients
92
    NoRecipients,
93
    /// Partially signed bitcoin transaction error
94
    Psbt(psbt::Error),
95
    /// In order to use the [`TxBuilder::add_global_xpubs`] option every extended
96
    /// key in the descriptor must either be a master key itself (having depth = 0) or have an
97
    /// explicit origin provided
98
    ///
99
    /// [`TxBuilder::add_global_xpubs`]: crate::wallet::tx_builder::TxBuilder::add_global_xpubs
100
    MissingKeyOrigin(String),
101
    /// Happens when trying to spend an UTXO that is not in the internal database
102
    UnknownUtxo,
103
    /// Missing non_witness_utxo on foreign utxo for given `OutPoint`
104
    MissingNonWitnessUtxo(OutPoint),
105
    /// Miniscript PSBT error
106
    MiniscriptPsbt(MiniscriptPsbtError),
107
}
108

109
impl fmt::Display for CreateTxError {
110
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
8✔
111
        match self {
8✔
112
            Self::Descriptor(e) => e.fmt(f),
×
113
            Self::Policy(e) => e.fmt(f),
×
114
            CreateTxError::SpendingPolicyRequired(keychain_kind) => {
×
115
                write!(f, "Spending policy required: {:?}", keychain_kind)
×
116
            }
117
            CreateTxError::Version0 => {
118
                write!(f, "Invalid version `0`")
×
119
            }
120
            CreateTxError::Version1Csv => {
121
                write!(
×
122
                    f,
×
123
                    "TxBuilder requested version `1`, but at least `2` is needed to use OP_CSV"
×
124
                )
×
125
            }
126
            CreateTxError::LockTime {
127
                requested,
×
128
                required,
×
129
            } => {
×
130
                write!(f, "TxBuilder requested timelock of `{:?}`, but at least `{:?}` is required to spend from this script", required, requested)
×
131
            }
132
            CreateTxError::RbfSequenceCsv { sequence, csv } => {
×
133
                write!(
×
134
                    f,
×
135
                    "Cannot enable RBF with nSequence `{:?}` given a required OP_CSV of `{:?}`",
×
136
                    sequence, csv
×
137
                )
×
138
            }
139
            CreateTxError::FeeTooLow { required } => {
×
140
                write!(f, "Fee to low: required {}", required.display_dynamic())
×
141
            }
142
            CreateTxError::FeeRateTooLow { required } => {
8✔
143
                write!(
8✔
144
                    f,
8✔
145
                    // Note: alternate fmt as sat/vb (ceil) available in bitcoin-0.31
8✔
146
                    //"Fee rate too low: required {required:#}"
8✔
147
                    "Fee rate too low: required {} sat/vb",
8✔
148
                    crate::floating_rate!(required)
8✔
149
                )
8✔
150
            }
151
            CreateTxError::NoUtxosSelected => {
152
                write!(f, "No UTXO selected")
×
153
            }
154
            CreateTxError::OutputBelowDustLimit(limit) => {
×
155
                write!(f, "Output below the dust limit: {}", limit)
×
156
            }
157
            CreateTxError::CoinSelection(e) => e.fmt(f),
×
158
            CreateTxError::NoRecipients => {
159
                write!(f, "Cannot build tx without recipients")
×
160
            }
161
            CreateTxError::Psbt(e) => e.fmt(f),
×
162
            CreateTxError::MissingKeyOrigin(err) => {
×
163
                write!(f, "Missing key origin: {}", err)
×
164
            }
165
            CreateTxError::UnknownUtxo => {
166
                write!(f, "UTXO not found in the internal database")
×
167
            }
168
            CreateTxError::MissingNonWitnessUtxo(outpoint) => {
×
169
                write!(f, "Missing non_witness_utxo on foreign utxo {}", outpoint)
×
170
            }
171
            CreateTxError::MiniscriptPsbt(err) => {
×
172
                write!(f, "Miniscript PSBT error: {}", err)
×
173
            }
174
        }
175
    }
8✔
176
}
177

178
impl From<descriptor::error::Error> for CreateTxError {
179
    fn from(err: descriptor::error::Error) -> Self {
×
180
        CreateTxError::Descriptor(err)
×
181
    }
×
182
}
183

184
impl From<PolicyError> for CreateTxError {
185
    fn from(err: PolicyError) -> Self {
×
186
        CreateTxError::Policy(err)
×
187
    }
×
188
}
189

190
impl From<MiniscriptPsbtError> for CreateTxError {
191
    fn from(err: MiniscriptPsbtError) -> Self {
×
192
        CreateTxError::MiniscriptPsbt(err)
×
193
    }
×
194
}
195

196
impl From<psbt::Error> for CreateTxError {
197
    fn from(err: psbt::Error) -> Self {
×
198
        CreateTxError::Psbt(err)
×
199
    }
×
200
}
201

202
impl From<coin_selection::InsufficientFunds> for CreateTxError {
203
    fn from(err: coin_selection::InsufficientFunds) -> Self {
×
204
        CreateTxError::CoinSelection(err)
×
205
    }
×
206
}
207

208
#[cfg(feature = "std")]
209
impl std::error::Error for CreateTxError {}
210

211
#[derive(Debug)]
212
/// Error returned from [`Wallet::build_fee_bump`]
213
///
214
/// [`Wallet::build_fee_bump`]: super::Wallet::build_fee_bump
215
pub enum BuildFeeBumpError {
216
    /// Happens when trying to spend an UTXO that is not in the internal database
217
    UnknownUtxo(OutPoint),
218
    /// Thrown when a tx is not found in the internal database
219
    TransactionNotFound(Txid),
220
    /// Happens when trying to bump a transaction that is already confirmed
221
    TransactionConfirmed(Txid),
222
    /// Trying to replace a tx that has a sequence >= `0xFFFFFFFE`
223
    IrreplaceableTransaction(Txid),
224
    /// Node doesn't have data to estimate a fee rate
225
    FeeRateUnavailable,
226
}
227

228
impl fmt::Display for BuildFeeBumpError {
229
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
×
230
        match self {
×
231
            Self::UnknownUtxo(outpoint) => write!(
×
232
                f,
×
233
                "UTXO not found in the internal database with txid: {}, vout: {}",
×
234
                outpoint.txid, outpoint.vout
×
235
            ),
×
236
            Self::TransactionNotFound(txid) => {
×
237
                write!(
×
238
                    f,
×
239
                    "Transaction not found in the internal database with txid: {}",
×
240
                    txid
×
241
                )
×
242
            }
243
            Self::TransactionConfirmed(txid) => {
×
244
                write!(f, "Transaction already confirmed with txid: {}", txid)
×
245
            }
246
            Self::IrreplaceableTransaction(txid) => {
×
247
                write!(f, "Transaction can't be replaced with txid: {}", txid)
×
248
            }
249
            Self::FeeRateUnavailable => write!(f, "Fee rate unavailable"),
×
250
        }
251
    }
×
252
}
253

254
#[cfg(feature = "std")]
255
impl std::error::Error for BuildFeeBumpError {}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc