|
31 | 31 | //! // With a custom fee rate of 5.0 satoshi/vbyte |
32 | 32 | //! .fee_rate(FeeRate::from_sat_per_vb(5).expect("valid feerate")) |
33 | 33 | //! // Only spend non-change outputs |
34 | | -//! .do_not_spend_change() |
35 | | -//! // Turn on RBF signaling |
36 | | -//! .enable_rbf(); |
| 34 | +//! .do_not_spend_change(); |
37 | 35 | //! let psbt = tx_builder.finish()?; |
38 | 36 | //! # Ok::<(), anyhow::Error>(()) |
39 | 37 | //! ``` |
@@ -134,7 +132,7 @@ pub(crate) struct TxParams { |
134 | 132 | pub(crate) sighash: Option<psbt::PsbtSighashType>, |
135 | 133 | pub(crate) ordering: TxOrdering, |
136 | 134 | pub(crate) locktime: Option<absolute::LockTime>, |
137 | | - pub(crate) rbf: Option<RbfValue>, |
| 135 | + pub(crate) sequence: Option<Sequence>, |
138 | 136 | pub(crate) version: Option<Version>, |
139 | 137 | pub(crate) change_policy: ChangeSpendPolicy, |
140 | 138 | pub(crate) only_witness_utxo: bool, |
@@ -554,23 +552,12 @@ impl<'a, Cs> TxBuilder<'a, Cs> { |
554 | 552 | } |
555 | 553 | } |
556 | 554 |
|
557 | | - /// Enable signaling RBF |
| 555 | + /// Set an exact nSequence value |
558 | 556 | /// |
559 | | - /// This will use the default nSequence value of `0xFFFFFFFD`. |
560 | | - pub fn enable_rbf(&mut self) -> &mut Self { |
561 | | - self.params.rbf = Some(RbfValue::Default); |
562 | | - self |
563 | | - } |
564 | | - |
565 | | - /// Enable signaling RBF with a specific nSequence value |
566 | | - /// |
567 | | - /// This can cause conflicts if the wallet's descriptors contain an "older" (OP_CSV) operator |
568 | | - /// and the given `nsequence` is lower than the CSV value. |
569 | | - /// |
570 | | - /// If the `nsequence` is higher than `0xFFFFFFFD` an error will be thrown, since it would not |
571 | | - /// be a valid nSequence to signal RBF. |
572 | | - pub fn enable_rbf_with_sequence(&mut self, nsequence: Sequence) -> &mut Self { |
573 | | - self.params.rbf = Some(RbfValue::Value(nsequence)); |
| 557 | + /// This can cause conflicts if the wallet's descriptors contain an |
| 558 | + /// "older" (OP_CSV) operator and the given `nsequence` is lower than the CSV value. |
| 559 | + pub fn set_exact_sequence(&mut self, n_sequence: Sequence) -> &mut Self { |
| 560 | + self.params.sequence = Some(n_sequence); |
574 | 561 | self |
575 | 562 | } |
576 | 563 |
|
@@ -654,8 +641,7 @@ impl<'a, Cs> TxBuilder<'a, Cs> { |
654 | 641 | /// .drain_wallet() |
655 | 642 | /// // Send the excess (which is all the coins minus the fee) to this address. |
656 | 643 | /// .drain_to(to_address.script_pubkey()) |
657 | | - /// .fee_rate(FeeRate::from_sat_per_vb(5).expect("valid feerate")) |
658 | | - /// .enable_rbf(); |
| 644 | + /// .fee_rate(FeeRate::from_sat_per_vb(5).expect("valid feerate")); |
659 | 645 | /// let psbt = tx_builder.finish()?; |
660 | 646 | /// # Ok::<(), anyhow::Error>(()) |
661 | 647 | /// ``` |
@@ -835,24 +821,6 @@ impl Default for Version { |
835 | 821 | } |
836 | 822 | } |
837 | 823 |
|
838 | | -/// RBF nSequence value |
839 | | -/// |
840 | | -/// Has a default value of `0xFFFFFFFD` |
841 | | -#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Clone, Copy)] |
842 | | -pub(crate) enum RbfValue { |
843 | | - Default, |
844 | | - Value(Sequence), |
845 | | -} |
846 | | - |
847 | | -impl RbfValue { |
848 | | - pub(crate) fn get_value(&self) -> Sequence { |
849 | | - match self { |
850 | | - RbfValue::Default => Sequence::ENABLE_RBF_NO_LOCKTIME, |
851 | | - RbfValue::Value(v) => *v, |
852 | | - } |
853 | | - } |
854 | | -} |
855 | | - |
856 | 824 | /// Policy regarding the use of change outputs when creating a transaction |
857 | 825 | #[derive(Default, Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Clone, Copy)] |
858 | 826 | pub enum ChangeSpendPolicy { |
|
0 commit comments