Skip to content

Commit db7ebb6

Browse files
committed
refactor: use macros for SignOptions
1 parent d255630 commit db7ebb6

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
@@ -347,55 +347,6 @@ interface FullScanScriptInspector {
347347
[Remote]
348348
interface ChangeSet {};
349349

350-
/// Options for a software signer.
351-
///
352-
/// Adjust the behavior of our software signers and the way a transaction is finalized.
353-
dictionary SignOptions {
354-
/// Whether the signer should trust the `witness_utxo`, if the `non_witness_utxo` hasn't been
355-
/// provided
356-
///
357-
/// Defaults to `false` to mitigate the "SegWit bug" which could trick the wallet into
358-
/// paying a fee larger than expected.
359-
///
360-
/// Some wallets, especially if relatively old, might not provide the `non_witness_utxo` for
361-
/// SegWit transactions in the PSBT they generate: in those cases setting this to `true`
362-
/// should correctly produce a signature, at the expense of an increased trust in the creator
363-
/// of the PSBT.
364-
///
365-
/// 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>
366-
boolean trust_witness_utxo;
367-
368-
/// Whether the wallet should assume a specific height has been reached when trying to finalize
369-
/// a transaction
370-
///
371-
/// The wallet will only "use" a timelock to satisfy the spending policy of an input if the
372-
/// timelock height has already been reached. This option allows overriding the "current height" to let the
373-
/// wallet use timelocks in the future to spend a coin.
374-
u32? assume_height;
375-
376-
/// Whether the signer should use the `sighash_type` set in the PSBT when signing, no matter
377-
/// what its value is
378-
///
379-
/// Defaults to `false` which will only allow signing using `SIGHASH_ALL`.
380-
boolean allow_all_sighashes;
381-
382-
/// Whether to try finalizing the PSBT after the inputs are signed.
383-
///
384-
/// Defaults to `true` which will try finalizing PSBT after inputs are signed.
385-
boolean try_finalize;
386-
387-
/// Whether we should try to sign a taproot transaction with the taproot internal key
388-
/// or not. This option is ignored if we're signing a non-taproot PSBT.
389-
///
390-
/// Defaults to `true`, i.e., we always try to sign with the taproot internal key.
391-
boolean sign_with_tap_internal_key;
392-
393-
/// Whether we should grind ECDSA signature to ensure signing with low r
394-
/// or not.
395-
/// Defaults to `true`, i.e., we always grind ECDSA signature to sign with low r.
396-
boolean allow_grinding;
397-
};
398-
399350
// ------------------------------------------------------------------------
400351
// bdk_wallet crate - wallet module
401352
// ------------------------------------------------------------------------

bdk-ffi/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ use crate::types::Satisfaction;
5757
use crate::types::SatisfiableItem;
5858
use crate::types::ScriptAmount;
5959
use crate::types::SentAndReceivedValues;
60-
use crate::types::SignOptions;
6160
use crate::types::SyncRequest;
6261
use crate::types::SyncRequestBuilder;
6362
use crate::types::SyncScriptInspector;

bdk-ffi/src/types.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,12 +563,48 @@ impl From<BdkCondition> for Condition {
563563
// because we did not want to expose the complexity behind the `TapLeavesOptions` type. When
564564
// transforming from a SignOption to a BdkSignOptions, we simply use the default values for
565565
// TapLeavesOptions.
566+
/// Options for a software signer.
567+
///
568+
/// Adjust the behavior of our software signers and the way a transaction is finalized.
569+
#[derive(uniffi::Record)]
566570
pub struct SignOptions {
571+
/// Whether the signer should trust the `witness_utxo`, if the `non_witness_utxo` hasn't been
572+
/// provided
573+
///
574+
/// Defaults to `false` to mitigate the "SegWit bug" which could trick the wallet into
575+
/// paying a fee larger than expected.
576+
///
577+
/// Some wallets, especially if relatively old, might not provide the `non_witness_utxo` for
578+
/// SegWit transactions in the PSBT they generate: in those cases setting this to `true`
579+
/// should correctly produce a signature, at the expense of an increased trust in the creator
580+
/// of the PSBT.
581+
///
582+
/// 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>
567583
pub trust_witness_utxo: bool,
584+
/// Whether the wallet should assume a specific height has been reached when trying to finalize
585+
/// a transaction
586+
///
587+
/// The wallet will only "use" a timelock to satisfy the spending policy of an input if the
588+
/// timelock height has already been reached. This option allows overriding the "current height" to let the
589+
/// wallet use timelocks in the future to spend a coin.
568590
pub assume_height: Option<u32>,
591+
/// Whether the signer should use the `sighash_type` set in the PSBT when signing, no matter
592+
/// what its value is
593+
///
594+
/// Defaults to `false` which will only allow signing using `SIGHASH_ALL`.
569595
pub allow_all_sighashes: bool,
596+
/// Whether to try finalizing the PSBT after the inputs are signed.
597+
///
598+
/// Defaults to `true` which will try finalizing PSBT after inputs are signed.
570599
pub try_finalize: bool,
600+
/// Whether we should try to sign a taproot transaction with the taproot internal key
601+
/// or not. This option is ignored if we're signing a non-taproot PSBT.
602+
///
603+
/// Defaults to `true`, i.e., we always try to sign with the taproot internal key.
571604
pub sign_with_tap_internal_key: bool,
605+
/// Whether we should grind ECDSA signature to ensure signing with low r
606+
/// or not.
607+
/// Defaults to `true`, i.e., we always grind ECDSA signature to sign with low r.
572608
pub allow_grinding: bool,
573609
}
574610

0 commit comments

Comments
 (0)