Skip to content

Commit 1db5a7b

Browse files
committed
refactor: use macros for SignOptions
1 parent 58e06a9 commit 1db5a7b

File tree

3 files changed

+36
-50
lines changed

3 files changed

+36
-50
lines changed

bdk-ffi/src/bdk.udl

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -335,55 +335,6 @@ interface FullScanScriptInspector {
335335
[Remote]
336336
interface ChangeSet {};
337337

338-
/// Options for a software signer.
339-
///
340-
/// Adjust the behavior of our software signers and the way a transaction is finalized.
341-
dictionary SignOptions {
342-
/// Whether the signer should trust the `witness_utxo`, if the `non_witness_utxo` hasn't been
343-
/// provided
344-
///
345-
/// Defaults to `false` to mitigate the "SegWit bug" which could trick the wallet into
346-
/// paying a fee larger than expected.
347-
///
348-
/// Some wallets, especially if relatively old, might not provide the `non_witness_utxo` for
349-
/// SegWit transactions in the PSBT they generate: in those cases setting this to `true`
350-
/// should correctly produce a signature, at the expense of an increased trust in the creator
351-
/// of the PSBT.
352-
///
353-
/// For more details see: <https://blog.trezor.io/details-of-firmware-updates-for-trezor-one-version-1-9-1-and-trezor-model-t-version-2-3-1-1eba8f60f2dd>
354-
boolean trust_witness_utxo;
355-
356-
/// Whether the wallet should assume a specific height has been reached when trying to finalize
357-
/// a transaction
358-
///
359-
/// The wallet will only "use" a timelock to satisfy the spending policy of an input if the
360-
/// timelock height has already been reached. This option allows overriding the "current height" to let the
361-
/// wallet use timelocks in the future to spend a coin.
362-
u32? assume_height;
363-
364-
/// Whether the signer should use the `sighash_type` set in the PSBT when signing, no matter
365-
/// what its value is
366-
///
367-
/// Defaults to `false` which will only allow signing using `SIGHASH_ALL`.
368-
boolean allow_all_sighashes;
369-
370-
/// Whether to try finalizing the PSBT after the inputs are signed.
371-
///
372-
/// Defaults to `true` which will try finalizing PSBT after inputs are signed.
373-
boolean try_finalize;
374-
375-
/// Whether we should try to sign a taproot transaction with the taproot internal key
376-
/// or not. This option is ignored if we're signing a non-taproot PSBT.
377-
///
378-
/// Defaults to `true`, i.e., we always try to sign with the taproot internal key.
379-
boolean sign_with_tap_internal_key;
380-
381-
/// Whether we should grind ECDSA signature to ensure signing with low r
382-
/// or not.
383-
/// Defaults to `true`, i.e., we always grind ECDSA signature to sign with low r.
384-
boolean allow_grinding;
385-
};
386-
387338
// ------------------------------------------------------------------------
388339
// bdk_wallet crate - wallet module
389340
// ------------------------------------------------------------------------

bdk-ffi/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ use crate::types::PkOrF;
4444
use crate::types::Policy;
4545
use crate::types::Satisfaction;
4646
use crate::types::SatisfiableItem;
47-
use crate::types::SignOptions;
4847
use crate::types::SyncRequest;
4948
use crate::types::SyncRequestBuilder;
5049
use crate::types::SyncScriptInspector;

bdk-ffi/src/types.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,12 +580,48 @@ impl From<BdkCondition> for Condition {
580580
// because we did not want to expose the complexity behind the `TapLeavesOptions` type. When
581581
// transforming from a SignOption to a BdkSignOptions, we simply use the default values for
582582
// TapLeavesOptions.
583+
/// Options for a software signer.
584+
///
585+
/// Adjust the behavior of our software signers and the way a transaction is finalized.
586+
#[derive(uniffi::Record)]
583587
pub struct SignOptions {
588+
/// Whether the signer should trust the `witness_utxo`, if the `non_witness_utxo` hasn't been
589+
/// provided
590+
///
591+
/// Defaults to `false` to mitigate the "SegWit bug" which could trick the wallet into
592+
/// paying a fee larger than expected.
593+
///
594+
/// Some wallets, especially if relatively old, might not provide the `non_witness_utxo` for
595+
/// SegWit transactions in the PSBT they generate: in those cases setting this to `true`
596+
/// should correctly produce a signature, at the expense of an increased trust in the creator
597+
/// of the PSBT.
598+
///
599+
/// For more details see: <https://blog.trezor.io/details-of-firmware-updates-for-trezor-one-version-1-9-1-and-trezor-model-t-version-2-3-1-1eba8f60f2dd>
584600
pub trust_witness_utxo: bool,
601+
/// Whether the wallet should assume a specific height has been reached when trying to finalize
602+
/// a transaction
603+
///
604+
/// The wallet will only "use" a timelock to satisfy the spending policy of an input if the
605+
/// timelock height has already been reached. This option allows overriding the "current height" to let the
606+
/// wallet use timelocks in the future to spend a coin.
585607
pub assume_height: Option<u32>,
608+
/// Whether the signer should use the `sighash_type` set in the PSBT when signing, no matter
609+
/// what its value is
610+
///
611+
/// Defaults to `false` which will only allow signing using `SIGHASH_ALL`.
586612
pub allow_all_sighashes: bool,
613+
/// Whether to try finalizing the PSBT after the inputs are signed.
614+
///
615+
/// Defaults to `true` which will try finalizing PSBT after inputs are signed.
587616
pub try_finalize: bool,
617+
/// Whether we should try to sign a taproot transaction with the taproot internal key
618+
/// or not. This option is ignored if we're signing a non-taproot PSBT.
619+
///
620+
/// Defaults to `true`, i.e., we always try to sign with the taproot internal key.
588621
pub sign_with_tap_internal_key: bool,
622+
/// Whether we should grind ECDSA signature to ensure signing with low r
623+
/// or not.
624+
/// Defaults to `true`, i.e., we always grind ECDSA signature to sign with low r.
589625
pub allow_grinding: bool,
590626
}
591627

0 commit comments

Comments
 (0)