@bennyblader/ddk-rn 0.4.0 → 1.0.0-rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/ddk_ffi.ts CHANGED
@@ -10,21 +10,30 @@ import {
10
10
  type UniffiForeignFutureDroppedCallbackStruct,
11
11
  } from './ddk_ffi-ffi';
12
12
  import {
13
+ type FfiConverter,
13
14
  type UniffiByteArray,
15
+ type UniffiGcObject,
16
+ type UniffiHandle,
17
+ type UniffiObjectFactory,
14
18
  AbstractFfiConverterByteArray,
15
19
  FfiConverterArray,
16
20
  FfiConverterArrayBuffer,
17
21
  FfiConverterBool,
18
22
  FfiConverterInt32,
23
+ FfiConverterObject,
19
24
  FfiConverterOptional,
25
+ FfiConverterUInt16,
20
26
  FfiConverterUInt32,
21
27
  FfiConverterUInt64,
22
28
  FfiConverterUInt8,
23
29
  RustBuffer,
30
+ UniffiAbstractObject,
24
31
  UniffiEnum,
25
32
  UniffiError,
26
33
  UniffiInternalError,
27
34
  UniffiRustCaller,
35
+ destructorGuardSymbol,
36
+ pointerLiteralSymbol,
28
37
  uniffiCreateFfiConverterString,
29
38
  uniffiCreateRecord,
30
39
  uniffiTypeNameSymbol,
@@ -41,6 +50,149 @@ const uniffiIsDebug =
41
50
 
42
51
  // Public interface members begin here.
43
52
 
53
+ /**
54
+ * Accepts an offer. The accepting party's funding secret key is derived inside
55
+ * Rust from `keys` + `new_temporary_contract_id` and never crosses the boundary;
56
+ * it must match `params.party.funding_pubkey` (derive both from the same provider).
57
+ */
58
+ export function acceptOffer(
59
+ offer: ArrayBuffer,
60
+ params: AcceptOfferParams,
61
+ keys: ContractKeyProviderLike,
62
+ newTemporaryContractId: ArrayBuffer
63
+ ): AcceptResult /*throws*/ {
64
+ return ((__rb: Uint8Array) => {
65
+ try {
66
+ return FfiConverterTypeAcceptResult.lift(__rb);
67
+ } finally {
68
+ nativeModule().rustbuffer_free(__rb);
69
+ }
70
+ })(
71
+ uniffiCaller.rustCallWithError(
72
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
73
+ FfiConverterTypeContractError
74
+ ),
75
+ /*caller:*/ (callStatus) => {
76
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_accept_offer(
77
+ FfiConverterArrayBuffer.lower(offer, nativeModule().rustbuffer_alloc),
78
+ FfiConverterTypeAcceptOfferParams.lower(
79
+ params,
80
+ nativeModule().rustbuffer_alloc
81
+ ),
82
+ FfiConverterTypeContractKeyProvider.lower(
83
+ keys,
84
+ nativeModule().rustbuffer_alloc
85
+ ),
86
+ FfiConverterArrayBuffer.lower(
87
+ newTemporaryContractId,
88
+ nativeModule().rustbuffer_alloc
89
+ ),
90
+ callStatus
91
+ );
92
+ },
93
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
94
+ )
95
+ );
96
+ }
97
+
98
+ /**
99
+ * The 32-byte chain hash for a network (`bitcoin` / `testnet` / `signet` /
100
+ * `regtest`). Use it for [`CreateOfferParams::chain_hash`].
101
+ */
102
+ export function chainHashFromNetwork(network: string): ArrayBuffer /*throws*/ {
103
+ return ((__rb: Uint8Array) => {
104
+ try {
105
+ return FfiConverterArrayBuffer.lift(__rb);
106
+ } finally {
107
+ nativeModule().rustbuffer_free(__rb);
108
+ }
109
+ })(
110
+ uniffiCaller.rustCallWithError(
111
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
112
+ FfiConverterTypeContractError
113
+ ),
114
+ /*caller:*/ (callStatus) => {
115
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_chain_hash_from_network(
116
+ FfiConverterString.lower(network, nativeModule().rustbuffer_alloc),
117
+ callStatus
118
+ );
119
+ },
120
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
121
+ )
122
+ );
123
+ }
124
+
125
+ /**
126
+ * The 32-byte contract id derived from the offer and accept messages — the
127
+ * stable id of the funded contract. Use it to key stored contracts.
128
+ */
129
+ export function computeContractId(
130
+ offer: ArrayBuffer,
131
+ accept: ArrayBuffer
132
+ ): ArrayBuffer /*throws*/ {
133
+ return ((__rb: Uint8Array) => {
134
+ try {
135
+ return FfiConverterArrayBuffer.lift(__rb);
136
+ } finally {
137
+ nativeModule().rustbuffer_free(__rb);
138
+ }
139
+ })(
140
+ uniffiCaller.rustCallWithError(
141
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
142
+ FfiConverterTypeContractError
143
+ ),
144
+ /*caller:*/ (callStatus) => {
145
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_compute_contract_id(
146
+ FfiConverterArrayBuffer.lower(offer, nativeModule().rustbuffer_alloc),
147
+ FfiConverterArrayBuffer.lower(
148
+ accept,
149
+ nativeModule().rustbuffer_alloc
150
+ ),
151
+ callStatus
152
+ );
153
+ },
154
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
155
+ )
156
+ );
157
+ }
158
+
159
+ /**
160
+ * Derives the offer/accept payouts for every outcome of a contract from its
161
+ * wire-encoded `ContractInfo`, for building a payout table to show users.
162
+ *
163
+ * Handles both enum contracts (each row a labeled outcome) and numeric-outcome
164
+ * contracts (each row an inclusive outcome range that shares a single payout,
165
+ * as determined by the payout function and rounding intervals). Disjoint
166
+ * contracts contribute the rows of each of their sub-contracts.
167
+ */
168
+ export function contractInfoPayouts(
169
+ contractInfo: ArrayBuffer
170
+ ): ContractPayouts /*throws*/ {
171
+ return ((__rb: Uint8Array) => {
172
+ try {
173
+ return FfiConverterTypeContractPayouts.lift(__rb);
174
+ } finally {
175
+ nativeModule().rustbuffer_free(__rb);
176
+ }
177
+ })(
178
+ uniffiCaller.rustCallWithError(
179
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
180
+ FfiConverterTypeContractError
181
+ ),
182
+ /*caller:*/ (callStatus) => {
183
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_contract_info_payouts(
184
+ FfiConverterArrayBuffer.lower(
185
+ contractInfo,
186
+ nativeModule().rustbuffer_alloc
187
+ ),
188
+ callStatus
189
+ );
190
+ },
191
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
192
+ )
193
+ );
194
+ }
195
+
44
196
  export function convertMnemonicToSeed(
45
197
  mnemonic: string,
46
198
  passphrase: string | undefined
@@ -317,6 +469,61 @@ export function createCets(
317
469
  );
318
470
  }
319
471
 
472
+ /**
473
+ * Rebuilds the splice `FundingInput` (wire-encoded) that spends a previous
474
+ * contract's 2-of-2 funding output, from that contract's offer and accept
475
+ * messages. Only the offering party contributes a splice input; place the
476
+ * result in the offering party's `funding_inputs`. `max_witness_len` must be
477
+ * greater than 108 — use [`dlc_input_max_witness_len`].
478
+ */
479
+ export function createDlcSpliceInput(
480
+ prevOffer: ArrayBuffer,
481
+ prevAccept: ArrayBuffer,
482
+ localParty: Party,
483
+ inputSerialId: bigint | undefined,
484
+ maxWitnessLen: number
485
+ ): ArrayBuffer /*throws*/ {
486
+ return ((__rb: Uint8Array) => {
487
+ try {
488
+ return FfiConverterArrayBuffer.lift(__rb);
489
+ } finally {
490
+ nativeModule().rustbuffer_free(__rb);
491
+ }
492
+ })(
493
+ uniffiCaller.rustCallWithError(
494
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
495
+ FfiConverterTypeContractError
496
+ ),
497
+ /*caller:*/ (callStatus) => {
498
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_create_dlc_splice_input(
499
+ FfiConverterArrayBuffer.lower(
500
+ prevOffer,
501
+ nativeModule().rustbuffer_alloc
502
+ ),
503
+ FfiConverterArrayBuffer.lower(
504
+ prevAccept,
505
+ nativeModule().rustbuffer_alloc
506
+ ),
507
+ FfiConverterTypeParty.lower(
508
+ localParty,
509
+ nativeModule().rustbuffer_alloc
510
+ ),
511
+ FfiConverterOptionalUInt64.lower(
512
+ inputSerialId,
513
+ nativeModule().rustbuffer_alloc
514
+ ),
515
+ FfiConverterUInt16.lower(
516
+ maxWitnessLen,
517
+ nativeModule().rustbuffer_alloc
518
+ ),
519
+ callStatus
520
+ );
521
+ },
522
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
523
+ )
524
+ );
525
+ }
526
+
320
527
  /**
321
528
  * Create complete DLC transactions
322
529
  */
@@ -486,6 +693,68 @@ export function createFundTxLockingScript(
486
693
  );
487
694
  }
488
695
 
696
+ /**
697
+ * Rebuilds the BIP-174 funding PSBT from the offer and accept messages.
698
+ */
699
+ export function createFundingPsbt(
700
+ offer: ArrayBuffer,
701
+ accept: ArrayBuffer
702
+ ): ArrayBuffer /*throws*/ {
703
+ return ((__rb: Uint8Array) => {
704
+ try {
705
+ return FfiConverterArrayBuffer.lift(__rb);
706
+ } finally {
707
+ nativeModule().rustbuffer_free(__rb);
708
+ }
709
+ })(
710
+ uniffiCaller.rustCallWithError(
711
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
712
+ FfiConverterTypeContractError
713
+ ),
714
+ /*caller:*/ (callStatus) => {
715
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_create_funding_psbt(
716
+ FfiConverterArrayBuffer.lower(offer, nativeModule().rustbuffer_alloc),
717
+ FfiConverterArrayBuffer.lower(
718
+ accept,
719
+ nativeModule().rustbuffer_alloc
720
+ ),
721
+ callStatus
722
+ );
723
+ },
724
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
725
+ )
726
+ );
727
+ }
728
+
729
+ /**
730
+ * Creates an offer. Returns the wire-encoded `OfferDlc` to send to the accepting party.
731
+ */
732
+ export function createOffer(params: CreateOfferParams): ArrayBuffer /*throws*/ {
733
+ return ((__rb: Uint8Array) => {
734
+ try {
735
+ return FfiConverterArrayBuffer.lift(__rb);
736
+ } finally {
737
+ nativeModule().rustbuffer_free(__rb);
738
+ }
739
+ })(
740
+ uniffiCaller.rustCallWithError(
741
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
742
+ FfiConverterTypeContractError
743
+ ),
744
+ /*caller:*/ (callStatus) => {
745
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_create_offer(
746
+ FfiConverterTypeCreateOfferParams.lower(
747
+ params,
748
+ nativeModule().rustbuffer_alloc
749
+ ),
750
+ callStatus
751
+ );
752
+ },
753
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
754
+ )
755
+ );
756
+ }
757
+
489
758
  /**
490
759
  * Create a refund transaction
491
760
  */
@@ -647,6 +916,55 @@ export function createXprivFromParentPath(
647
916
  );
648
917
  }
649
918
 
919
+ /**
920
+ * The required `max_witness_len` for a DLC (splice) funding input (220).
921
+ */
922
+ export function dlcInputMaxWitnessLen(): number {
923
+ return FfiConverterUInt16.lift(
924
+ uniffiCaller.rustCall(
925
+ /*caller:*/ (callStatus) => {
926
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_dlc_input_max_witness_len(
927
+ callStatus
928
+ );
929
+ },
930
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
931
+ )
932
+ );
933
+ }
934
+
935
+ /**
936
+ * Rebuilds the unsigned funding, CET, and refund transactions from the messages.
937
+ */
938
+ export function dlcTransactionsFromMessages(
939
+ offer: ArrayBuffer,
940
+ accept: ArrayBuffer
941
+ ): DlcTransactions /*throws*/ {
942
+ return ((__rb: Uint8Array) => {
943
+ try {
944
+ return FfiConverterTypeDlcTransactions.lift(__rb);
945
+ } finally {
946
+ nativeModule().rustbuffer_free(__rb);
947
+ }
948
+ })(
949
+ uniffiCaller.rustCallWithError(
950
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
951
+ FfiConverterTypeContractError
952
+ ),
953
+ /*caller:*/ (callStatus) => {
954
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_dlc_transactions_from_messages(
955
+ FfiConverterArrayBuffer.lower(offer, nativeModule().rustbuffer_alloc),
956
+ FfiConverterArrayBuffer.lower(
957
+ accept,
958
+ nativeModule().rustbuffer_alloc
959
+ ),
960
+ callStatus
961
+ );
962
+ },
963
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
964
+ )
965
+ );
966
+ }
967
+
650
968
  export function extractEcdsaSignatureFromOracleSignatures(
651
969
  oracleSignatures: Array<ArrayBuffer>,
652
970
  adaptorSignature: ArrayBuffer
@@ -681,12 +999,14 @@ export function extractEcdsaSignatureFromOracleSignatures(
681
999
  }
682
1000
 
683
1001
  /**
684
- * Extract public key from extended key (private or public)
685
- * Input: 78-byte encoded xpriv/xpub, Output: 33-byte compressed public key
1002
+ * The accepting party verifies the sign message and completes the funding
1003
+ * transaction. Returns the Bitcoin consensus-serialized signed transaction.
686
1004
  */
687
- export function getPubkeyFromExtkey(
688
- extkey: ArrayBuffer,
689
- network: string
1005
+ export function finalizeSign(
1006
+ offer: ArrayBuffer,
1007
+ accept: ArrayBuffer,
1008
+ sign: ArrayBuffer,
1009
+ signedFundingPsbt: ArrayBuffer
690
1010
  ): ArrayBuffer /*throws*/ {
691
1011
  return ((__rb: Uint8Array) => {
692
1012
  try {
@@ -696,16 +1016,21 @@ export function getPubkeyFromExtkey(
696
1016
  }
697
1017
  })(
698
1018
  uniffiCaller.rustCallWithError(
699
- /*liftError:*/ FfiConverterTypeDLCError.lift.bind(
700
- FfiConverterTypeDLCError
1019
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
1020
+ FfiConverterTypeContractError
701
1021
  ),
702
1022
  /*caller:*/ (callStatus) => {
703
- return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_get_pubkey_from_extkey(
1023
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_finalize_sign(
1024
+ FfiConverterArrayBuffer.lower(offer, nativeModule().rustbuffer_alloc),
704
1025
  FfiConverterArrayBuffer.lower(
705
- extkey,
1026
+ accept,
1027
+ nativeModule().rustbuffer_alloc
1028
+ ),
1029
+ FfiConverterArrayBuffer.lower(sign, nativeModule().rustbuffer_alloc),
1030
+ FfiConverterArrayBuffer.lower(
1031
+ signedFundingPsbt,
706
1032
  nativeModule().rustbuffer_alloc
707
1033
  ),
708
- FfiConverterString.lower(network, nativeModule().rustbuffer_alloc),
709
1034
  callStatus
710
1035
  );
711
1036
  },
@@ -715,15 +1040,47 @@ export function getPubkeyFromExtkey(
715
1040
  }
716
1041
 
717
1042
  /**
718
- * Get total input virtual size for fee calculation
1043
+ * Like [`finalize_sign`], but additionally completes the 2-of-2 witness for any
1044
+ * splice (DLC) funding input using this (accepting) party's prior funding keys,
1045
+ * re-derived inside Rust from `keys`.
719
1046
  */
720
- export function getTotalInputVsize(inputs: Array<TxInputInfo>): number {
721
- return FfiConverterUInt32.lift(
722
- uniffiCaller.rustCall(
1047
+ export function finalizeSignSpliced(
1048
+ offer: ArrayBuffer,
1049
+ accept: ArrayBuffer,
1050
+ sign: ArrayBuffer,
1051
+ signedFundingPsbt: ArrayBuffer,
1052
+ keys: ContractKeyProviderLike,
1053
+ spliceKeys: Array<SpliceKeyRef>
1054
+ ): ArrayBuffer /*throws*/ {
1055
+ return ((__rb: Uint8Array) => {
1056
+ try {
1057
+ return FfiConverterArrayBuffer.lift(__rb);
1058
+ } finally {
1059
+ nativeModule().rustbuffer_free(__rb);
1060
+ }
1061
+ })(
1062
+ uniffiCaller.rustCallWithError(
1063
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
1064
+ FfiConverterTypeContractError
1065
+ ),
723
1066
  /*caller:*/ (callStatus) => {
724
- return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_get_total_input_vsize(
725
- FfiConverterSequenceTypeTxInputInfo.lower(
726
- inputs,
1067
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_finalize_sign_spliced(
1068
+ FfiConverterArrayBuffer.lower(offer, nativeModule().rustbuffer_alloc),
1069
+ FfiConverterArrayBuffer.lower(
1070
+ accept,
1071
+ nativeModule().rustbuffer_alloc
1072
+ ),
1073
+ FfiConverterArrayBuffer.lower(sign, nativeModule().rustbuffer_alloc),
1074
+ FfiConverterArrayBuffer.lower(
1075
+ signedFundingPsbt,
1076
+ nativeModule().rustbuffer_alloc
1077
+ ),
1078
+ FfiConverterTypeContractKeyProvider.lower(
1079
+ keys,
1080
+ nativeModule().rustbuffer_alloc
1081
+ ),
1082
+ FfiConverterSequenceTypeSpliceKeyRef.lower(
1083
+ spliceKeys,
727
1084
  nativeModule().rustbuffer_alloc
728
1085
  ),
729
1086
  callStatus
@@ -735,12 +1092,26 @@ export function getTotalInputVsize(inputs: Array<TxInputInfo>): number {
735
1092
  }
736
1093
 
737
1094
  /**
738
- * Convert extended private key to extended public key
739
- * Input: 78-byte encoded xpriv, Output: 78-byte encoded xpub
1095
+ * Builds a wire-encoded `FundingInput` from a wallet UTXO, ready to place in a
1096
+ * party's `funding_inputs`.
1097
+ *
1098
+ * - `previous_transaction`: the full consensus-serialized transaction that
1099
+ * created the UTXO being spent.
1100
+ * - `vout`: the output index of the UTXO within that transaction.
1101
+ * - `input_serial_id`: orders the input in the funding transaction; randomly
1102
+ * generated when `None`.
1103
+ * - `sequence`: the input sequence (usually `0xffffffff`).
1104
+ * - `max_witness_len`: the input's maximum witness length (e.g. 108 for
1105
+ * P2WPKH).
1106
+ * - `redeem_script`: the redeem script for a P2SH input, or empty for others.
740
1107
  */
741
- export function getXpubFromXpriv(
742
- xpriv: ArrayBuffer,
743
- network: string
1108
+ export function fundingInput(
1109
+ previousTransaction: ArrayBuffer,
1110
+ vout: number,
1111
+ inputSerialId: bigint | undefined,
1112
+ sequence: number,
1113
+ maxWitnessLen: number,
1114
+ redeemScript: ArrayBuffer
744
1115
  ): ArrayBuffer /*throws*/ {
745
1116
  return ((__rb: Uint8Array) => {
746
1117
  try {
@@ -750,12 +1121,62 @@ export function getXpubFromXpriv(
750
1121
  }
751
1122
  })(
752
1123
  uniffiCaller.rustCallWithError(
753
- /*liftError:*/ FfiConverterTypeDLCError.lift.bind(
754
- FfiConverterTypeDLCError
1124
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
1125
+ FfiConverterTypeContractError
755
1126
  ),
756
1127
  /*caller:*/ (callStatus) => {
757
- return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_get_xpub_from_xpriv(
758
- FfiConverterArrayBuffer.lower(xpriv, nativeModule().rustbuffer_alloc),
1128
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_funding_input(
1129
+ FfiConverterArrayBuffer.lower(
1130
+ previousTransaction,
1131
+ nativeModule().rustbuffer_alloc
1132
+ ),
1133
+ FfiConverterUInt32.lower(vout, nativeModule().rustbuffer_alloc),
1134
+ FfiConverterOptionalUInt64.lower(
1135
+ inputSerialId,
1136
+ nativeModule().rustbuffer_alloc
1137
+ ),
1138
+ FfiConverterUInt32.lower(sequence, nativeModule().rustbuffer_alloc),
1139
+ FfiConverterUInt16.lower(
1140
+ maxWitnessLen,
1141
+ nativeModule().rustbuffer_alloc
1142
+ ),
1143
+ FfiConverterArrayBuffer.lower(
1144
+ redeemScript,
1145
+ nativeModule().rustbuffer_alloc
1146
+ ),
1147
+ callStatus
1148
+ );
1149
+ },
1150
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
1151
+ )
1152
+ );
1153
+ }
1154
+
1155
+ /**
1156
+ * Extract public key from extended key (private or public)
1157
+ * Input: 78-byte encoded xpriv/xpub, Output: 33-byte compressed public key
1158
+ */
1159
+ export function getPubkeyFromExtkey(
1160
+ extkey: ArrayBuffer,
1161
+ network: string
1162
+ ): ArrayBuffer /*throws*/ {
1163
+ return ((__rb: Uint8Array) => {
1164
+ try {
1165
+ return FfiConverterArrayBuffer.lift(__rb);
1166
+ } finally {
1167
+ nativeModule().rustbuffer_free(__rb);
1168
+ }
1169
+ })(
1170
+ uniffiCaller.rustCallWithError(
1171
+ /*liftError:*/ FfiConverterTypeDLCError.lift.bind(
1172
+ FfiConverterTypeDLCError
1173
+ ),
1174
+ /*caller:*/ (callStatus) => {
1175
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_get_pubkey_from_extkey(
1176
+ FfiConverterArrayBuffer.lower(
1177
+ extkey,
1178
+ nativeModule().rustbuffer_alloc
1179
+ ),
759
1180
  FfiConverterString.lower(network, nativeModule().rustbuffer_alloc),
760
1181
  callStatus
761
1182
  );
@@ -765,45 +1186,152 @@ export function getXpubFromXpriv(
765
1186
  );
766
1187
  }
767
1188
 
768
- export function verifyCetAdaptorSigsFromOracleInfo(
769
- adaptorSigs: Array<AdaptorSignature>,
770
- cets: Array<Transaction>,
771
- oracleInfos: Array<OracleInfo>,
772
- pubkey: ArrayBuffer,
773
- fundingScriptPubkey: ArrayBuffer,
774
- totalCollateral: bigint,
775
- msgs: Array<Array<Array<ArrayBuffer>>>
776
- ): boolean {
777
- return FfiConverterBool.lift(
1189
+ /**
1190
+ * Get total input virtual size for fee calculation
1191
+ */
1192
+ export function getTotalInputVsize(inputs: Array<TxInputInfo>): number {
1193
+ return FfiConverterUInt32.lift(
778
1194
  uniffiCaller.rustCall(
779
1195
  /*caller:*/ (callStatus) => {
780
- return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_verify_cet_adaptor_sigs_from_oracle_info(
781
- FfiConverterSequenceTypeAdaptorSignature.lower(
782
- adaptorSigs,
1196
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_get_total_input_vsize(
1197
+ FfiConverterSequenceTypeTxInputInfo.lower(
1198
+ inputs,
783
1199
  nativeModule().rustbuffer_alloc
784
1200
  ),
785
- FfiConverterSequenceTypeTransaction.lower(
786
- cets,
1201
+ callStatus
1202
+ );
1203
+ },
1204
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
1205
+ )
1206
+ );
1207
+ }
1208
+
1209
+ /**
1210
+ * Convert extended private key to extended public key
1211
+ * Input: 78-byte encoded xpriv, Output: 78-byte encoded xpub
1212
+ */
1213
+ export function getXpubFromXpriv(
1214
+ xpriv: ArrayBuffer,
1215
+ network: string
1216
+ ): ArrayBuffer /*throws*/ {
1217
+ return ((__rb: Uint8Array) => {
1218
+ try {
1219
+ return FfiConverterArrayBuffer.lift(__rb);
1220
+ } finally {
1221
+ nativeModule().rustbuffer_free(__rb);
1222
+ }
1223
+ })(
1224
+ uniffiCaller.rustCallWithError(
1225
+ /*liftError:*/ FfiConverterTypeDLCError.lift.bind(
1226
+ FfiConverterTypeDLCError
1227
+ ),
1228
+ /*caller:*/ (callStatus) => {
1229
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_get_xpub_from_xpriv(
1230
+ FfiConverterArrayBuffer.lower(xpriv, nativeModule().rustbuffer_alloc),
1231
+ FfiConverterString.lower(network, nativeModule().rustbuffer_alloc),
1232
+ callStatus
1233
+ );
1234
+ },
1235
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
1236
+ )
1237
+ );
1238
+ }
1239
+
1240
+ /**
1241
+ * The offering party verifies the accept message and produces its `SignDlc`.
1242
+ * The offer party's funding secret key is derived from `keys` +
1243
+ * `temporary_contract_id` (the new contract's id).
1244
+ */
1245
+ export function signAccept(
1246
+ offer: ArrayBuffer,
1247
+ accept: ArrayBuffer,
1248
+ keys: ContractKeyProviderLike,
1249
+ temporaryContractId: ArrayBuffer,
1250
+ signedFundingPsbt: ArrayBuffer
1251
+ ): SignResult /*throws*/ {
1252
+ return ((__rb: Uint8Array) => {
1253
+ try {
1254
+ return FfiConverterTypeSignResult.lift(__rb);
1255
+ } finally {
1256
+ nativeModule().rustbuffer_free(__rb);
1257
+ }
1258
+ })(
1259
+ uniffiCaller.rustCallWithError(
1260
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
1261
+ FfiConverterTypeContractError
1262
+ ),
1263
+ /*caller:*/ (callStatus) => {
1264
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_sign_accept(
1265
+ FfiConverterArrayBuffer.lower(offer, nativeModule().rustbuffer_alloc),
1266
+ FfiConverterArrayBuffer.lower(
1267
+ accept,
787
1268
  nativeModule().rustbuffer_alloc
788
1269
  ),
789
- FfiConverterSequenceTypeOracleInfo.lower(
790
- oracleInfos,
1270
+ FfiConverterTypeContractKeyProvider.lower(
1271
+ keys,
791
1272
  nativeModule().rustbuffer_alloc
792
1273
  ),
793
1274
  FfiConverterArrayBuffer.lower(
794
- pubkey,
1275
+ temporaryContractId,
795
1276
  nativeModule().rustbuffer_alloc
796
1277
  ),
797
1278
  FfiConverterArrayBuffer.lower(
798
- fundingScriptPubkey,
1279
+ signedFundingPsbt,
799
1280
  nativeModule().rustbuffer_alloc
800
1281
  ),
801
- FfiConverterUInt64.lower(
802
- totalCollateral,
1282
+ callStatus
1283
+ );
1284
+ },
1285
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
1286
+ )
1287
+ );
1288
+ }
1289
+
1290
+ /**
1291
+ * Like [`sign_accept`], but additionally co-signs any splice (DLC) funding
1292
+ * inputs. For each splice input, `splice_keys` names the previous contract; the
1293
+ * prior funding secret key is re-derived inside Rust from `keys`.
1294
+ */
1295
+ export function signAcceptSpliced(
1296
+ offer: ArrayBuffer,
1297
+ accept: ArrayBuffer,
1298
+ keys: ContractKeyProviderLike,
1299
+ temporaryContractId: ArrayBuffer,
1300
+ signedFundingPsbt: ArrayBuffer,
1301
+ spliceKeys: Array<SpliceKeyRef>
1302
+ ): SignResult /*throws*/ {
1303
+ return ((__rb: Uint8Array) => {
1304
+ try {
1305
+ return FfiConverterTypeSignResult.lift(__rb);
1306
+ } finally {
1307
+ nativeModule().rustbuffer_free(__rb);
1308
+ }
1309
+ })(
1310
+ uniffiCaller.rustCallWithError(
1311
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
1312
+ FfiConverterTypeContractError
1313
+ ),
1314
+ /*caller:*/ (callStatus) => {
1315
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_sign_accept_spliced(
1316
+ FfiConverterArrayBuffer.lower(offer, nativeModule().rustbuffer_alloc),
1317
+ FfiConverterArrayBuffer.lower(
1318
+ accept,
803
1319
  nativeModule().rustbuffer_alloc
804
1320
  ),
805
- FfiConverterSequenceSequenceSequenceBytes.lower(
806
- msgs,
1321
+ FfiConverterTypeContractKeyProvider.lower(
1322
+ keys,
1323
+ nativeModule().rustbuffer_alloc
1324
+ ),
1325
+ FfiConverterArrayBuffer.lower(
1326
+ temporaryContractId,
1327
+ nativeModule().rustbuffer_alloc
1328
+ ),
1329
+ FfiConverterArrayBuffer.lower(
1330
+ signedFundingPsbt,
1331
+ nativeModule().rustbuffer_alloc
1332
+ ),
1333
+ FfiConverterSequenceTypeSpliceKeyRef.lower(
1334
+ spliceKeys,
807
1335
  nativeModule().rustbuffer_alloc
808
1336
  ),
809
1337
  callStatus
@@ -814,110 +1342,468 @@ export function verifyCetAdaptorSigsFromOracleInfo(
814
1342
  );
815
1343
  }
816
1344
 
817
- export function version(): string {
1345
+ /**
1346
+ * Signs the CET matching a set of oracle attestations, returning the Bitcoin
1347
+ * consensus-serialized transaction. It pays each party the attested outcome's
1348
+ * payout and is ready to broadcast — no network access happens here.
1349
+ *
1350
+ * The settling party's funding secret key is derived inside Rust from `keys` +
1351
+ * `temporary_contract_id` — the settling party's OWN temporary id (the offer's
1352
+ * for the offering party, the `new_temporary_contract_id` passed to
1353
+ * `accept_offer` for the accepting party). The key also identifies which side
1354
+ * is settling, so there is no party argument to get wrong. Either party can
1355
+ * settle alone: the counterparty's half of the 2-of-2 comes from decrypting its
1356
+ * CET adaptor signature with the oracle signatures.
1357
+ *
1358
+ * Each entry in `attestations` pairs a wire-encoded `OracleAttestation` with
1359
+ * the index of its oracle in the announcements of the contract info it settles.
1360
+ * Attestations are verified against the announcements they claim to come from,
1361
+ * so a forged or misindexed one cannot produce a CET
1362
+ * ([`ContractError::InvalidAttestation`]). When no contract outcome matches the
1363
+ * attested outcomes, [`ContractError::NoMatchingOutcome`] is returned — which
1364
+ * is also what an attestation for an unrelated event looks like.
1365
+ */
1366
+ export function signContractCet(
1367
+ offer: ArrayBuffer,
1368
+ accept: ArrayBuffer,
1369
+ sign: ArrayBuffer,
1370
+ keys: ContractKeyProviderLike,
1371
+ temporaryContractId: ArrayBuffer,
1372
+ attestations: Array<OracleAttestationRef>
1373
+ ): ArrayBuffer /*throws*/ {
818
1374
  return ((__rb: Uint8Array) => {
819
1375
  try {
820
- return FfiConverterString.lift(__rb);
1376
+ return FfiConverterArrayBuffer.lift(__rb);
821
1377
  } finally {
822
1378
  nativeModule().rustbuffer_free(__rb);
823
1379
  }
824
1380
  })(
825
- uniffiCaller.rustCall(
1381
+ uniffiCaller.rustCallWithError(
1382
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
1383
+ FfiConverterTypeContractError
1384
+ ),
826
1385
  /*caller:*/ (callStatus) => {
827
- return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_version(callStatus);
1386
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_sign_contract_cet(
1387
+ FfiConverterArrayBuffer.lower(offer, nativeModule().rustbuffer_alloc),
1388
+ FfiConverterArrayBuffer.lower(
1389
+ accept,
1390
+ nativeModule().rustbuffer_alloc
1391
+ ),
1392
+ FfiConverterArrayBuffer.lower(sign, nativeModule().rustbuffer_alloc),
1393
+ FfiConverterTypeContractKeyProvider.lower(
1394
+ keys,
1395
+ nativeModule().rustbuffer_alloc
1396
+ ),
1397
+ FfiConverterArrayBuffer.lower(
1398
+ temporaryContractId,
1399
+ nativeModule().rustbuffer_alloc
1400
+ ),
1401
+ FfiConverterSequenceTypeOracleAttestationRef.lower(
1402
+ attestations,
1403
+ nativeModule().rustbuffer_alloc
1404
+ ),
1405
+ callStatus
1406
+ );
828
1407
  },
829
1408
  /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
830
1409
  )
831
1410
  );
832
1411
  }
833
1412
 
834
- export type AdaptorSignature = {
835
- signature: ArrayBuffer;
836
- proof: ArrayBuffer;
837
- };
1413
+ /**
1414
+ * Signs the refund transaction, returning the Bitcoin consensus-serialized
1415
+ * transaction. It returns each party its own collateral and can only be
1416
+ * broadcast once the offer's `refund_locktime` has passed — enforcing that is
1417
+ * the chain's job, not this function's.
1418
+ *
1419
+ * As with [`sign_contract_cet`], `temporary_contract_id` is the settling
1420
+ * party's own temporary id and identifies which side is settling. Both parties
1421
+ * signed the refund during the offer/accept exchange, so this only adds this
1422
+ * party's half; the counterparty's stored signature is verified first.
1423
+ */
1424
+ export function signContractRefund(
1425
+ offer: ArrayBuffer,
1426
+ accept: ArrayBuffer,
1427
+ sign: ArrayBuffer,
1428
+ keys: ContractKeyProviderLike,
1429
+ temporaryContractId: ArrayBuffer
1430
+ ): ArrayBuffer /*throws*/ {
1431
+ return ((__rb: Uint8Array) => {
1432
+ try {
1433
+ return FfiConverterArrayBuffer.lift(__rb);
1434
+ } finally {
1435
+ nativeModule().rustbuffer_free(__rb);
1436
+ }
1437
+ })(
1438
+ uniffiCaller.rustCallWithError(
1439
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
1440
+ FfiConverterTypeContractError
1441
+ ),
1442
+ /*caller:*/ (callStatus) => {
1443
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_sign_contract_refund(
1444
+ FfiConverterArrayBuffer.lower(offer, nativeModule().rustbuffer_alloc),
1445
+ FfiConverterArrayBuffer.lower(
1446
+ accept,
1447
+ nativeModule().rustbuffer_alloc
1448
+ ),
1449
+ FfiConverterArrayBuffer.lower(sign, nativeModule().rustbuffer_alloc),
1450
+ FfiConverterTypeContractKeyProvider.lower(
1451
+ keys,
1452
+ nativeModule().rustbuffer_alloc
1453
+ ),
1454
+ FfiConverterArrayBuffer.lower(
1455
+ temporaryContractId,
1456
+ nativeModule().rustbuffer_alloc
1457
+ ),
1458
+ callStatus
1459
+ );
1460
+ },
1461
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
1462
+ )
1463
+ );
1464
+ }
838
1465
 
839
1466
  /**
840
- * Generated factory for {@link AdaptorSignature} record objects.
1467
+ * Signs a party's own funding inputs on the funding PSBT using a private output
1468
+ * descriptor (e.g. bdk's `wpkh(...)` with an xprv), returning the updated PSBT.
1469
+ * Each entry in `inputs` names one of this party's funding inputs (by serial
1470
+ * id) and the descriptor wildcard index that derives its key. Supports `wpkh()`
1471
+ * and `sh(wpkh())`, with or without a wildcard.
841
1472
  */
842
- export const AdaptorSignature = (() => {
843
- const defaults = () => ({});
844
- const create = (() => {
845
- return uniffiCreateRecord<AdaptorSignature, ReturnType<typeof defaults>>(
846
- defaults
847
- );
848
- })();
849
- return Object.freeze({
850
- create,
851
- new: create,
852
- defaults: () => Object.freeze(defaults()) as Partial<AdaptorSignature>,
853
- verifyFromOracleInfo(
854
- self_: AdaptorSignature,
855
- cet: Transaction,
856
- oracleInfos: Array<OracleInfo>,
857
- pubkey: ArrayBuffer,
858
- fundingScriptPubkey: ArrayBuffer,
859
- totalCollateral: bigint,
860
- msgs: Array<Array<ArrayBuffer>>
861
- ): boolean {
862
- return FfiConverterBool.lift(
863
- uniffiCaller.rustCall(
864
- /*caller:*/ (callStatus) => {
865
- return nativeModule().ubrn_uniffi_ddk_ffi_fn_method_adaptorsignature_verify_from_oracle_info(
866
- FfiConverterTypeAdaptorSignature.lower(
867
- self_,
868
- nativeModule().rustbuffer_alloc
869
- ),
870
- FfiConverterTypeTransaction.lower(
871
- cet,
872
- nativeModule().rustbuffer_alloc
873
- ),
874
- FfiConverterSequenceTypeOracleInfo.lower(
875
- oracleInfos,
876
- nativeModule().rustbuffer_alloc
877
- ),
878
- FfiConverterArrayBuffer.lower(
879
- pubkey,
880
- nativeModule().rustbuffer_alloc
881
- ),
882
- FfiConverterArrayBuffer.lower(
883
- fundingScriptPubkey,
884
- nativeModule().rustbuffer_alloc
885
- ),
886
- FfiConverterUInt64.lower(
887
- totalCollateral,
888
- nativeModule().rustbuffer_alloc
889
- ),
890
- FfiConverterSequenceSequenceBytes.lower(
891
- msgs,
892
- nativeModule().rustbuffer_alloc
893
- ),
894
- callStatus
895
- );
896
- },
897
- /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
898
- )
1473
+ export function signFundingPsbtWithDescriptor(
1474
+ offer: ArrayBuffer,
1475
+ accept: ArrayBuffer,
1476
+ fundingPsbt: ArrayBuffer,
1477
+ descriptor: string,
1478
+ inputs: Array<DescriptorInput>
1479
+ ): ArrayBuffer /*throws*/ {
1480
+ return ((__rb: Uint8Array) => {
1481
+ try {
1482
+ return FfiConverterArrayBuffer.lift(__rb);
1483
+ } finally {
1484
+ nativeModule().rustbuffer_free(__rb);
1485
+ }
1486
+ })(
1487
+ uniffiCaller.rustCallWithError(
1488
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
1489
+ FfiConverterTypeContractError
1490
+ ),
1491
+ /*caller:*/ (callStatus) => {
1492
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_sign_funding_psbt_with_descriptor(
1493
+ FfiConverterArrayBuffer.lower(offer, nativeModule().rustbuffer_alloc),
1494
+ FfiConverterArrayBuffer.lower(
1495
+ accept,
1496
+ nativeModule().rustbuffer_alloc
1497
+ ),
1498
+ FfiConverterArrayBuffer.lower(
1499
+ fundingPsbt,
1500
+ nativeModule().rustbuffer_alloc
1501
+ ),
1502
+ FfiConverterString.lower(descriptor, nativeModule().rustbuffer_alloc),
1503
+ FfiConverterSequenceTypeDescriptorInput.lower(
1504
+ inputs,
1505
+ nativeModule().rustbuffer_alloc
1506
+ ),
1507
+ callStatus
1508
+ );
1509
+ },
1510
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
1511
+ )
1512
+ );
1513
+ }
1514
+
1515
+ /**
1516
+ * Validates an accept message against its offer: the acceptor's CET adaptor
1517
+ * signatures and refund signature must be valid for the contract the two
1518
+ * messages describe. This is the same check `sign_accept` runs internally,
1519
+ * exposed so a stored/received `AcceptDlc` can be verified on its own.
1520
+ */
1521
+ export function validateAccept(
1522
+ offer: ArrayBuffer,
1523
+ accept: ArrayBuffer
1524
+ ): void /*throws*/ {
1525
+ uniffiCaller.rustCallWithError(
1526
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
1527
+ FfiConverterTypeContractError
1528
+ ),
1529
+ /*caller:*/ (callStatus) => {
1530
+ nativeModule().ubrn_uniffi_ddk_ffi_fn_func_validate_accept(
1531
+ FfiConverterArrayBuffer.lower(offer, nativeModule().rustbuffer_alloc),
1532
+ FfiConverterArrayBuffer.lower(accept, nativeModule().rustbuffer_alloc),
1533
+ callStatus
1534
+ );
1535
+ },
1536
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
1537
+ );
1538
+ }
1539
+
1540
+ /**
1541
+ * Validates an offer's protocol version, funding inputs, fee rate, collateral,
1542
+ * and oracle timeouts.
1543
+ *
1544
+ * The lifecycle functions already validate internally (`accept_offer` validates
1545
+ * the offer, `sign_accept` validates the accept, `finalize_sign` validates the
1546
+ * sign); these `validate_*` functions expose the same checks standalone, so a
1547
+ * consumer can independently verify a stored or received message at any time —
1548
+ * e.g. before persisting it, or when loading it back later.
1549
+ */
1550
+ export function validateOffer(
1551
+ offer: ArrayBuffer,
1552
+ minTimeoutInterval: number,
1553
+ maxTimeoutInterval: number
1554
+ ): void /*throws*/ {
1555
+ uniffiCaller.rustCallWithError(
1556
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
1557
+ FfiConverterTypeContractError
1558
+ ),
1559
+ /*caller:*/ (callStatus) => {
1560
+ nativeModule().ubrn_uniffi_ddk_ffi_fn_func_validate_offer(
1561
+ FfiConverterArrayBuffer.lower(offer, nativeModule().rustbuffer_alloc),
1562
+ FfiConverterUInt32.lower(
1563
+ minTimeoutInterval,
1564
+ nativeModule().rustbuffer_alloc
1565
+ ),
1566
+ FfiConverterUInt32.lower(
1567
+ maxTimeoutInterval,
1568
+ nativeModule().rustbuffer_alloc
1569
+ ),
1570
+ callStatus
1571
+ );
1572
+ },
1573
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
1574
+ );
1575
+ }
1576
+
1577
+ /**
1578
+ * Validates a sign message against its offer and accept: the offerer's CET
1579
+ * adaptor signatures and refund signature must be valid. This is the same
1580
+ * check `finalize_sign` runs internally, exposed so a stored/received `SignDlc`
1581
+ * can be verified on its own.
1582
+ */
1583
+ export function validateSign(
1584
+ offer: ArrayBuffer,
1585
+ accept: ArrayBuffer,
1586
+ sign: ArrayBuffer
1587
+ ): void /*throws*/ {
1588
+ uniffiCaller.rustCallWithError(
1589
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
1590
+ FfiConverterTypeContractError
1591
+ ),
1592
+ /*caller:*/ (callStatus) => {
1593
+ nativeModule().ubrn_uniffi_ddk_ffi_fn_func_validate_sign(
1594
+ FfiConverterArrayBuffer.lower(offer, nativeModule().rustbuffer_alloc),
1595
+ FfiConverterArrayBuffer.lower(accept, nativeModule().rustbuffer_alloc),
1596
+ FfiConverterArrayBuffer.lower(sign, nativeModule().rustbuffer_alloc),
1597
+ callStatus
899
1598
  );
900
1599
  },
1600
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
1601
+ );
1602
+ }
1603
+
1604
+ export function verifyCetAdaptorSigsFromOracleInfo(
1605
+ adaptorSigs: Array<AdaptorSignature>,
1606
+ cets: Array<Transaction>,
1607
+ oracleInfos: Array<OracleInfo>,
1608
+ pubkey: ArrayBuffer,
1609
+ fundingScriptPubkey: ArrayBuffer,
1610
+ totalCollateral: bigint,
1611
+ msgs: Array<Array<Array<ArrayBuffer>>>
1612
+ ): boolean {
1613
+ return FfiConverterBool.lift(
1614
+ uniffiCaller.rustCall(
1615
+ /*caller:*/ (callStatus) => {
1616
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_verify_cet_adaptor_sigs_from_oracle_info(
1617
+ FfiConverterSequenceTypeAdaptorSignature.lower(
1618
+ adaptorSigs,
1619
+ nativeModule().rustbuffer_alloc
1620
+ ),
1621
+ FfiConverterSequenceTypeTransaction.lower(
1622
+ cets,
1623
+ nativeModule().rustbuffer_alloc
1624
+ ),
1625
+ FfiConverterSequenceTypeOracleInfo.lower(
1626
+ oracleInfos,
1627
+ nativeModule().rustbuffer_alloc
1628
+ ),
1629
+ FfiConverterArrayBuffer.lower(
1630
+ pubkey,
1631
+ nativeModule().rustbuffer_alloc
1632
+ ),
1633
+ FfiConverterArrayBuffer.lower(
1634
+ fundingScriptPubkey,
1635
+ nativeModule().rustbuffer_alloc
1636
+ ),
1637
+ FfiConverterUInt64.lower(
1638
+ totalCollateral,
1639
+ nativeModule().rustbuffer_alloc
1640
+ ),
1641
+ FfiConverterSequenceSequenceSequenceBytes.lower(
1642
+ msgs,
1643
+ nativeModule().rustbuffer_alloc
1644
+ ),
1645
+ callStatus
1646
+ );
1647
+ },
1648
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
1649
+ )
1650
+ );
1651
+ }
1652
+
1653
+ export function version(): string {
1654
+ return ((__rb: Uint8Array) => {
1655
+ try {
1656
+ return FfiConverterString.lift(__rb);
1657
+ } finally {
1658
+ nativeModule().rustbuffer_free(__rb);
1659
+ }
1660
+ })(
1661
+ uniffiCaller.rustCall(
1662
+ /*caller:*/ (callStatus) => {
1663
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_version(callStatus);
1664
+ },
1665
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
1666
+ )
1667
+ );
1668
+ }
1669
+
1670
+ /**
1671
+ * One party's Bitcoin-level contract data (mirrors [`ddk::contract::PartyParams`]).
1672
+ */
1673
+ export type ContractPartyParams = {
1674
+ /**
1675
+ * The 33-byte compressed DLC funding public key.
1676
+ */
1677
+ fundingPubkey: ArrayBuffer;
1678
+ /**
1679
+ * The wallet UTXOs this party contributes, each a wire-encoded `FundingInput`.
1680
+ */
1681
+ fundingInputs: Array<ArrayBuffer>;
1682
+ /**
1683
+ * The script pubkey (raw bytes) CET and refund payouts are sent to.
1684
+ */
1685
+ payoutSpk: ArrayBuffer;
1686
+ /**
1687
+ * Serial id ordering the payout output; randomly generated when `None`.
1688
+ */
1689
+ payoutSerialId?: bigint;
1690
+ /**
1691
+ * The script pubkey (raw bytes) funding change is sent to.
1692
+ */
1693
+ changeSpk: ArrayBuffer;
1694
+ /**
1695
+ * Serial id ordering the change output; randomly generated when `None`.
1696
+ */
1697
+ changeSerialId?: bigint;
1698
+ };
1699
+
1700
+ /**
1701
+ * Generated factory for {@link ContractPartyParams} record objects.
1702
+ */
1703
+ export const ContractPartyParams = (() => {
1704
+ const defaults = () => ({});
1705
+ const create = (() => {
1706
+ return uniffiCreateRecord<ContractPartyParams, ReturnType<typeof defaults>>(
1707
+ defaults
1708
+ );
1709
+ })();
1710
+ return Object.freeze({
1711
+ create,
1712
+ new: create,
1713
+ defaults: () => Object.freeze(defaults()) as Partial<ContractPartyParams>,
901
1714
  });
902
1715
  })();
903
1716
 
904
- const FfiConverterTypeAdaptorSignature = (() => {
905
- type TypeName = AdaptorSignature;
1717
+ const FfiConverterTypeContractPartyParams = (() => {
1718
+ type TypeName = ContractPartyParams;
906
1719
  class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
907
1720
  read(from: RustBuffer): TypeName {
908
1721
  return {
909
- signature: FfiConverterArrayBuffer.read(from),
910
- proof: FfiConverterArrayBuffer.read(from),
1722
+ fundingPubkey: FfiConverterArrayBuffer.read(from),
1723
+ fundingInputs: FfiConverterSequenceBytes.read(from),
1724
+ payoutSpk: FfiConverterArrayBuffer.read(from),
1725
+ payoutSerialId: FfiConverterOptionalUInt64.read(from),
1726
+ changeSpk: FfiConverterArrayBuffer.read(from),
1727
+ changeSerialId: FfiConverterOptionalUInt64.read(from),
911
1728
  };
912
1729
  }
913
1730
  write(value: TypeName, into: RustBuffer): void {
914
- FfiConverterArrayBuffer.write(value.signature, into);
915
- FfiConverterArrayBuffer.write(value.proof, into);
1731
+ FfiConverterArrayBuffer.write(value.fundingPubkey, into);
1732
+ FfiConverterSequenceBytes.write(value.fundingInputs, into);
1733
+ FfiConverterArrayBuffer.write(value.payoutSpk, into);
1734
+ FfiConverterOptionalUInt64.write(value.payoutSerialId, into);
1735
+ FfiConverterArrayBuffer.write(value.changeSpk, into);
1736
+ FfiConverterOptionalUInt64.write(value.changeSerialId, into);
916
1737
  }
917
1738
  allocationSize(value: TypeName): number {
918
1739
  return (
919
- FfiConverterArrayBuffer.allocationSize(value.signature) +
920
- FfiConverterArrayBuffer.allocationSize(value.proof)
1740
+ FfiConverterArrayBuffer.allocationSize(value.fundingPubkey) +
1741
+ FfiConverterSequenceBytes.allocationSize(value.fundingInputs) +
1742
+ FfiConverterArrayBuffer.allocationSize(value.payoutSpk) +
1743
+ FfiConverterOptionalUInt64.allocationSize(value.payoutSerialId) +
1744
+ FfiConverterArrayBuffer.allocationSize(value.changeSpk) +
1745
+ FfiConverterOptionalUInt64.allocationSize(value.changeSerialId)
1746
+ );
1747
+ }
1748
+ }
1749
+ return new FFIConverter();
1750
+ })();
1751
+
1752
+ /**
1753
+ * Parameters for [`accept_offer`] (mirrors [`ddk::contract::AcceptOfferParams`]).
1754
+ */
1755
+ export type AcceptOfferParams = {
1756
+ /**
1757
+ * The accepting party's Bitcoin-level contract data.
1758
+ */
1759
+ party: ContractPartyParams;
1760
+ /**
1761
+ * The minimum accepted interval between oracle maturity and the refund locktime.
1762
+ */
1763
+ minTimeoutInterval: number;
1764
+ /**
1765
+ * The maximum accepted interval between oracle maturity and the refund locktime.
1766
+ */
1767
+ maxTimeoutInterval: number;
1768
+ };
1769
+
1770
+ /**
1771
+ * Generated factory for {@link AcceptOfferParams} record objects.
1772
+ */
1773
+ export const AcceptOfferParams = (() => {
1774
+ const defaults = () => ({});
1775
+ const create = (() => {
1776
+ return uniffiCreateRecord<AcceptOfferParams, ReturnType<typeof defaults>>(
1777
+ defaults
1778
+ );
1779
+ })();
1780
+ return Object.freeze({
1781
+ create,
1782
+ new: create,
1783
+ defaults: () => Object.freeze(defaults()) as Partial<AcceptOfferParams>,
1784
+ });
1785
+ })();
1786
+
1787
+ const FfiConverterTypeAcceptOfferParams = (() => {
1788
+ type TypeName = AcceptOfferParams;
1789
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1790
+ read(from: RustBuffer): TypeName {
1791
+ return {
1792
+ party: FfiConverterTypeContractPartyParams.read(from),
1793
+ minTimeoutInterval: FfiConverterUInt32.read(from),
1794
+ maxTimeoutInterval: FfiConverterUInt32.read(from),
1795
+ };
1796
+ }
1797
+ write(value: TypeName, into: RustBuffer): void {
1798
+ FfiConverterTypeContractPartyParams.write(value.party, into);
1799
+ FfiConverterUInt32.write(value.minTimeoutInterval, into);
1800
+ FfiConverterUInt32.write(value.maxTimeoutInterval, into);
1801
+ }
1802
+ allocationSize(value: TypeName): number {
1803
+ return (
1804
+ FfiConverterTypeContractPartyParams.allocationSize(value.party) +
1805
+ FfiConverterUInt32.allocationSize(value.minTimeoutInterval) +
1806
+ FfiConverterUInt32.allocationSize(value.maxTimeoutInterval)
921
1807
  );
922
1808
  }
923
1809
  }
@@ -986,97 +1872,55 @@ const stringConverter = (() => {
986
1872
  })();
987
1873
  const FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
988
1874
 
989
- /**
990
- * Debug info for CET adaptor signature inputs.
991
- *
992
- * Contains all the values that go into creating an adaptor signature,
993
- * useful for comparing with external signers during debugging.
994
- *
995
- * This struct is intentionally always available (not feature-gated)
996
- * to support production debugging scenarios.
997
- */
998
- export type CetAdaptorSignatureDebugInfo = {
999
- /**
1000
- * The sighash (32 bytes) - this is the message that gets signed
1001
- */
1002
- sighash: ArrayBuffer;
1003
- /**
1004
- * The adaptor point (33 bytes compressed public key)
1005
- */
1006
- adaptorPoint: ArrayBuffer;
1007
- /**
1008
- * Input index (always 0 for CETs)
1009
- */
1010
- inputIndex: number;
1011
- /**
1012
- * The funding script pubkey used for sighash
1013
- */
1014
- scriptPubkey: ArrayBuffer;
1015
- /**
1016
- * The fund output value used for sighash
1017
- */
1018
- value: bigint;
1019
- /**
1020
- * The CET txid
1021
- */
1022
- cetTxid: string;
1023
- /**
1024
- * Raw CET bytes for verification
1025
- */
1026
- cetRaw: ArrayBuffer;
1875
+ export type TxInput = {
1876
+ txid: string;
1877
+ vout: number;
1878
+ scriptSig: ArrayBuffer;
1879
+ sequence: number;
1880
+ witness: Array<ArrayBuffer>;
1027
1881
  };
1028
1882
 
1029
1883
  /**
1030
- * Generated factory for {@link CetAdaptorSignatureDebugInfo} record objects.
1884
+ * Generated factory for {@link TxInput} record objects.
1031
1885
  */
1032
- export const CetAdaptorSignatureDebugInfo = (() => {
1886
+ export const TxInput = (() => {
1033
1887
  const defaults = () => ({});
1034
1888
  const create = (() => {
1035
- return uniffiCreateRecord<
1036
- CetAdaptorSignatureDebugInfo,
1037
- ReturnType<typeof defaults>
1038
- >(defaults);
1889
+ return uniffiCreateRecord<TxInput, ReturnType<typeof defaults>>(defaults);
1039
1890
  })();
1040
1891
  return Object.freeze({
1041
1892
  create,
1042
1893
  new: create,
1043
- defaults: () =>
1044
- Object.freeze(defaults()) as Partial<CetAdaptorSignatureDebugInfo>,
1894
+ defaults: () => Object.freeze(defaults()) as Partial<TxInput>,
1045
1895
  });
1046
1896
  })();
1047
1897
 
1048
- const FfiConverterTypeCetAdaptorSignatureDebugInfo = (() => {
1049
- type TypeName = CetAdaptorSignatureDebugInfo;
1898
+ const FfiConverterTypeTxInput = (() => {
1899
+ type TypeName = TxInput;
1050
1900
  class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1051
1901
  read(from: RustBuffer): TypeName {
1052
1902
  return {
1053
- sighash: FfiConverterArrayBuffer.read(from),
1054
- adaptorPoint: FfiConverterArrayBuffer.read(from),
1055
- inputIndex: FfiConverterUInt32.read(from),
1056
- scriptPubkey: FfiConverterArrayBuffer.read(from),
1057
- value: FfiConverterUInt64.read(from),
1058
- cetTxid: FfiConverterString.read(from),
1059
- cetRaw: FfiConverterArrayBuffer.read(from),
1903
+ txid: FfiConverterString.read(from),
1904
+ vout: FfiConverterUInt32.read(from),
1905
+ scriptSig: FfiConverterArrayBuffer.read(from),
1906
+ sequence: FfiConverterUInt32.read(from),
1907
+ witness: FfiConverterSequenceBytes.read(from),
1060
1908
  };
1061
1909
  }
1062
1910
  write(value: TypeName, into: RustBuffer): void {
1063
- FfiConverterArrayBuffer.write(value.sighash, into);
1064
- FfiConverterArrayBuffer.write(value.adaptorPoint, into);
1065
- FfiConverterUInt32.write(value.inputIndex, into);
1066
- FfiConverterArrayBuffer.write(value.scriptPubkey, into);
1067
- FfiConverterUInt64.write(value.value, into);
1068
- FfiConverterString.write(value.cetTxid, into);
1069
- FfiConverterArrayBuffer.write(value.cetRaw, into);
1911
+ FfiConverterString.write(value.txid, into);
1912
+ FfiConverterUInt32.write(value.vout, into);
1913
+ FfiConverterArrayBuffer.write(value.scriptSig, into);
1914
+ FfiConverterUInt32.write(value.sequence, into);
1915
+ FfiConverterSequenceBytes.write(value.witness, into);
1070
1916
  }
1071
1917
  allocationSize(value: TypeName): number {
1072
1918
  return (
1073
- FfiConverterArrayBuffer.allocationSize(value.sighash) +
1074
- FfiConverterArrayBuffer.allocationSize(value.adaptorPoint) +
1075
- FfiConverterUInt32.allocationSize(value.inputIndex) +
1076
- FfiConverterArrayBuffer.allocationSize(value.scriptPubkey) +
1077
- FfiConverterUInt64.allocationSize(value.value) +
1078
- FfiConverterString.allocationSize(value.cetTxid) +
1079
- FfiConverterArrayBuffer.allocationSize(value.cetRaw)
1919
+ FfiConverterString.allocationSize(value.txid) +
1920
+ FfiConverterUInt32.allocationSize(value.vout) +
1921
+ FfiConverterArrayBuffer.allocationSize(value.scriptSig) +
1922
+ FfiConverterUInt32.allocationSize(value.sequence) +
1923
+ FfiConverterSequenceBytes.allocationSize(value.witness)
1080
1924
  );
1081
1925
  }
1082
1926
  }
@@ -1142,110 +1986,6 @@ const FfiConverterTypeTxOutput = (() => {
1142
1986
  return new FFIConverter();
1143
1987
  })();
1144
1988
 
1145
- export type ChangeOutputAndFees = {
1146
- changeOutput: TxOutput;
1147
- fundFee: bigint;
1148
- cetFee: bigint;
1149
- };
1150
-
1151
- /**
1152
- * Generated factory for {@link ChangeOutputAndFees} record objects.
1153
- */
1154
- export const ChangeOutputAndFees = (() => {
1155
- const defaults = () => ({});
1156
- const create = (() => {
1157
- return uniffiCreateRecord<ChangeOutputAndFees, ReturnType<typeof defaults>>(
1158
- defaults
1159
- );
1160
- })();
1161
- return Object.freeze({
1162
- create,
1163
- new: create,
1164
- defaults: () => Object.freeze(defaults()) as Partial<ChangeOutputAndFees>,
1165
- });
1166
- })();
1167
-
1168
- const FfiConverterTypeChangeOutputAndFees = (() => {
1169
- type TypeName = ChangeOutputAndFees;
1170
- class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1171
- read(from: RustBuffer): TypeName {
1172
- return {
1173
- changeOutput: FfiConverterTypeTxOutput.read(from),
1174
- fundFee: FfiConverterUInt64.read(from),
1175
- cetFee: FfiConverterUInt64.read(from),
1176
- };
1177
- }
1178
- write(value: TypeName, into: RustBuffer): void {
1179
- FfiConverterTypeTxOutput.write(value.changeOutput, into);
1180
- FfiConverterUInt64.write(value.fundFee, into);
1181
- FfiConverterUInt64.write(value.cetFee, into);
1182
- }
1183
- allocationSize(value: TypeName): number {
1184
- return (
1185
- FfiConverterTypeTxOutput.allocationSize(value.changeOutput) +
1186
- FfiConverterUInt64.allocationSize(value.fundFee) +
1187
- FfiConverterUInt64.allocationSize(value.cetFee)
1188
- );
1189
- }
1190
- }
1191
- return new FFIConverter();
1192
- })();
1193
-
1194
- export type TxInput = {
1195
- txid: string;
1196
- vout: number;
1197
- scriptSig: ArrayBuffer;
1198
- sequence: number;
1199
- witness: Array<ArrayBuffer>;
1200
- };
1201
-
1202
- /**
1203
- * Generated factory for {@link TxInput} record objects.
1204
- */
1205
- export const TxInput = (() => {
1206
- const defaults = () => ({});
1207
- const create = (() => {
1208
- return uniffiCreateRecord<TxInput, ReturnType<typeof defaults>>(defaults);
1209
- })();
1210
- return Object.freeze({
1211
- create,
1212
- new: create,
1213
- defaults: () => Object.freeze(defaults()) as Partial<TxInput>,
1214
- });
1215
- })();
1216
-
1217
- const FfiConverterTypeTxInput = (() => {
1218
- type TypeName = TxInput;
1219
- class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1220
- read(from: RustBuffer): TypeName {
1221
- return {
1222
- txid: FfiConverterString.read(from),
1223
- vout: FfiConverterUInt32.read(from),
1224
- scriptSig: FfiConverterArrayBuffer.read(from),
1225
- sequence: FfiConverterUInt32.read(from),
1226
- witness: FfiConverterSequenceBytes.read(from),
1227
- };
1228
- }
1229
- write(value: TypeName, into: RustBuffer): void {
1230
- FfiConverterString.write(value.txid, into);
1231
- FfiConverterUInt32.write(value.vout, into);
1232
- FfiConverterArrayBuffer.write(value.scriptSig, into);
1233
- FfiConverterUInt32.write(value.sequence, into);
1234
- FfiConverterSequenceBytes.write(value.witness, into);
1235
- }
1236
- allocationSize(value: TypeName): number {
1237
- return (
1238
- FfiConverterString.allocationSize(value.txid) +
1239
- FfiConverterUInt32.allocationSize(value.vout) +
1240
- FfiConverterArrayBuffer.allocationSize(value.scriptSig) +
1241
- FfiConverterUInt32.allocationSize(value.sequence) +
1242
- FfiConverterSequenceBytes.allocationSize(value.witness)
1243
- );
1244
- }
1245
- }
1246
- return new FFIConverter();
1247
- })();
1248
-
1249
1989
  export type Transaction = {
1250
1990
  version: number;
1251
1991
  lockTime: number;
@@ -1708,75 +2448,6 @@ const FfiConverterTypeTransaction = (() => {
1708
2448
  return new FFIConverter();
1709
2449
  })();
1710
2450
 
1711
- export type DlcInputInfo = {
1712
- fundTx: Transaction;
1713
- fundVout: number;
1714
- localFundPubkey: ArrayBuffer;
1715
- remoteFundPubkey: ArrayBuffer;
1716
- fundAmount: bigint;
1717
- maxWitnessLen: number;
1718
- inputSerialId: bigint;
1719
- contractId: ArrayBuffer;
1720
- };
1721
-
1722
- /**
1723
- * Generated factory for {@link DlcInputInfo} record objects.
1724
- */
1725
- export const DlcInputInfo = (() => {
1726
- const defaults = () => ({});
1727
- const create = (() => {
1728
- return uniffiCreateRecord<DlcInputInfo, ReturnType<typeof defaults>>(
1729
- defaults
1730
- );
1731
- })();
1732
- return Object.freeze({
1733
- create,
1734
- new: create,
1735
- defaults: () => Object.freeze(defaults()) as Partial<DlcInputInfo>,
1736
- });
1737
- })();
1738
-
1739
- const FfiConverterTypeDlcInputInfo = (() => {
1740
- type TypeName = DlcInputInfo;
1741
- class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1742
- read(from: RustBuffer): TypeName {
1743
- return {
1744
- fundTx: FfiConverterTypeTransaction.read(from),
1745
- fundVout: FfiConverterUInt32.read(from),
1746
- localFundPubkey: FfiConverterArrayBuffer.read(from),
1747
- remoteFundPubkey: FfiConverterArrayBuffer.read(from),
1748
- fundAmount: FfiConverterUInt64.read(from),
1749
- maxWitnessLen: FfiConverterUInt32.read(from),
1750
- inputSerialId: FfiConverterUInt64.read(from),
1751
- contractId: FfiConverterArrayBuffer.read(from),
1752
- };
1753
- }
1754
- write(value: TypeName, into: RustBuffer): void {
1755
- FfiConverterTypeTransaction.write(value.fundTx, into);
1756
- FfiConverterUInt32.write(value.fundVout, into);
1757
- FfiConverterArrayBuffer.write(value.localFundPubkey, into);
1758
- FfiConverterArrayBuffer.write(value.remoteFundPubkey, into);
1759
- FfiConverterUInt64.write(value.fundAmount, into);
1760
- FfiConverterUInt32.write(value.maxWitnessLen, into);
1761
- FfiConverterUInt64.write(value.inputSerialId, into);
1762
- FfiConverterArrayBuffer.write(value.contractId, into);
1763
- }
1764
- allocationSize(value: TypeName): number {
1765
- return (
1766
- FfiConverterTypeTransaction.allocationSize(value.fundTx) +
1767
- FfiConverterUInt32.allocationSize(value.fundVout) +
1768
- FfiConverterArrayBuffer.allocationSize(value.localFundPubkey) +
1769
- FfiConverterArrayBuffer.allocationSize(value.remoteFundPubkey) +
1770
- FfiConverterUInt64.allocationSize(value.fundAmount) +
1771
- FfiConverterUInt32.allocationSize(value.maxWitnessLen) +
1772
- FfiConverterUInt64.allocationSize(value.inputSerialId) +
1773
- FfiConverterArrayBuffer.allocationSize(value.contractId)
1774
- );
1775
- }
1776
- }
1777
- return new FFIConverter();
1778
- })();
1779
-
1780
2451
  export type DlcTransactions = {
1781
2452
  fund: Transaction;
1782
2453
  cets: Array<Transaction>;
@@ -1830,251 +2501,2062 @@ const FfiConverterTypeDlcTransactions = (() => {
1830
2501
  return new FFIConverter();
1831
2502
  })();
1832
2503
 
1833
- export type OracleInfo = {
1834
- publicKey: ArrayBuffer;
1835
- nonces: Array<ArrayBuffer>;
2504
+ /**
2505
+ * The result of [`accept_offer`].
2506
+ */
2507
+ export type AcceptResult = {
2508
+ /**
2509
+ * The wire-encoded `AcceptDlc` message to send to the offering party.
2510
+ */
2511
+ accept: ArrayBuffer;
2512
+ /**
2513
+ * The unsigned funding, CET, and refund transactions.
2514
+ */
2515
+ transactions: DlcTransactions;
2516
+ /**
2517
+ * The BIP-174 funding PSBT ready to be signed by either party's funding source.
2518
+ */
2519
+ fundingPsbt: ArrayBuffer;
1836
2520
  };
1837
2521
 
1838
2522
  /**
1839
- * Generated factory for {@link OracleInfo} record objects.
2523
+ * Generated factory for {@link AcceptResult} record objects.
1840
2524
  */
1841
- export const OracleInfo = (() => {
2525
+ export const AcceptResult = (() => {
1842
2526
  const defaults = () => ({});
1843
2527
  const create = (() => {
1844
- return uniffiCreateRecord<OracleInfo, ReturnType<typeof defaults>>(
2528
+ return uniffiCreateRecord<AcceptResult, ReturnType<typeof defaults>>(
1845
2529
  defaults
1846
2530
  );
1847
2531
  })();
1848
2532
  return Object.freeze({
1849
2533
  create,
1850
2534
  new: create,
1851
- defaults: () => Object.freeze(defaults()) as Partial<OracleInfo>,
2535
+ defaults: () => Object.freeze(defaults()) as Partial<AcceptResult>,
1852
2536
  });
1853
2537
  })();
1854
2538
 
1855
- const FfiConverterTypeOracleInfo = (() => {
1856
- type TypeName = OracleInfo;
2539
+ const FfiConverterTypeAcceptResult = (() => {
2540
+ type TypeName = AcceptResult;
1857
2541
  class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1858
2542
  read(from: RustBuffer): TypeName {
1859
2543
  return {
1860
- publicKey: FfiConverterArrayBuffer.read(from),
1861
- nonces: FfiConverterSequenceBytes.read(from),
2544
+ accept: FfiConverterArrayBuffer.read(from),
2545
+ transactions: FfiConverterTypeDlcTransactions.read(from),
2546
+ fundingPsbt: FfiConverterArrayBuffer.read(from),
1862
2547
  };
1863
2548
  }
1864
2549
  write(value: TypeName, into: RustBuffer): void {
1865
- FfiConverterArrayBuffer.write(value.publicKey, into);
1866
- FfiConverterSequenceBytes.write(value.nonces, into);
2550
+ FfiConverterArrayBuffer.write(value.accept, into);
2551
+ FfiConverterTypeDlcTransactions.write(value.transactions, into);
2552
+ FfiConverterArrayBuffer.write(value.fundingPsbt, into);
1867
2553
  }
1868
2554
  allocationSize(value: TypeName): number {
1869
2555
  return (
1870
- FfiConverterArrayBuffer.allocationSize(value.publicKey) +
1871
- FfiConverterSequenceBytes.allocationSize(value.nonces)
2556
+ FfiConverterArrayBuffer.allocationSize(value.accept) +
2557
+ FfiConverterTypeDlcTransactions.allocationSize(value.transactions) +
2558
+ FfiConverterArrayBuffer.allocationSize(value.fundingPsbt)
1872
2559
  );
1873
2560
  }
1874
2561
  }
1875
2562
  return new FFIConverter();
1876
2563
  })();
1877
2564
 
1878
- export type TxInputInfo = {
1879
- txid: string;
1880
- vout: number;
1881
- scriptSig: ArrayBuffer;
1882
- maxWitnessLength: number;
1883
- serialId: bigint;
2565
+ export type AdaptorSignature = {
2566
+ signature: ArrayBuffer;
2567
+ proof: ArrayBuffer;
1884
2568
  };
1885
2569
 
1886
2570
  /**
1887
- * Generated factory for {@link TxInputInfo} record objects.
2571
+ * Generated factory for {@link AdaptorSignature} record objects.
1888
2572
  */
1889
- export const TxInputInfo = (() => {
2573
+ export const AdaptorSignature = (() => {
1890
2574
  const defaults = () => ({});
1891
2575
  const create = (() => {
1892
- return uniffiCreateRecord<TxInputInfo, ReturnType<typeof defaults>>(
2576
+ return uniffiCreateRecord<AdaptorSignature, ReturnType<typeof defaults>>(
1893
2577
  defaults
1894
2578
  );
1895
2579
  })();
1896
2580
  return Object.freeze({
1897
2581
  create,
1898
2582
  new: create,
1899
- defaults: () => Object.freeze(defaults()) as Partial<TxInputInfo>,
1900
- });
1901
- })();
1902
-
1903
- const FfiConverterTypeTxInputInfo = (() => {
1904
- type TypeName = TxInputInfo;
2583
+ defaults: () => Object.freeze(defaults()) as Partial<AdaptorSignature>,
2584
+ verifyFromOracleInfo(
2585
+ self_: AdaptorSignature,
2586
+ cet: Transaction,
2587
+ oracleInfos: Array<OracleInfo>,
2588
+ pubkey: ArrayBuffer,
2589
+ fundingScriptPubkey: ArrayBuffer,
2590
+ totalCollateral: bigint,
2591
+ msgs: Array<Array<ArrayBuffer>>
2592
+ ): boolean {
2593
+ return FfiConverterBool.lift(
2594
+ uniffiCaller.rustCall(
2595
+ /*caller:*/ (callStatus) => {
2596
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_method_adaptorsignature_verify_from_oracle_info(
2597
+ FfiConverterTypeAdaptorSignature.lower(
2598
+ self_,
2599
+ nativeModule().rustbuffer_alloc
2600
+ ),
2601
+ FfiConverterTypeTransaction.lower(
2602
+ cet,
2603
+ nativeModule().rustbuffer_alloc
2604
+ ),
2605
+ FfiConverterSequenceTypeOracleInfo.lower(
2606
+ oracleInfos,
2607
+ nativeModule().rustbuffer_alloc
2608
+ ),
2609
+ FfiConverterArrayBuffer.lower(
2610
+ pubkey,
2611
+ nativeModule().rustbuffer_alloc
2612
+ ),
2613
+ FfiConverterArrayBuffer.lower(
2614
+ fundingScriptPubkey,
2615
+ nativeModule().rustbuffer_alloc
2616
+ ),
2617
+ FfiConverterUInt64.lower(
2618
+ totalCollateral,
2619
+ nativeModule().rustbuffer_alloc
2620
+ ),
2621
+ FfiConverterSequenceSequenceBytes.lower(
2622
+ msgs,
2623
+ nativeModule().rustbuffer_alloc
2624
+ ),
2625
+ callStatus
2626
+ );
2627
+ },
2628
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
2629
+ )
2630
+ );
2631
+ },
2632
+ });
2633
+ })();
2634
+
2635
+ const FfiConverterTypeAdaptorSignature = (() => {
2636
+ type TypeName = AdaptorSignature;
1905
2637
  class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1906
2638
  read(from: RustBuffer): TypeName {
1907
2639
  return {
1908
- txid: FfiConverterString.read(from),
1909
- vout: FfiConverterUInt32.read(from),
1910
- scriptSig: FfiConverterArrayBuffer.read(from),
1911
- maxWitnessLength: FfiConverterUInt32.read(from),
1912
- serialId: FfiConverterUInt64.read(from),
2640
+ signature: FfiConverterArrayBuffer.read(from),
2641
+ proof: FfiConverterArrayBuffer.read(from),
1913
2642
  };
1914
2643
  }
1915
2644
  write(value: TypeName, into: RustBuffer): void {
1916
- FfiConverterString.write(value.txid, into);
1917
- FfiConverterUInt32.write(value.vout, into);
1918
- FfiConverterArrayBuffer.write(value.scriptSig, into);
1919
- FfiConverterUInt32.write(value.maxWitnessLength, into);
1920
- FfiConverterUInt64.write(value.serialId, into);
2645
+ FfiConverterArrayBuffer.write(value.signature, into);
2646
+ FfiConverterArrayBuffer.write(value.proof, into);
1921
2647
  }
1922
2648
  allocationSize(value: TypeName): number {
1923
2649
  return (
1924
- FfiConverterString.allocationSize(value.txid) +
1925
- FfiConverterUInt32.allocationSize(value.vout) +
1926
- FfiConverterArrayBuffer.allocationSize(value.scriptSig) +
1927
- FfiConverterUInt32.allocationSize(value.maxWitnessLength) +
1928
- FfiConverterUInt64.allocationSize(value.serialId)
2650
+ FfiConverterArrayBuffer.allocationSize(value.signature) +
2651
+ FfiConverterArrayBuffer.allocationSize(value.proof)
1929
2652
  );
1930
2653
  }
1931
2654
  }
1932
2655
  return new FFIConverter();
1933
2656
  })();
1934
2657
 
1935
- export type PartyParams = {
1936
- fundPubkey: ArrayBuffer;
1937
- changeScriptPubkey: ArrayBuffer;
1938
- changeSerialId: bigint;
1939
- payoutScriptPubkey: ArrayBuffer;
1940
- payoutSerialId: bigint;
1941
- inputs: Array<TxInputInfo>;
1942
- inputAmount: bigint;
1943
- collateral: bigint;
1944
- dlcInputs: Array<DlcInputInfo>;
2658
+ /**
2659
+ * Debug info for CET adaptor signature inputs.
2660
+ *
2661
+ * Contains all the values that go into creating an adaptor signature,
2662
+ * useful for comparing with external signers during debugging.
2663
+ *
2664
+ * This struct is intentionally always available (not feature-gated)
2665
+ * to support production debugging scenarios.
2666
+ */
2667
+ export type CetAdaptorSignatureDebugInfo = {
2668
+ /**
2669
+ * The sighash (32 bytes) - this is the message that gets signed
2670
+ */
2671
+ sighash: ArrayBuffer;
2672
+ /**
2673
+ * The adaptor point (33 bytes compressed public key)
2674
+ */
2675
+ adaptorPoint: ArrayBuffer;
2676
+ /**
2677
+ * Input index (always 0 for CETs)
2678
+ */
2679
+ inputIndex: number;
2680
+ /**
2681
+ * The funding script pubkey used for sighash
2682
+ */
2683
+ scriptPubkey: ArrayBuffer;
2684
+ /**
2685
+ * The fund output value used for sighash
2686
+ */
2687
+ value: bigint;
2688
+ /**
2689
+ * The CET txid
2690
+ */
2691
+ cetTxid: string;
2692
+ /**
2693
+ * Raw CET bytes for verification
2694
+ */
2695
+ cetRaw: ArrayBuffer;
1945
2696
  };
1946
2697
 
1947
2698
  /**
1948
- * Generated factory for {@link PartyParams} record objects.
2699
+ * Generated factory for {@link CetAdaptorSignatureDebugInfo} record objects.
1949
2700
  */
1950
- export const PartyParams = (() => {
2701
+ export const CetAdaptorSignatureDebugInfo = (() => {
1951
2702
  const defaults = () => ({});
1952
2703
  const create = (() => {
1953
- return uniffiCreateRecord<PartyParams, ReturnType<typeof defaults>>(
1954
- defaults
1955
- );
2704
+ return uniffiCreateRecord<
2705
+ CetAdaptorSignatureDebugInfo,
2706
+ ReturnType<typeof defaults>
2707
+ >(defaults);
1956
2708
  })();
1957
2709
  return Object.freeze({
1958
2710
  create,
1959
2711
  new: create,
1960
- defaults: () => Object.freeze(defaults()) as Partial<PartyParams>,
1961
- changeOutputAndFees(
1962
- self_: PartyParams,
1963
- feeRate: bigint
1964
- ): ChangeOutputAndFees {
1965
- return ((__rb: Uint8Array) => {
1966
- try {
1967
- return FfiConverterTypeChangeOutputAndFees.lift(__rb);
1968
- } finally {
1969
- nativeModule().rustbuffer_free(__rb);
1970
- }
1971
- })(
1972
- uniffiCaller.rustCallWithError(
1973
- /*liftError:*/ FfiConverterTypeDLCError.lift.bind(
1974
- FfiConverterTypeDLCError
1975
- ),
1976
- /*caller:*/ (callStatus) => {
1977
- return nativeModule().ubrn_uniffi_ddk_ffi_fn_method_partyparams_change_output_and_fees(
1978
- FfiConverterTypePartyParams.lower(
1979
- self_,
1980
- nativeModule().rustbuffer_alloc
1981
- ),
1982
- FfiConverterUInt64.lower(
1983
- feeRate,
1984
- nativeModule().rustbuffer_alloc
1985
- ),
1986
- callStatus
1987
- );
1988
- },
1989
- /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
1990
- )
1991
- );
1992
- },
2712
+ defaults: () =>
2713
+ Object.freeze(defaults()) as Partial<CetAdaptorSignatureDebugInfo>,
1993
2714
  });
1994
2715
  })();
1995
2716
 
1996
- const FfiConverterTypePartyParams = (() => {
1997
- type TypeName = PartyParams;
2717
+ const FfiConverterTypeCetAdaptorSignatureDebugInfo = (() => {
2718
+ type TypeName = CetAdaptorSignatureDebugInfo;
1998
2719
  class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1999
2720
  read(from: RustBuffer): TypeName {
2000
2721
  return {
2001
- fundPubkey: FfiConverterArrayBuffer.read(from),
2002
- changeScriptPubkey: FfiConverterArrayBuffer.read(from),
2003
- changeSerialId: FfiConverterUInt64.read(from),
2004
- payoutScriptPubkey: FfiConverterArrayBuffer.read(from),
2005
- payoutSerialId: FfiConverterUInt64.read(from),
2006
- inputs: FfiConverterSequenceTypeTxInputInfo.read(from),
2007
- inputAmount: FfiConverterUInt64.read(from),
2008
- collateral: FfiConverterUInt64.read(from),
2009
- dlcInputs: FfiConverterSequenceTypeDlcInputInfo.read(from),
2722
+ sighash: FfiConverterArrayBuffer.read(from),
2723
+ adaptorPoint: FfiConverterArrayBuffer.read(from),
2724
+ inputIndex: FfiConverterUInt32.read(from),
2725
+ scriptPubkey: FfiConverterArrayBuffer.read(from),
2726
+ value: FfiConverterUInt64.read(from),
2727
+ cetTxid: FfiConverterString.read(from),
2728
+ cetRaw: FfiConverterArrayBuffer.read(from),
2010
2729
  };
2011
2730
  }
2012
2731
  write(value: TypeName, into: RustBuffer): void {
2013
- FfiConverterArrayBuffer.write(value.fundPubkey, into);
2014
- FfiConverterArrayBuffer.write(value.changeScriptPubkey, into);
2015
- FfiConverterUInt64.write(value.changeSerialId, into);
2016
- FfiConverterArrayBuffer.write(value.payoutScriptPubkey, into);
2017
- FfiConverterUInt64.write(value.payoutSerialId, into);
2018
- FfiConverterSequenceTypeTxInputInfo.write(value.inputs, into);
2019
- FfiConverterUInt64.write(value.inputAmount, into);
2020
- FfiConverterUInt64.write(value.collateral, into);
2021
- FfiConverterSequenceTypeDlcInputInfo.write(value.dlcInputs, into);
2732
+ FfiConverterArrayBuffer.write(value.sighash, into);
2733
+ FfiConverterArrayBuffer.write(value.adaptorPoint, into);
2734
+ FfiConverterUInt32.write(value.inputIndex, into);
2735
+ FfiConverterArrayBuffer.write(value.scriptPubkey, into);
2736
+ FfiConverterUInt64.write(value.value, into);
2737
+ FfiConverterString.write(value.cetTxid, into);
2738
+ FfiConverterArrayBuffer.write(value.cetRaw, into);
2022
2739
  }
2023
2740
  allocationSize(value: TypeName): number {
2024
2741
  return (
2025
- FfiConverterArrayBuffer.allocationSize(value.fundPubkey) +
2026
- FfiConverterArrayBuffer.allocationSize(value.changeScriptPubkey) +
2027
- FfiConverterUInt64.allocationSize(value.changeSerialId) +
2028
- FfiConverterArrayBuffer.allocationSize(value.payoutScriptPubkey) +
2029
- FfiConverterUInt64.allocationSize(value.payoutSerialId) +
2030
- FfiConverterSequenceTypeTxInputInfo.allocationSize(value.inputs) +
2031
- FfiConverterUInt64.allocationSize(value.inputAmount) +
2032
- FfiConverterUInt64.allocationSize(value.collateral) +
2033
- FfiConverterSequenceTypeDlcInputInfo.allocationSize(value.dlcInputs)
2742
+ FfiConverterArrayBuffer.allocationSize(value.sighash) +
2743
+ FfiConverterArrayBuffer.allocationSize(value.adaptorPoint) +
2744
+ FfiConverterUInt32.allocationSize(value.inputIndex) +
2745
+ FfiConverterArrayBuffer.allocationSize(value.scriptPubkey) +
2746
+ FfiConverterUInt64.allocationSize(value.value) +
2747
+ FfiConverterString.allocationSize(value.cetTxid) +
2748
+ FfiConverterArrayBuffer.allocationSize(value.cetRaw)
2034
2749
  );
2035
2750
  }
2036
2751
  }
2037
2752
  return new FFIConverter();
2038
2753
  })();
2039
2754
 
2040
- export type Payout = {
2041
- offer: bigint;
2042
- accept: bigint;
2755
+ export type ChangeOutputAndFees = {
2756
+ changeOutput: TxOutput;
2757
+ fundFee: bigint;
2758
+ cetFee: bigint;
2043
2759
  };
2044
2760
 
2045
2761
  /**
2046
- * Generated factory for {@link Payout} record objects.
2762
+ * Generated factory for {@link ChangeOutputAndFees} record objects.
2047
2763
  */
2048
- export const Payout = (() => {
2764
+ export const ChangeOutputAndFees = (() => {
2049
2765
  const defaults = () => ({});
2050
2766
  const create = (() => {
2051
- return uniffiCreateRecord<Payout, ReturnType<typeof defaults>>(defaults);
2767
+ return uniffiCreateRecord<ChangeOutputAndFees, ReturnType<typeof defaults>>(
2768
+ defaults
2769
+ );
2052
2770
  })();
2053
2771
  return Object.freeze({
2054
2772
  create,
2055
2773
  new: create,
2056
- defaults: () => Object.freeze(defaults()) as Partial<Payout>,
2774
+ defaults: () => Object.freeze(defaults()) as Partial<ChangeOutputAndFees>,
2057
2775
  });
2058
2776
  })();
2059
2777
 
2060
- const FfiConverterTypePayout = (() => {
2061
- type TypeName = Payout;
2778
+ const FfiConverterTypeChangeOutputAndFees = (() => {
2779
+ type TypeName = ChangeOutputAndFees;
2062
2780
  class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
2063
2781
  read(from: RustBuffer): TypeName {
2064
2782
  return {
2065
- offer: FfiConverterUInt64.read(from),
2066
- accept: FfiConverterUInt64.read(from),
2783
+ changeOutput: FfiConverterTypeTxOutput.read(from),
2784
+ fundFee: FfiConverterUInt64.read(from),
2785
+ cetFee: FfiConverterUInt64.read(from),
2067
2786
  };
2068
2787
  }
2069
2788
  write(value: TypeName, into: RustBuffer): void {
2070
- FfiConverterUInt64.write(value.offer, into);
2071
- FfiConverterUInt64.write(value.accept, into);
2789
+ FfiConverterTypeTxOutput.write(value.changeOutput, into);
2790
+ FfiConverterUInt64.write(value.fundFee, into);
2791
+ FfiConverterUInt64.write(value.cetFee, into);
2072
2792
  }
2073
2793
  allocationSize(value: TypeName): number {
2074
2794
  return (
2075
- FfiConverterUInt64.allocationSize(value.offer) +
2076
- FfiConverterUInt64.allocationSize(value.accept)
2077
- );
2795
+ FfiConverterTypeTxOutput.allocationSize(value.changeOutput) +
2796
+ FfiConverterUInt64.allocationSize(value.fundFee) +
2797
+ FfiConverterUInt64.allocationSize(value.cetFee)
2798
+ );
2799
+ }
2800
+ }
2801
+ return new FFIConverter();
2802
+ })();
2803
+
2804
+ /**
2805
+ * One row of a contract's payout table.
2806
+ *
2807
+ * Enum-contract rows carry an `outcome` label; numeric-contract rows carry an
2808
+ * inclusive `[range_start, range_end]` of outcome values that share the payout.
2809
+ */
2810
+ export type PayoutRow = {
2811
+ /**
2812
+ * The outcome label (enum contracts only; `None` for numeric).
2813
+ */
2814
+ outcome?: string;
2815
+ /**
2816
+ * Inclusive start of the outcome range (numeric contracts only; `None` for enum).
2817
+ */
2818
+ rangeStart?: bigint;
2819
+ /**
2820
+ * Inclusive end of the outcome range (numeric contracts only; `None` for enum).
2821
+ */
2822
+ rangeEnd?: bigint;
2823
+ /**
2824
+ * The payout to the offering party, in satoshis.
2825
+ */
2826
+ offerPayoutSats: bigint;
2827
+ /**
2828
+ * The payout to the accepting party, in satoshis.
2829
+ */
2830
+ acceptPayoutSats: bigint;
2831
+ };
2832
+
2833
+ /**
2834
+ * Generated factory for {@link PayoutRow} record objects.
2835
+ */
2836
+ export const PayoutRow = (() => {
2837
+ const defaults = () => ({});
2838
+ const create = (() => {
2839
+ return uniffiCreateRecord<PayoutRow, ReturnType<typeof defaults>>(defaults);
2840
+ })();
2841
+ return Object.freeze({
2842
+ create,
2843
+ new: create,
2844
+ defaults: () => Object.freeze(defaults()) as Partial<PayoutRow>,
2845
+ });
2846
+ })();
2847
+
2848
+ const FfiConverterTypePayoutRow = (() => {
2849
+ type TypeName = PayoutRow;
2850
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
2851
+ read(from: RustBuffer): TypeName {
2852
+ return {
2853
+ outcome: FfiConverterOptionalString.read(from),
2854
+ rangeStart: FfiConverterOptionalUInt64.read(from),
2855
+ rangeEnd: FfiConverterOptionalUInt64.read(from),
2856
+ offerPayoutSats: FfiConverterUInt64.read(from),
2857
+ acceptPayoutSats: FfiConverterUInt64.read(from),
2858
+ };
2859
+ }
2860
+ write(value: TypeName, into: RustBuffer): void {
2861
+ FfiConverterOptionalString.write(value.outcome, into);
2862
+ FfiConverterOptionalUInt64.write(value.rangeStart, into);
2863
+ FfiConverterOptionalUInt64.write(value.rangeEnd, into);
2864
+ FfiConverterUInt64.write(value.offerPayoutSats, into);
2865
+ FfiConverterUInt64.write(value.acceptPayoutSats, into);
2866
+ }
2867
+ allocationSize(value: TypeName): number {
2868
+ return (
2869
+ FfiConverterOptionalString.allocationSize(value.outcome) +
2870
+ FfiConverterOptionalUInt64.allocationSize(value.rangeStart) +
2871
+ FfiConverterOptionalUInt64.allocationSize(value.rangeEnd) +
2872
+ FfiConverterUInt64.allocationSize(value.offerPayoutSats) +
2873
+ FfiConverterUInt64.allocationSize(value.acceptPayoutSats)
2874
+ );
2875
+ }
2876
+ }
2877
+ return new FFIConverter();
2878
+ })();
2879
+
2880
+ /**
2881
+ * A contract's payouts, derived from its `ContractInfo`, for display as a table.
2882
+ */
2883
+ export type ContractPayouts = {
2884
+ /**
2885
+ * Total collateral (offer + accept), in satoshis.
2886
+ */
2887
+ totalCollateralSats: bigint;
2888
+ /**
2889
+ * `true` for enum contracts (rows are labeled outcomes); `false` for numeric
2890
+ * contracts (rows are outcome ranges).
2891
+ */
2892
+ isEnum: boolean;
2893
+ /**
2894
+ * The payout rows, in outcome order.
2895
+ */
2896
+ rows: Array<PayoutRow>;
2897
+ };
2898
+
2899
+ /**
2900
+ * Generated factory for {@link ContractPayouts} record objects.
2901
+ */
2902
+ export const ContractPayouts = (() => {
2903
+ const defaults = () => ({});
2904
+ const create = (() => {
2905
+ return uniffiCreateRecord<ContractPayouts, ReturnType<typeof defaults>>(
2906
+ defaults
2907
+ );
2908
+ })();
2909
+ return Object.freeze({
2910
+ create,
2911
+ new: create,
2912
+ defaults: () => Object.freeze(defaults()) as Partial<ContractPayouts>,
2913
+ });
2914
+ })();
2915
+
2916
+ const FfiConverterTypeContractPayouts = (() => {
2917
+ type TypeName = ContractPayouts;
2918
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
2919
+ read(from: RustBuffer): TypeName {
2920
+ return {
2921
+ totalCollateralSats: FfiConverterUInt64.read(from),
2922
+ isEnum: FfiConverterBool.read(from),
2923
+ rows: FfiConverterSequenceTypePayoutRow.read(from),
2924
+ };
2925
+ }
2926
+ write(value: TypeName, into: RustBuffer): void {
2927
+ FfiConverterUInt64.write(value.totalCollateralSats, into);
2928
+ FfiConverterBool.write(value.isEnum, into);
2929
+ FfiConverterSequenceTypePayoutRow.write(value.rows, into);
2930
+ }
2931
+ allocationSize(value: TypeName): number {
2932
+ return (
2933
+ FfiConverterUInt64.allocationSize(value.totalCollateralSats) +
2934
+ FfiConverterBool.allocationSize(value.isEnum) +
2935
+ FfiConverterSequenceTypePayoutRow.allocationSize(value.rows)
2936
+ );
2937
+ }
2938
+ }
2939
+ return new FFIConverter();
2940
+ })();
2941
+
2942
+ /**
2943
+ * Parameters for [`create_offer`] (mirrors [`ddk::contract::CreateOfferParams`]).
2944
+ */
2945
+ export type CreateOfferParams = {
2946
+ /**
2947
+ * The 32-byte chain hash the contract settles on.
2948
+ */
2949
+ chainHash: ArrayBuffer;
2950
+ /**
2951
+ * The 32-byte temporary contract id; randomly generated when `None`.
2952
+ */
2953
+ temporaryContractId?: ArrayBuffer;
2954
+ /**
2955
+ * The contract payout and oracle information, wire-encoded `ContractInfo`.
2956
+ */
2957
+ contractInfo: ArrayBuffer;
2958
+ /**
2959
+ * The collateral, in satoshis, contributed by the offering party.
2960
+ */
2961
+ offerCollateralSats: bigint;
2962
+ /**
2963
+ * The offering party's Bitcoin-level contract data.
2964
+ */
2965
+ party: ContractPartyParams;
2966
+ /**
2967
+ * Serial id ordering the funding output; randomly generated when `None`.
2968
+ */
2969
+ fundOutputSerialId?: bigint;
2970
+ /**
2971
+ * The fee rate, in satoshis per virtual byte.
2972
+ */
2973
+ feeRatePerVb: bigint;
2974
+ /**
2975
+ * The earliest time CETs can be broadcast.
2976
+ */
2977
+ cetLocktime: number;
2978
+ /**
2979
+ * The time after which the refund transaction can be broadcast.
2980
+ */
2981
+ refundLocktime: number;
2982
+ /**
2983
+ * Contract feature flags. Use `0` unless a protocol extension requires otherwise.
2984
+ */
2985
+ contractFlags: number;
2986
+ };
2987
+
2988
+ /**
2989
+ * Generated factory for {@link CreateOfferParams} record objects.
2990
+ */
2991
+ export const CreateOfferParams = (() => {
2992
+ const defaults = () => ({});
2993
+ const create = (() => {
2994
+ return uniffiCreateRecord<CreateOfferParams, ReturnType<typeof defaults>>(
2995
+ defaults
2996
+ );
2997
+ })();
2998
+ return Object.freeze({
2999
+ create,
3000
+ new: create,
3001
+ defaults: () => Object.freeze(defaults()) as Partial<CreateOfferParams>,
3002
+ });
3003
+ })();
3004
+
3005
+ const FfiConverterTypeCreateOfferParams = (() => {
3006
+ type TypeName = CreateOfferParams;
3007
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
3008
+ read(from: RustBuffer): TypeName {
3009
+ return {
3010
+ chainHash: FfiConverterArrayBuffer.read(from),
3011
+ temporaryContractId: FfiConverterOptionalBytes.read(from),
3012
+ contractInfo: FfiConverterArrayBuffer.read(from),
3013
+ offerCollateralSats: FfiConverterUInt64.read(from),
3014
+ party: FfiConverterTypeContractPartyParams.read(from),
3015
+ fundOutputSerialId: FfiConverterOptionalUInt64.read(from),
3016
+ feeRatePerVb: FfiConverterUInt64.read(from),
3017
+ cetLocktime: FfiConverterUInt32.read(from),
3018
+ refundLocktime: FfiConverterUInt32.read(from),
3019
+ contractFlags: FfiConverterUInt8.read(from),
3020
+ };
3021
+ }
3022
+ write(value: TypeName, into: RustBuffer): void {
3023
+ FfiConverterArrayBuffer.write(value.chainHash, into);
3024
+ FfiConverterOptionalBytes.write(value.temporaryContractId, into);
3025
+ FfiConverterArrayBuffer.write(value.contractInfo, into);
3026
+ FfiConverterUInt64.write(value.offerCollateralSats, into);
3027
+ FfiConverterTypeContractPartyParams.write(value.party, into);
3028
+ FfiConverterOptionalUInt64.write(value.fundOutputSerialId, into);
3029
+ FfiConverterUInt64.write(value.feeRatePerVb, into);
3030
+ FfiConverterUInt32.write(value.cetLocktime, into);
3031
+ FfiConverterUInt32.write(value.refundLocktime, into);
3032
+ FfiConverterUInt8.write(value.contractFlags, into);
3033
+ }
3034
+ allocationSize(value: TypeName): number {
3035
+ return (
3036
+ FfiConverterArrayBuffer.allocationSize(value.chainHash) +
3037
+ FfiConverterOptionalBytes.allocationSize(value.temporaryContractId) +
3038
+ FfiConverterArrayBuffer.allocationSize(value.contractInfo) +
3039
+ FfiConverterUInt64.allocationSize(value.offerCollateralSats) +
3040
+ FfiConverterTypeContractPartyParams.allocationSize(value.party) +
3041
+ FfiConverterOptionalUInt64.allocationSize(value.fundOutputSerialId) +
3042
+ FfiConverterUInt64.allocationSize(value.feeRatePerVb) +
3043
+ FfiConverterUInt32.allocationSize(value.cetLocktime) +
3044
+ FfiConverterUInt32.allocationSize(value.refundLocktime) +
3045
+ FfiConverterUInt8.allocationSize(value.contractFlags)
3046
+ );
3047
+ }
3048
+ }
3049
+ return new FFIConverter();
3050
+ })();
3051
+
3052
+ /**
3053
+ * Identifies a funding input and the descriptor wildcard index that derives its
3054
+ * key, for [`sign_funding_psbt_with_descriptor`].
3055
+ */
3056
+ export type DescriptorInput = {
3057
+ /**
3058
+ * The serial id of the funding input to sign.
3059
+ */
3060
+ inputSerialId: bigint;
3061
+ /**
3062
+ * The descriptor wildcard derivation index of the input's script (ignored
3063
+ * for descriptors without a wildcard).
3064
+ */
3065
+ derivationIndex: number;
3066
+ };
3067
+
3068
+ /**
3069
+ * Generated factory for {@link DescriptorInput} record objects.
3070
+ */
3071
+ export const DescriptorInput = (() => {
3072
+ const defaults = () => ({});
3073
+ const create = (() => {
3074
+ return uniffiCreateRecord<DescriptorInput, ReturnType<typeof defaults>>(
3075
+ defaults
3076
+ );
3077
+ })();
3078
+ return Object.freeze({
3079
+ create,
3080
+ new: create,
3081
+ defaults: () => Object.freeze(defaults()) as Partial<DescriptorInput>,
3082
+ });
3083
+ })();
3084
+
3085
+ const FfiConverterTypeDescriptorInput = (() => {
3086
+ type TypeName = DescriptorInput;
3087
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
3088
+ read(from: RustBuffer): TypeName {
3089
+ return {
3090
+ inputSerialId: FfiConverterUInt64.read(from),
3091
+ derivationIndex: FfiConverterUInt32.read(from),
3092
+ };
3093
+ }
3094
+ write(value: TypeName, into: RustBuffer): void {
3095
+ FfiConverterUInt64.write(value.inputSerialId, into);
3096
+ FfiConverterUInt32.write(value.derivationIndex, into);
3097
+ }
3098
+ allocationSize(value: TypeName): number {
3099
+ return (
3100
+ FfiConverterUInt64.allocationSize(value.inputSerialId) +
3101
+ FfiConverterUInt32.allocationSize(value.derivationIndex)
3102
+ );
3103
+ }
3104
+ }
3105
+ return new FFIConverter();
3106
+ })();
3107
+
3108
+ export type DlcInputInfo = {
3109
+ fundTx: Transaction;
3110
+ fundVout: number;
3111
+ localFundPubkey: ArrayBuffer;
3112
+ remoteFundPubkey: ArrayBuffer;
3113
+ fundAmount: bigint;
3114
+ maxWitnessLen: number;
3115
+ inputSerialId: bigint;
3116
+ contractId: ArrayBuffer;
3117
+ };
3118
+
3119
+ /**
3120
+ * Generated factory for {@link DlcInputInfo} record objects.
3121
+ */
3122
+ export const DlcInputInfo = (() => {
3123
+ const defaults = () => ({});
3124
+ const create = (() => {
3125
+ return uniffiCreateRecord<DlcInputInfo, ReturnType<typeof defaults>>(
3126
+ defaults
3127
+ );
3128
+ })();
3129
+ return Object.freeze({
3130
+ create,
3131
+ new: create,
3132
+ defaults: () => Object.freeze(defaults()) as Partial<DlcInputInfo>,
3133
+ });
3134
+ })();
3135
+
3136
+ const FfiConverterTypeDlcInputInfo = (() => {
3137
+ type TypeName = DlcInputInfo;
3138
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
3139
+ read(from: RustBuffer): TypeName {
3140
+ return {
3141
+ fundTx: FfiConverterTypeTransaction.read(from),
3142
+ fundVout: FfiConverterUInt32.read(from),
3143
+ localFundPubkey: FfiConverterArrayBuffer.read(from),
3144
+ remoteFundPubkey: FfiConverterArrayBuffer.read(from),
3145
+ fundAmount: FfiConverterUInt64.read(from),
3146
+ maxWitnessLen: FfiConverterUInt32.read(from),
3147
+ inputSerialId: FfiConverterUInt64.read(from),
3148
+ contractId: FfiConverterArrayBuffer.read(from),
3149
+ };
3150
+ }
3151
+ write(value: TypeName, into: RustBuffer): void {
3152
+ FfiConverterTypeTransaction.write(value.fundTx, into);
3153
+ FfiConverterUInt32.write(value.fundVout, into);
3154
+ FfiConverterArrayBuffer.write(value.localFundPubkey, into);
3155
+ FfiConverterArrayBuffer.write(value.remoteFundPubkey, into);
3156
+ FfiConverterUInt64.write(value.fundAmount, into);
3157
+ FfiConverterUInt32.write(value.maxWitnessLen, into);
3158
+ FfiConverterUInt64.write(value.inputSerialId, into);
3159
+ FfiConverterArrayBuffer.write(value.contractId, into);
3160
+ }
3161
+ allocationSize(value: TypeName): number {
3162
+ return (
3163
+ FfiConverterTypeTransaction.allocationSize(value.fundTx) +
3164
+ FfiConverterUInt32.allocationSize(value.fundVout) +
3165
+ FfiConverterArrayBuffer.allocationSize(value.localFundPubkey) +
3166
+ FfiConverterArrayBuffer.allocationSize(value.remoteFundPubkey) +
3167
+ FfiConverterUInt64.allocationSize(value.fundAmount) +
3168
+ FfiConverterUInt32.allocationSize(value.maxWitnessLen) +
3169
+ FfiConverterUInt64.allocationSize(value.inputSerialId) +
3170
+ FfiConverterArrayBuffer.allocationSize(value.contractId)
3171
+ );
3172
+ }
3173
+ }
3174
+ return new FFIConverter();
3175
+ })();
3176
+
3177
+ /**
3178
+ * An oracle attestation paired with the position of the oracle that produced it
3179
+ * in the contract's announcements, for [`sign_contract_cet`].
3180
+ */
3181
+ export type OracleAttestationRef = {
3182
+ /**
3183
+ * The index of the attesting oracle in the contract info's announcements.
3184
+ */
3185
+ oracleIndex: number;
3186
+ /**
3187
+ * The wire-encoded `OracleAttestation`.
3188
+ */
3189
+ attestation: ArrayBuffer;
3190
+ };
3191
+
3192
+ /**
3193
+ * Generated factory for {@link OracleAttestationRef} record objects.
3194
+ */
3195
+ export const OracleAttestationRef = (() => {
3196
+ const defaults = () => ({});
3197
+ const create = (() => {
3198
+ return uniffiCreateRecord<
3199
+ OracleAttestationRef,
3200
+ ReturnType<typeof defaults>
3201
+ >(defaults);
3202
+ })();
3203
+ return Object.freeze({
3204
+ create,
3205
+ new: create,
3206
+ defaults: () => Object.freeze(defaults()) as Partial<OracleAttestationRef>,
3207
+ });
3208
+ })();
3209
+
3210
+ const FfiConverterTypeOracleAttestationRef = (() => {
3211
+ type TypeName = OracleAttestationRef;
3212
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
3213
+ read(from: RustBuffer): TypeName {
3214
+ return {
3215
+ oracleIndex: FfiConverterUInt32.read(from),
3216
+ attestation: FfiConverterArrayBuffer.read(from),
3217
+ };
3218
+ }
3219
+ write(value: TypeName, into: RustBuffer): void {
3220
+ FfiConverterUInt32.write(value.oracleIndex, into);
3221
+ FfiConverterArrayBuffer.write(value.attestation, into);
3222
+ }
3223
+ allocationSize(value: TypeName): number {
3224
+ return (
3225
+ FfiConverterUInt32.allocationSize(value.oracleIndex) +
3226
+ FfiConverterArrayBuffer.allocationSize(value.attestation)
3227
+ );
3228
+ }
3229
+ }
3230
+ return new FFIConverter();
3231
+ })();
3232
+
3233
+ export type OracleInfo = {
3234
+ publicKey: ArrayBuffer;
3235
+ nonces: Array<ArrayBuffer>;
3236
+ };
3237
+
3238
+ /**
3239
+ * Generated factory for {@link OracleInfo} record objects.
3240
+ */
3241
+ export const OracleInfo = (() => {
3242
+ const defaults = () => ({});
3243
+ const create = (() => {
3244
+ return uniffiCreateRecord<OracleInfo, ReturnType<typeof defaults>>(
3245
+ defaults
3246
+ );
3247
+ })();
3248
+ return Object.freeze({
3249
+ create,
3250
+ new: create,
3251
+ defaults: () => Object.freeze(defaults()) as Partial<OracleInfo>,
3252
+ });
3253
+ })();
3254
+
3255
+ const FfiConverterTypeOracleInfo = (() => {
3256
+ type TypeName = OracleInfo;
3257
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
3258
+ read(from: RustBuffer): TypeName {
3259
+ return {
3260
+ publicKey: FfiConverterArrayBuffer.read(from),
3261
+ nonces: FfiConverterSequenceBytes.read(from),
3262
+ };
3263
+ }
3264
+ write(value: TypeName, into: RustBuffer): void {
3265
+ FfiConverterArrayBuffer.write(value.publicKey, into);
3266
+ FfiConverterSequenceBytes.write(value.nonces, into);
3267
+ }
3268
+ allocationSize(value: TypeName): number {
3269
+ return (
3270
+ FfiConverterArrayBuffer.allocationSize(value.publicKey) +
3271
+ FfiConverterSequenceBytes.allocationSize(value.nonces)
3272
+ );
3273
+ }
3274
+ }
3275
+ return new FFIConverter();
3276
+ })();
3277
+
3278
+ export type TxInputInfo = {
3279
+ txid: string;
3280
+ vout: number;
3281
+ scriptSig: ArrayBuffer;
3282
+ maxWitnessLength: number;
3283
+ serialId: bigint;
3284
+ };
3285
+
3286
+ /**
3287
+ * Generated factory for {@link TxInputInfo} record objects.
3288
+ */
3289
+ export const TxInputInfo = (() => {
3290
+ const defaults = () => ({});
3291
+ const create = (() => {
3292
+ return uniffiCreateRecord<TxInputInfo, ReturnType<typeof defaults>>(
3293
+ defaults
3294
+ );
3295
+ })();
3296
+ return Object.freeze({
3297
+ create,
3298
+ new: create,
3299
+ defaults: () => Object.freeze(defaults()) as Partial<TxInputInfo>,
3300
+ });
3301
+ })();
3302
+
3303
+ const FfiConverterTypeTxInputInfo = (() => {
3304
+ type TypeName = TxInputInfo;
3305
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
3306
+ read(from: RustBuffer): TypeName {
3307
+ return {
3308
+ txid: FfiConverterString.read(from),
3309
+ vout: FfiConverterUInt32.read(from),
3310
+ scriptSig: FfiConverterArrayBuffer.read(from),
3311
+ maxWitnessLength: FfiConverterUInt32.read(from),
3312
+ serialId: FfiConverterUInt64.read(from),
3313
+ };
3314
+ }
3315
+ write(value: TypeName, into: RustBuffer): void {
3316
+ FfiConverterString.write(value.txid, into);
3317
+ FfiConverterUInt32.write(value.vout, into);
3318
+ FfiConverterArrayBuffer.write(value.scriptSig, into);
3319
+ FfiConverterUInt32.write(value.maxWitnessLength, into);
3320
+ FfiConverterUInt64.write(value.serialId, into);
3321
+ }
3322
+ allocationSize(value: TypeName): number {
3323
+ return (
3324
+ FfiConverterString.allocationSize(value.txid) +
3325
+ FfiConverterUInt32.allocationSize(value.vout) +
3326
+ FfiConverterArrayBuffer.allocationSize(value.scriptSig) +
3327
+ FfiConverterUInt32.allocationSize(value.maxWitnessLength) +
3328
+ FfiConverterUInt64.allocationSize(value.serialId)
3329
+ );
3330
+ }
3331
+ }
3332
+ return new FFIConverter();
3333
+ })();
3334
+
3335
+ export type PartyParams = {
3336
+ fundPubkey: ArrayBuffer;
3337
+ changeScriptPubkey: ArrayBuffer;
3338
+ changeSerialId: bigint;
3339
+ payoutScriptPubkey: ArrayBuffer;
3340
+ payoutSerialId: bigint;
3341
+ inputs: Array<TxInputInfo>;
3342
+ inputAmount: bigint;
3343
+ collateral: bigint;
3344
+ dlcInputs: Array<DlcInputInfo>;
3345
+ };
3346
+
3347
+ /**
3348
+ * Generated factory for {@link PartyParams} record objects.
3349
+ */
3350
+ export const PartyParams = (() => {
3351
+ const defaults = () => ({});
3352
+ const create = (() => {
3353
+ return uniffiCreateRecord<PartyParams, ReturnType<typeof defaults>>(
3354
+ defaults
3355
+ );
3356
+ })();
3357
+ return Object.freeze({
3358
+ create,
3359
+ new: create,
3360
+ defaults: () => Object.freeze(defaults()) as Partial<PartyParams>,
3361
+ changeOutputAndFees(
3362
+ self_: PartyParams,
3363
+ feeRate: bigint
3364
+ ): ChangeOutputAndFees {
3365
+ return ((__rb: Uint8Array) => {
3366
+ try {
3367
+ return FfiConverterTypeChangeOutputAndFees.lift(__rb);
3368
+ } finally {
3369
+ nativeModule().rustbuffer_free(__rb);
3370
+ }
3371
+ })(
3372
+ uniffiCaller.rustCallWithError(
3373
+ /*liftError:*/ FfiConverterTypeDLCError.lift.bind(
3374
+ FfiConverterTypeDLCError
3375
+ ),
3376
+ /*caller:*/ (callStatus) => {
3377
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_method_partyparams_change_output_and_fees(
3378
+ FfiConverterTypePartyParams.lower(
3379
+ self_,
3380
+ nativeModule().rustbuffer_alloc
3381
+ ),
3382
+ FfiConverterUInt64.lower(
3383
+ feeRate,
3384
+ nativeModule().rustbuffer_alloc
3385
+ ),
3386
+ callStatus
3387
+ );
3388
+ },
3389
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
3390
+ )
3391
+ );
3392
+ },
3393
+ });
3394
+ })();
3395
+
3396
+ const FfiConverterTypePartyParams = (() => {
3397
+ type TypeName = PartyParams;
3398
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
3399
+ read(from: RustBuffer): TypeName {
3400
+ return {
3401
+ fundPubkey: FfiConverterArrayBuffer.read(from),
3402
+ changeScriptPubkey: FfiConverterArrayBuffer.read(from),
3403
+ changeSerialId: FfiConverterUInt64.read(from),
3404
+ payoutScriptPubkey: FfiConverterArrayBuffer.read(from),
3405
+ payoutSerialId: FfiConverterUInt64.read(from),
3406
+ inputs: FfiConverterSequenceTypeTxInputInfo.read(from),
3407
+ inputAmount: FfiConverterUInt64.read(from),
3408
+ collateral: FfiConverterUInt64.read(from),
3409
+ dlcInputs: FfiConverterSequenceTypeDlcInputInfo.read(from),
3410
+ };
3411
+ }
3412
+ write(value: TypeName, into: RustBuffer): void {
3413
+ FfiConverterArrayBuffer.write(value.fundPubkey, into);
3414
+ FfiConverterArrayBuffer.write(value.changeScriptPubkey, into);
3415
+ FfiConverterUInt64.write(value.changeSerialId, into);
3416
+ FfiConverterArrayBuffer.write(value.payoutScriptPubkey, into);
3417
+ FfiConverterUInt64.write(value.payoutSerialId, into);
3418
+ FfiConverterSequenceTypeTxInputInfo.write(value.inputs, into);
3419
+ FfiConverterUInt64.write(value.inputAmount, into);
3420
+ FfiConverterUInt64.write(value.collateral, into);
3421
+ FfiConverterSequenceTypeDlcInputInfo.write(value.dlcInputs, into);
3422
+ }
3423
+ allocationSize(value: TypeName): number {
3424
+ return (
3425
+ FfiConverterArrayBuffer.allocationSize(value.fundPubkey) +
3426
+ FfiConverterArrayBuffer.allocationSize(value.changeScriptPubkey) +
3427
+ FfiConverterUInt64.allocationSize(value.changeSerialId) +
3428
+ FfiConverterArrayBuffer.allocationSize(value.payoutScriptPubkey) +
3429
+ FfiConverterUInt64.allocationSize(value.payoutSerialId) +
3430
+ FfiConverterSequenceTypeTxInputInfo.allocationSize(value.inputs) +
3431
+ FfiConverterUInt64.allocationSize(value.inputAmount) +
3432
+ FfiConverterUInt64.allocationSize(value.collateral) +
3433
+ FfiConverterSequenceTypeDlcInputInfo.allocationSize(value.dlcInputs)
3434
+ );
3435
+ }
3436
+ }
3437
+ return new FFIConverter();
3438
+ })();
3439
+
3440
+ export type Payout = {
3441
+ offer: bigint;
3442
+ accept: bigint;
3443
+ };
3444
+
3445
+ /**
3446
+ * Generated factory for {@link Payout} record objects.
3447
+ */
3448
+ export const Payout = (() => {
3449
+ const defaults = () => ({});
3450
+ const create = (() => {
3451
+ return uniffiCreateRecord<Payout, ReturnType<typeof defaults>>(defaults);
3452
+ })();
3453
+ return Object.freeze({
3454
+ create,
3455
+ new: create,
3456
+ defaults: () => Object.freeze(defaults()) as Partial<Payout>,
3457
+ });
3458
+ })();
3459
+
3460
+ const FfiConverterTypePayout = (() => {
3461
+ type TypeName = Payout;
3462
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
3463
+ read(from: RustBuffer): TypeName {
3464
+ return {
3465
+ offer: FfiConverterUInt64.read(from),
3466
+ accept: FfiConverterUInt64.read(from),
3467
+ };
3468
+ }
3469
+ write(value: TypeName, into: RustBuffer): void {
3470
+ FfiConverterUInt64.write(value.offer, into);
3471
+ FfiConverterUInt64.write(value.accept, into);
3472
+ }
3473
+ allocationSize(value: TypeName): number {
3474
+ return (
3475
+ FfiConverterUInt64.allocationSize(value.offer) +
3476
+ FfiConverterUInt64.allocationSize(value.accept)
3477
+ );
3478
+ }
3479
+ }
3480
+ return new FFIConverter();
3481
+ })();
3482
+
3483
+ /**
3484
+ * The result of [`sign_accept`] / [`sign_accept_spliced`].
3485
+ */
3486
+ export type SignResult = {
3487
+ /**
3488
+ * The wire-encoded `SignDlc` message to send to the accepting party.
3489
+ */
3490
+ sign: ArrayBuffer;
3491
+ /**
3492
+ * The unsigned funding, CET, and refund transactions.
3493
+ */
3494
+ transactions: DlcTransactions;
3495
+ };
3496
+
3497
+ /**
3498
+ * Generated factory for {@link SignResult} record objects.
3499
+ */
3500
+ export const SignResult = (() => {
3501
+ const defaults = () => ({});
3502
+ const create = (() => {
3503
+ return uniffiCreateRecord<SignResult, ReturnType<typeof defaults>>(
3504
+ defaults
3505
+ );
3506
+ })();
3507
+ return Object.freeze({
3508
+ create,
3509
+ new: create,
3510
+ defaults: () => Object.freeze(defaults()) as Partial<SignResult>,
3511
+ });
3512
+ })();
3513
+
3514
+ const FfiConverterTypeSignResult = (() => {
3515
+ type TypeName = SignResult;
3516
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
3517
+ read(from: RustBuffer): TypeName {
3518
+ return {
3519
+ sign: FfiConverterArrayBuffer.read(from),
3520
+ transactions: FfiConverterTypeDlcTransactions.read(from),
3521
+ };
3522
+ }
3523
+ write(value: TypeName, into: RustBuffer): void {
3524
+ FfiConverterArrayBuffer.write(value.sign, into);
3525
+ FfiConverterTypeDlcTransactions.write(value.transactions, into);
3526
+ }
3527
+ allocationSize(value: TypeName): number {
3528
+ return (
3529
+ FfiConverterArrayBuffer.allocationSize(value.sign) +
3530
+ FfiConverterTypeDlcTransactions.allocationSize(value.transactions)
3531
+ );
3532
+ }
3533
+ }
3534
+ return new FFIConverter();
3535
+ })();
3536
+
3537
+ /**
3538
+ * References a splice (DLC) funding input and the previous contract whose
3539
+ * 2-of-2 output it spends, so the provider can re-derive the signing key.
3540
+ */
3541
+ export type SpliceKeyRef = {
3542
+ /**
3543
+ * The serial id of the DLC (splice) funding input this key signs.
3544
+ */
3545
+ inputSerialId: bigint;
3546
+ /**
3547
+ * The 32-byte temporary id of the previous contract being spliced from.
3548
+ */
3549
+ priorTemporaryContractId: ArrayBuffer;
3550
+ };
3551
+
3552
+ /**
3553
+ * Generated factory for {@link SpliceKeyRef} record objects.
3554
+ */
3555
+ export const SpliceKeyRef = (() => {
3556
+ const defaults = () => ({});
3557
+ const create = (() => {
3558
+ return uniffiCreateRecord<SpliceKeyRef, ReturnType<typeof defaults>>(
3559
+ defaults
3560
+ );
3561
+ })();
3562
+ return Object.freeze({
3563
+ create,
3564
+ new: create,
3565
+ defaults: () => Object.freeze(defaults()) as Partial<SpliceKeyRef>,
3566
+ });
3567
+ })();
3568
+
3569
+ const FfiConverterTypeSpliceKeyRef = (() => {
3570
+ type TypeName = SpliceKeyRef;
3571
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
3572
+ read(from: RustBuffer): TypeName {
3573
+ return {
3574
+ inputSerialId: FfiConverterUInt64.read(from),
3575
+ priorTemporaryContractId: FfiConverterArrayBuffer.read(from),
3576
+ };
3577
+ }
3578
+ write(value: TypeName, into: RustBuffer): void {
3579
+ FfiConverterUInt64.write(value.inputSerialId, into);
3580
+ FfiConverterArrayBuffer.write(value.priorTemporaryContractId, into);
3581
+ }
3582
+ allocationSize(value: TypeName): number {
3583
+ return (
3584
+ FfiConverterUInt64.allocationSize(value.inputSerialId) +
3585
+ FfiConverterArrayBuffer.allocationSize(value.priorTemporaryContractId)
3586
+ );
3587
+ }
3588
+ }
3589
+ return new FFIConverter();
3590
+ })();
3591
+
3592
+ // Error type: ContractError
3593
+ export enum ContractError_Tags {
3594
+ InvalidOffer = 'InvalidOffer',
3595
+ InvalidAccept = 'InvalidAccept',
3596
+ InvalidSign = 'InvalidSign',
3597
+ InvalidFundingInput = 'InvalidFundingInput',
3598
+ PsbtMismatch = 'PsbtMismatch',
3599
+ MissingFinalizedInput = 'MissingFinalizedInput',
3600
+ UnsupportedScriptType = 'UnsupportedScriptType',
3601
+ InvalidAttestation = 'InvalidAttestation',
3602
+ NoMatchingOutcome = 'NoMatchingOutcome',
3603
+ Descriptor = 'Descriptor',
3604
+ Wallet = 'Wallet',
3605
+ Bip32 = 'Bip32',
3606
+ Dlc = 'Dlc',
3607
+ Key = 'Key',
3608
+ Serialization = 'Serialization',
3609
+ InvalidNetwork = 'InvalidNetwork',
3610
+ InvalidLength = 'InvalidLength',
3611
+ }
3612
+ /**
3613
+ * Errors returned by the stateless contract API.
3614
+ *
3615
+ * Mirrors [`ddk::contract::ContractError`] as a uniffi error so the typed
3616
+ * variants survive across the binding boundary. Variants carry plain strings.
3617
+ */
3618
+ export const ContractError = (() => {
3619
+ type InvalidOffer__interface = {
3620
+ tag: ContractError_Tags.InvalidOffer;
3621
+ inner: Readonly<{ message: string }>;
3622
+ };
3623
+ class InvalidOffer_ extends UniffiError implements InvalidOffer__interface {
3624
+ /**
3625
+ * @private
3626
+ * This field is private and should not be used, use `tag` instead.
3627
+ */
3628
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
3629
+ readonly tag = ContractError_Tags.InvalidOffer;
3630
+ readonly inner: Readonly<{ message: string }>;
3631
+ constructor(inner: { message: string }) {
3632
+ super('ContractError', 'InvalidOffer');
3633
+
3634
+ this.inner = Object.freeze(inner);
3635
+ }
3636
+ static new(inner: { message: string }): InvalidOffer_ {
3637
+ return new InvalidOffer_(inner);
3638
+ }
3639
+
3640
+ static instanceOf(obj: any): obj is InvalidOffer_ {
3641
+ return obj.tag === ContractError_Tags.InvalidOffer;
3642
+ }
3643
+ static hasInner(obj: any): obj is InvalidOffer_ {
3644
+ return InvalidOffer_.instanceOf(obj);
3645
+ }
3646
+
3647
+ static getInner(obj: InvalidOffer_): Readonly<{ message: string }> {
3648
+ return obj.inner;
3649
+ }
3650
+ }
3651
+
3652
+ type InvalidAccept__interface = {
3653
+ tag: ContractError_Tags.InvalidAccept;
3654
+ inner: Readonly<{ message: string }>;
3655
+ };
3656
+ class InvalidAccept_ extends UniffiError implements InvalidAccept__interface {
3657
+ /**
3658
+ * @private
3659
+ * This field is private and should not be used, use `tag` instead.
3660
+ */
3661
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
3662
+ readonly tag = ContractError_Tags.InvalidAccept;
3663
+ readonly inner: Readonly<{ message: string }>;
3664
+ constructor(inner: { message: string }) {
3665
+ super('ContractError', 'InvalidAccept');
3666
+
3667
+ this.inner = Object.freeze(inner);
3668
+ }
3669
+ static new(inner: { message: string }): InvalidAccept_ {
3670
+ return new InvalidAccept_(inner);
3671
+ }
3672
+
3673
+ static instanceOf(obj: any): obj is InvalidAccept_ {
3674
+ return obj.tag === ContractError_Tags.InvalidAccept;
3675
+ }
3676
+ static hasInner(obj: any): obj is InvalidAccept_ {
3677
+ return InvalidAccept_.instanceOf(obj);
3678
+ }
3679
+
3680
+ static getInner(obj: InvalidAccept_): Readonly<{ message: string }> {
3681
+ return obj.inner;
3682
+ }
3683
+ }
3684
+
3685
+ type InvalidSign__interface = {
3686
+ tag: ContractError_Tags.InvalidSign;
3687
+ inner: Readonly<{ message: string }>;
3688
+ };
3689
+ class InvalidSign_ extends UniffiError implements InvalidSign__interface {
3690
+ /**
3691
+ * @private
3692
+ * This field is private and should not be used, use `tag` instead.
3693
+ */
3694
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
3695
+ readonly tag = ContractError_Tags.InvalidSign;
3696
+ readonly inner: Readonly<{ message: string }>;
3697
+ constructor(inner: { message: string }) {
3698
+ super('ContractError', 'InvalidSign');
3699
+
3700
+ this.inner = Object.freeze(inner);
3701
+ }
3702
+ static new(inner: { message: string }): InvalidSign_ {
3703
+ return new InvalidSign_(inner);
3704
+ }
3705
+
3706
+ static instanceOf(obj: any): obj is InvalidSign_ {
3707
+ return obj.tag === ContractError_Tags.InvalidSign;
3708
+ }
3709
+ static hasInner(obj: any): obj is InvalidSign_ {
3710
+ return InvalidSign_.instanceOf(obj);
3711
+ }
3712
+
3713
+ static getInner(obj: InvalidSign_): Readonly<{ message: string }> {
3714
+ return obj.inner;
3715
+ }
3716
+ }
3717
+
3718
+ type InvalidFundingInput__interface = {
3719
+ tag: ContractError_Tags.InvalidFundingInput;
3720
+ inner: Readonly<{ message: string }>;
3721
+ };
3722
+ class InvalidFundingInput_
3723
+ extends UniffiError
3724
+ implements InvalidFundingInput__interface
3725
+ {
3726
+ /**
3727
+ * @private
3728
+ * This field is private and should not be used, use `tag` instead.
3729
+ */
3730
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
3731
+ readonly tag = ContractError_Tags.InvalidFundingInput;
3732
+ readonly inner: Readonly<{ message: string }>;
3733
+ constructor(inner: { message: string }) {
3734
+ super('ContractError', 'InvalidFundingInput');
3735
+
3736
+ this.inner = Object.freeze(inner);
3737
+ }
3738
+ static new(inner: { message: string }): InvalidFundingInput_ {
3739
+ return new InvalidFundingInput_(inner);
3740
+ }
3741
+
3742
+ static instanceOf(obj: any): obj is InvalidFundingInput_ {
3743
+ return obj.tag === ContractError_Tags.InvalidFundingInput;
3744
+ }
3745
+ static hasInner(obj: any): obj is InvalidFundingInput_ {
3746
+ return InvalidFundingInput_.instanceOf(obj);
3747
+ }
3748
+
3749
+ static getInner(obj: InvalidFundingInput_): Readonly<{ message: string }> {
3750
+ return obj.inner;
3751
+ }
3752
+ }
3753
+
3754
+ type PsbtMismatch__interface = {
3755
+ tag: ContractError_Tags.PsbtMismatch;
3756
+ inner: Readonly<{ message: string }>;
3757
+ };
3758
+ class PsbtMismatch_ extends UniffiError implements PsbtMismatch__interface {
3759
+ /**
3760
+ * @private
3761
+ * This field is private and should not be used, use `tag` instead.
3762
+ */
3763
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
3764
+ readonly tag = ContractError_Tags.PsbtMismatch;
3765
+ readonly inner: Readonly<{ message: string }>;
3766
+ constructor(inner: { message: string }) {
3767
+ super('ContractError', 'PsbtMismatch');
3768
+
3769
+ this.inner = Object.freeze(inner);
3770
+ }
3771
+ static new(inner: { message: string }): PsbtMismatch_ {
3772
+ return new PsbtMismatch_(inner);
3773
+ }
3774
+
3775
+ static instanceOf(obj: any): obj is PsbtMismatch_ {
3776
+ return obj.tag === ContractError_Tags.PsbtMismatch;
3777
+ }
3778
+ static hasInner(obj: any): obj is PsbtMismatch_ {
3779
+ return PsbtMismatch_.instanceOf(obj);
3780
+ }
3781
+
3782
+ static getInner(obj: PsbtMismatch_): Readonly<{ message: string }> {
3783
+ return obj.inner;
3784
+ }
3785
+ }
3786
+
3787
+ type MissingFinalizedInput__interface = {
3788
+ tag: ContractError_Tags.MissingFinalizedInput;
3789
+ inner: Readonly<{ inputIndex: number }>;
3790
+ };
3791
+ class MissingFinalizedInput_
3792
+ extends UniffiError
3793
+ implements MissingFinalizedInput__interface
3794
+ {
3795
+ /**
3796
+ * @private
3797
+ * This field is private and should not be used, use `tag` instead.
3798
+ */
3799
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
3800
+ readonly tag = ContractError_Tags.MissingFinalizedInput;
3801
+ readonly inner: Readonly<{ inputIndex: number }>;
3802
+ constructor(inner: { inputIndex: number }) {
3803
+ super('ContractError', 'MissingFinalizedInput');
3804
+
3805
+ this.inner = Object.freeze(inner);
3806
+ }
3807
+ static new(inner: { inputIndex: number }): MissingFinalizedInput_ {
3808
+ return new MissingFinalizedInput_(inner);
3809
+ }
3810
+
3811
+ static instanceOf(obj: any): obj is MissingFinalizedInput_ {
3812
+ return obj.tag === ContractError_Tags.MissingFinalizedInput;
3813
+ }
3814
+ static hasInner(obj: any): obj is MissingFinalizedInput_ {
3815
+ return MissingFinalizedInput_.instanceOf(obj);
3816
+ }
3817
+
3818
+ static getInner(
3819
+ obj: MissingFinalizedInput_
3820
+ ): Readonly<{ inputIndex: number }> {
3821
+ return obj.inner;
3822
+ }
3823
+ }
3824
+
3825
+ type UnsupportedScriptType__interface = {
3826
+ tag: ContractError_Tags.UnsupportedScriptType;
3827
+ inner: Readonly<{ inputIndex: number }>;
3828
+ };
3829
+ class UnsupportedScriptType_
3830
+ extends UniffiError
3831
+ implements UnsupportedScriptType__interface
3832
+ {
3833
+ /**
3834
+ * @private
3835
+ * This field is private and should not be used, use `tag` instead.
3836
+ */
3837
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
3838
+ readonly tag = ContractError_Tags.UnsupportedScriptType;
3839
+ readonly inner: Readonly<{ inputIndex: number }>;
3840
+ constructor(inner: { inputIndex: number }) {
3841
+ super('ContractError', 'UnsupportedScriptType');
3842
+
3843
+ this.inner = Object.freeze(inner);
3844
+ }
3845
+ static new(inner: { inputIndex: number }): UnsupportedScriptType_ {
3846
+ return new UnsupportedScriptType_(inner);
3847
+ }
3848
+
3849
+ static instanceOf(obj: any): obj is UnsupportedScriptType_ {
3850
+ return obj.tag === ContractError_Tags.UnsupportedScriptType;
3851
+ }
3852
+ static hasInner(obj: any): obj is UnsupportedScriptType_ {
3853
+ return UnsupportedScriptType_.instanceOf(obj);
3854
+ }
3855
+
3856
+ static getInner(
3857
+ obj: UnsupportedScriptType_
3858
+ ): Readonly<{ inputIndex: number }> {
3859
+ return obj.inner;
3860
+ }
3861
+ }
3862
+
3863
+ type InvalidAttestation__interface = {
3864
+ tag: ContractError_Tags.InvalidAttestation;
3865
+ inner: Readonly<{ message: string }>;
3866
+ };
3867
+ class InvalidAttestation_
3868
+ extends UniffiError
3869
+ implements InvalidAttestation__interface
3870
+ {
3871
+ /**
3872
+ * @private
3873
+ * This field is private and should not be used, use `tag` instead.
3874
+ */
3875
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
3876
+ readonly tag = ContractError_Tags.InvalidAttestation;
3877
+ readonly inner: Readonly<{ message: string }>;
3878
+ constructor(inner: { message: string }) {
3879
+ super('ContractError', 'InvalidAttestation');
3880
+
3881
+ this.inner = Object.freeze(inner);
3882
+ }
3883
+ static new(inner: { message: string }): InvalidAttestation_ {
3884
+ return new InvalidAttestation_(inner);
3885
+ }
3886
+
3887
+ static instanceOf(obj: any): obj is InvalidAttestation_ {
3888
+ return obj.tag === ContractError_Tags.InvalidAttestation;
3889
+ }
3890
+ static hasInner(obj: any): obj is InvalidAttestation_ {
3891
+ return InvalidAttestation_.instanceOf(obj);
3892
+ }
3893
+
3894
+ static getInner(obj: InvalidAttestation_): Readonly<{ message: string }> {
3895
+ return obj.inner;
3896
+ }
3897
+ }
3898
+
3899
+ type NoMatchingOutcome__interface = {
3900
+ tag: ContractError_Tags.NoMatchingOutcome;
3901
+ };
3902
+ class NoMatchingOutcome_
3903
+ extends UniffiError
3904
+ implements NoMatchingOutcome__interface
3905
+ {
3906
+ /**
3907
+ * @private
3908
+ * This field is private and should not be used, use `tag` instead.
3909
+ */
3910
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
3911
+ readonly tag = ContractError_Tags.NoMatchingOutcome;
3912
+ constructor() {
3913
+ super('ContractError', 'NoMatchingOutcome');
3914
+ }
3915
+
3916
+ static new(): NoMatchingOutcome_ {
3917
+ return new NoMatchingOutcome_();
3918
+ }
3919
+
3920
+ static instanceOf(obj: any): obj is NoMatchingOutcome_ {
3921
+ return obj.tag === ContractError_Tags.NoMatchingOutcome;
3922
+ }
3923
+ static hasInner(obj: any): obj is NoMatchingOutcome_ {
3924
+ return false;
3925
+ }
3926
+ }
3927
+
3928
+ type Descriptor__interface = {
3929
+ tag: ContractError_Tags.Descriptor;
3930
+ inner: Readonly<{ message: string }>;
3931
+ };
3932
+ class Descriptor_ extends UniffiError implements Descriptor__interface {
3933
+ /**
3934
+ * @private
3935
+ * This field is private and should not be used, use `tag` instead.
3936
+ */
3937
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
3938
+ readonly tag = ContractError_Tags.Descriptor;
3939
+ readonly inner: Readonly<{ message: string }>;
3940
+ constructor(inner: { message: string }) {
3941
+ super('ContractError', 'Descriptor');
3942
+
3943
+ this.inner = Object.freeze(inner);
3944
+ }
3945
+ static new(inner: { message: string }): Descriptor_ {
3946
+ return new Descriptor_(inner);
3947
+ }
3948
+
3949
+ static instanceOf(obj: any): obj is Descriptor_ {
3950
+ return obj.tag === ContractError_Tags.Descriptor;
3951
+ }
3952
+ static hasInner(obj: any): obj is Descriptor_ {
3953
+ return Descriptor_.instanceOf(obj);
3954
+ }
3955
+
3956
+ static getInner(obj: Descriptor_): Readonly<{ message: string }> {
3957
+ return obj.inner;
3958
+ }
3959
+ }
3960
+
3961
+ type Wallet__interface = {
3962
+ tag: ContractError_Tags.Wallet;
3963
+ inner: Readonly<{ message: string }>;
3964
+ };
3965
+ class Wallet_ extends UniffiError implements Wallet__interface {
3966
+ /**
3967
+ * @private
3968
+ * This field is private and should not be used, use `tag` instead.
3969
+ */
3970
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
3971
+ readonly tag = ContractError_Tags.Wallet;
3972
+ readonly inner: Readonly<{ message: string }>;
3973
+ constructor(inner: { message: string }) {
3974
+ super('ContractError', 'Wallet');
3975
+
3976
+ this.inner = Object.freeze(inner);
3977
+ }
3978
+ static new(inner: { message: string }): Wallet_ {
3979
+ return new Wallet_(inner);
3980
+ }
3981
+
3982
+ static instanceOf(obj: any): obj is Wallet_ {
3983
+ return obj.tag === ContractError_Tags.Wallet;
3984
+ }
3985
+ static hasInner(obj: any): obj is Wallet_ {
3986
+ return Wallet_.instanceOf(obj);
3987
+ }
3988
+
3989
+ static getInner(obj: Wallet_): Readonly<{ message: string }> {
3990
+ return obj.inner;
3991
+ }
3992
+ }
3993
+
3994
+ type Bip32__interface = {
3995
+ tag: ContractError_Tags.Bip32;
3996
+ inner: Readonly<{ message: string }>;
3997
+ };
3998
+ class Bip32_ extends UniffiError implements Bip32__interface {
3999
+ /**
4000
+ * @private
4001
+ * This field is private and should not be used, use `tag` instead.
4002
+ */
4003
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
4004
+ readonly tag = ContractError_Tags.Bip32;
4005
+ readonly inner: Readonly<{ message: string }>;
4006
+ constructor(inner: { message: string }) {
4007
+ super('ContractError', 'Bip32');
4008
+
4009
+ this.inner = Object.freeze(inner);
4010
+ }
4011
+ static new(inner: { message: string }): Bip32_ {
4012
+ return new Bip32_(inner);
4013
+ }
4014
+
4015
+ static instanceOf(obj: any): obj is Bip32_ {
4016
+ return obj.tag === ContractError_Tags.Bip32;
4017
+ }
4018
+ static hasInner(obj: any): obj is Bip32_ {
4019
+ return Bip32_.instanceOf(obj);
4020
+ }
4021
+
4022
+ static getInner(obj: Bip32_): Readonly<{ message: string }> {
4023
+ return obj.inner;
4024
+ }
4025
+ }
4026
+
4027
+ type Dlc__interface = {
4028
+ tag: ContractError_Tags.Dlc;
4029
+ inner: Readonly<{ message: string }>;
4030
+ };
4031
+ class Dlc_ extends UniffiError implements Dlc__interface {
4032
+ /**
4033
+ * @private
4034
+ * This field is private and should not be used, use `tag` instead.
4035
+ */
4036
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
4037
+ readonly tag = ContractError_Tags.Dlc;
4038
+ readonly inner: Readonly<{ message: string }>;
4039
+ constructor(inner: { message: string }) {
4040
+ super('ContractError', 'Dlc');
4041
+
4042
+ this.inner = Object.freeze(inner);
4043
+ }
4044
+ static new(inner: { message: string }): Dlc_ {
4045
+ return new Dlc_(inner);
4046
+ }
4047
+
4048
+ static instanceOf(obj: any): obj is Dlc_ {
4049
+ return obj.tag === ContractError_Tags.Dlc;
4050
+ }
4051
+ static hasInner(obj: any): obj is Dlc_ {
4052
+ return Dlc_.instanceOf(obj);
4053
+ }
4054
+
4055
+ static getInner(obj: Dlc_): Readonly<{ message: string }> {
4056
+ return obj.inner;
4057
+ }
4058
+ }
4059
+
4060
+ type Key__interface = {
4061
+ tag: ContractError_Tags.Key;
4062
+ inner: Readonly<{ message: string }>;
4063
+ };
4064
+ class Key_ extends UniffiError implements Key__interface {
4065
+ /**
4066
+ * @private
4067
+ * This field is private and should not be used, use `tag` instead.
4068
+ */
4069
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
4070
+ readonly tag = ContractError_Tags.Key;
4071
+ readonly inner: Readonly<{ message: string }>;
4072
+ constructor(inner: { message: string }) {
4073
+ super('ContractError', 'Key');
4074
+
4075
+ this.inner = Object.freeze(inner);
4076
+ }
4077
+ static new(inner: { message: string }): Key_ {
4078
+ return new Key_(inner);
4079
+ }
4080
+
4081
+ static instanceOf(obj: any): obj is Key_ {
4082
+ return obj.tag === ContractError_Tags.Key;
4083
+ }
4084
+ static hasInner(obj: any): obj is Key_ {
4085
+ return Key_.instanceOf(obj);
4086
+ }
4087
+
4088
+ static getInner(obj: Key_): Readonly<{ message: string }> {
4089
+ return obj.inner;
4090
+ }
4091
+ }
4092
+
4093
+ type Serialization__interface = {
4094
+ tag: ContractError_Tags.Serialization;
4095
+ inner: Readonly<{ message: string }>;
4096
+ };
4097
+ /**
4098
+ * A message or PSBT could not be (de)serialized at the FFI boundary.
4099
+ */
4100
+ class Serialization_ extends UniffiError implements Serialization__interface {
4101
+ /**
4102
+ * @private
4103
+ * This field is private and should not be used, use `tag` instead.
4104
+ */
4105
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
4106
+ readonly tag = ContractError_Tags.Serialization;
4107
+ readonly inner: Readonly<{ message: string }>;
4108
+ constructor(inner: { message: string }) {
4109
+ super('ContractError', 'Serialization');
4110
+
4111
+ this.inner = Object.freeze(inner);
4112
+ }
4113
+ static new(inner: { message: string }): Serialization_ {
4114
+ return new Serialization_(inner);
4115
+ }
4116
+
4117
+ static instanceOf(obj: any): obj is Serialization_ {
4118
+ return obj.tag === ContractError_Tags.Serialization;
4119
+ }
4120
+ static hasInner(obj: any): obj is Serialization_ {
4121
+ return Serialization_.instanceOf(obj);
4122
+ }
4123
+
4124
+ static getInner(obj: Serialization_): Readonly<{ message: string }> {
4125
+ return obj.inner;
4126
+ }
4127
+ }
4128
+
4129
+ type InvalidNetwork__interface = {
4130
+ tag: ContractError_Tags.InvalidNetwork;
4131
+ inner: Readonly<{ message: string }>;
4132
+ };
4133
+ /**
4134
+ * The network string was not one of bitcoin/testnet/signet/regtest.
4135
+ */
4136
+ class InvalidNetwork_
4137
+ extends UniffiError
4138
+ implements InvalidNetwork__interface
4139
+ {
4140
+ /**
4141
+ * @private
4142
+ * This field is private and should not be used, use `tag` instead.
4143
+ */
4144
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
4145
+ readonly tag = ContractError_Tags.InvalidNetwork;
4146
+ readonly inner: Readonly<{ message: string }>;
4147
+ constructor(inner: { message: string }) {
4148
+ super('ContractError', 'InvalidNetwork');
4149
+
4150
+ this.inner = Object.freeze(inner);
4151
+ }
4152
+ static new(inner: { message: string }): InvalidNetwork_ {
4153
+ return new InvalidNetwork_(inner);
4154
+ }
4155
+
4156
+ static instanceOf(obj: any): obj is InvalidNetwork_ {
4157
+ return obj.tag === ContractError_Tags.InvalidNetwork;
4158
+ }
4159
+ static hasInner(obj: any): obj is InvalidNetwork_ {
4160
+ return InvalidNetwork_.instanceOf(obj);
4161
+ }
4162
+
4163
+ static getInner(obj: InvalidNetwork_): Readonly<{ message: string }> {
4164
+ return obj.inner;
4165
+ }
4166
+ }
4167
+
4168
+ type InvalidLength__interface = {
4169
+ tag: ContractError_Tags.InvalidLength;
4170
+ inner: Readonly<{ field: string; expected: number; actual: number }>;
4171
+ };
4172
+ /**
4173
+ * A byte argument had the wrong length (e.g. a 32-byte id).
4174
+ */
4175
+ class InvalidLength_ extends UniffiError implements InvalidLength__interface {
4176
+ /**
4177
+ * @private
4178
+ * This field is private and should not be used, use `tag` instead.
4179
+ */
4180
+ readonly [uniffiTypeNameSymbol] = 'ContractError';
4181
+ readonly tag = ContractError_Tags.InvalidLength;
4182
+ readonly inner: Readonly<{
4183
+ field: string;
4184
+ expected: number;
4185
+ actual: number;
4186
+ }>;
4187
+ constructor(inner: { field: string; expected: number; actual: number }) {
4188
+ super('ContractError', 'InvalidLength');
4189
+
4190
+ this.inner = Object.freeze(inner);
4191
+ }
4192
+ static new(inner: {
4193
+ field: string;
4194
+ expected: number;
4195
+ actual: number;
4196
+ }): InvalidLength_ {
4197
+ return new InvalidLength_(inner);
4198
+ }
4199
+
4200
+ static instanceOf(obj: any): obj is InvalidLength_ {
4201
+ return obj.tag === ContractError_Tags.InvalidLength;
4202
+ }
4203
+ static hasInner(obj: any): obj is InvalidLength_ {
4204
+ return InvalidLength_.instanceOf(obj);
4205
+ }
4206
+
4207
+ static getInner(
4208
+ obj: InvalidLength_
4209
+ ): Readonly<{ field: string; expected: number; actual: number }> {
4210
+ return obj.inner;
4211
+ }
4212
+ }
4213
+
4214
+ function instanceOf(obj: any): obj is ContractError {
4215
+ return obj[uniffiTypeNameSymbol] === 'ContractError';
4216
+ }
4217
+
4218
+ return Object.freeze({
4219
+ instanceOf,
4220
+ InvalidOffer: InvalidOffer_,
4221
+ InvalidAccept: InvalidAccept_,
4222
+ InvalidSign: InvalidSign_,
4223
+ InvalidFundingInput: InvalidFundingInput_,
4224
+ PsbtMismatch: PsbtMismatch_,
4225
+ MissingFinalizedInput: MissingFinalizedInput_,
4226
+ UnsupportedScriptType: UnsupportedScriptType_,
4227
+ InvalidAttestation: InvalidAttestation_,
4228
+ NoMatchingOutcome: NoMatchingOutcome_,
4229
+ Descriptor: Descriptor_,
4230
+ Wallet: Wallet_,
4231
+ Bip32: Bip32_,
4232
+ Dlc: Dlc_,
4233
+ Key: Key_,
4234
+ Serialization: Serialization_,
4235
+ InvalidNetwork: InvalidNetwork_,
4236
+ InvalidLength: InvalidLength_,
4237
+ });
4238
+ })();
4239
+ /**
4240
+ * Errors returned by the stateless contract API.
4241
+ *
4242
+ * Mirrors [`ddk::contract::ContractError`] as a uniffi error so the typed
4243
+ * variants survive across the binding boundary. Variants carry plain strings.
4244
+ */
4245
+ export type ContractError = InstanceType<
4246
+ (typeof ContractError)[
4247
+ | 'InvalidOffer'
4248
+ | 'InvalidAccept'
4249
+ | 'InvalidSign'
4250
+ | 'InvalidFundingInput'
4251
+ | 'PsbtMismatch'
4252
+ | 'MissingFinalizedInput'
4253
+ | 'UnsupportedScriptType'
4254
+ | 'InvalidAttestation'
4255
+ | 'NoMatchingOutcome'
4256
+ | 'Descriptor'
4257
+ | 'Wallet'
4258
+ | 'Bip32'
4259
+ | 'Dlc'
4260
+ | 'Key'
4261
+ | 'Serialization'
4262
+ | 'InvalidNetwork'
4263
+ | 'InvalidLength']
4264
+ >;
4265
+
4266
+ // FfiConverter for enum ContractError
4267
+ const FfiConverterTypeContractError = (() => {
4268
+ const ordinalConverter = FfiConverterInt32;
4269
+ type TypeName = ContractError;
4270
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
4271
+ read(from: RustBuffer): TypeName {
4272
+ switch (ordinalConverter.read(from)) {
4273
+ case 1:
4274
+ return new ContractError.InvalidOffer({
4275
+ message: FfiConverterString.read(from),
4276
+ });
4277
+ case 2:
4278
+ return new ContractError.InvalidAccept({
4279
+ message: FfiConverterString.read(from),
4280
+ });
4281
+ case 3:
4282
+ return new ContractError.InvalidSign({
4283
+ message: FfiConverterString.read(from),
4284
+ });
4285
+ case 4:
4286
+ return new ContractError.InvalidFundingInput({
4287
+ message: FfiConverterString.read(from),
4288
+ });
4289
+ case 5:
4290
+ return new ContractError.PsbtMismatch({
4291
+ message: FfiConverterString.read(from),
4292
+ });
4293
+ case 6:
4294
+ return new ContractError.MissingFinalizedInput({
4295
+ inputIndex: FfiConverterUInt32.read(from),
4296
+ });
4297
+ case 7:
4298
+ return new ContractError.UnsupportedScriptType({
4299
+ inputIndex: FfiConverterUInt32.read(from),
4300
+ });
4301
+ case 8:
4302
+ return new ContractError.InvalidAttestation({
4303
+ message: FfiConverterString.read(from),
4304
+ });
4305
+ case 9:
4306
+ return new ContractError.NoMatchingOutcome();
4307
+ case 10:
4308
+ return new ContractError.Descriptor({
4309
+ message: FfiConverterString.read(from),
4310
+ });
4311
+ case 11:
4312
+ return new ContractError.Wallet({
4313
+ message: FfiConverterString.read(from),
4314
+ });
4315
+ case 12:
4316
+ return new ContractError.Bip32({
4317
+ message: FfiConverterString.read(from),
4318
+ });
4319
+ case 13:
4320
+ return new ContractError.Dlc({
4321
+ message: FfiConverterString.read(from),
4322
+ });
4323
+ case 14:
4324
+ return new ContractError.Key({
4325
+ message: FfiConverterString.read(from),
4326
+ });
4327
+ case 15:
4328
+ return new ContractError.Serialization({
4329
+ message: FfiConverterString.read(from),
4330
+ });
4331
+ case 16:
4332
+ return new ContractError.InvalidNetwork({
4333
+ message: FfiConverterString.read(from),
4334
+ });
4335
+ case 17:
4336
+ return new ContractError.InvalidLength({
4337
+ field: FfiConverterString.read(from),
4338
+ expected: FfiConverterUInt32.read(from),
4339
+ actual: FfiConverterUInt32.read(from),
4340
+ });
4341
+ default:
4342
+ throw new UniffiInternalError.UnexpectedEnumCase();
4343
+ }
4344
+ }
4345
+ write(value: TypeName, into: RustBuffer): void {
4346
+ switch (value.tag) {
4347
+ case ContractError_Tags.InvalidOffer: {
4348
+ ordinalConverter.write(1, into);
4349
+ const inner = value.inner;
4350
+ FfiConverterString.write(inner.message, into);
4351
+ return;
4352
+ }
4353
+ case ContractError_Tags.InvalidAccept: {
4354
+ ordinalConverter.write(2, into);
4355
+ const inner = value.inner;
4356
+ FfiConverterString.write(inner.message, into);
4357
+ return;
4358
+ }
4359
+ case ContractError_Tags.InvalidSign: {
4360
+ ordinalConverter.write(3, into);
4361
+ const inner = value.inner;
4362
+ FfiConverterString.write(inner.message, into);
4363
+ return;
4364
+ }
4365
+ case ContractError_Tags.InvalidFundingInput: {
4366
+ ordinalConverter.write(4, into);
4367
+ const inner = value.inner;
4368
+ FfiConverterString.write(inner.message, into);
4369
+ return;
4370
+ }
4371
+ case ContractError_Tags.PsbtMismatch: {
4372
+ ordinalConverter.write(5, into);
4373
+ const inner = value.inner;
4374
+ FfiConverterString.write(inner.message, into);
4375
+ return;
4376
+ }
4377
+ case ContractError_Tags.MissingFinalizedInput: {
4378
+ ordinalConverter.write(6, into);
4379
+ const inner = value.inner;
4380
+ FfiConverterUInt32.write(inner.inputIndex, into);
4381
+ return;
4382
+ }
4383
+ case ContractError_Tags.UnsupportedScriptType: {
4384
+ ordinalConverter.write(7, into);
4385
+ const inner = value.inner;
4386
+ FfiConverterUInt32.write(inner.inputIndex, into);
4387
+ return;
4388
+ }
4389
+ case ContractError_Tags.InvalidAttestation: {
4390
+ ordinalConverter.write(8, into);
4391
+ const inner = value.inner;
4392
+ FfiConverterString.write(inner.message, into);
4393
+ return;
4394
+ }
4395
+ case ContractError_Tags.NoMatchingOutcome: {
4396
+ ordinalConverter.write(9, into);
4397
+ return;
4398
+ }
4399
+ case ContractError_Tags.Descriptor: {
4400
+ ordinalConverter.write(10, into);
4401
+ const inner = value.inner;
4402
+ FfiConverterString.write(inner.message, into);
4403
+ return;
4404
+ }
4405
+ case ContractError_Tags.Wallet: {
4406
+ ordinalConverter.write(11, into);
4407
+ const inner = value.inner;
4408
+ FfiConverterString.write(inner.message, into);
4409
+ return;
4410
+ }
4411
+ case ContractError_Tags.Bip32: {
4412
+ ordinalConverter.write(12, into);
4413
+ const inner = value.inner;
4414
+ FfiConverterString.write(inner.message, into);
4415
+ return;
4416
+ }
4417
+ case ContractError_Tags.Dlc: {
4418
+ ordinalConverter.write(13, into);
4419
+ const inner = value.inner;
4420
+ FfiConverterString.write(inner.message, into);
4421
+ return;
4422
+ }
4423
+ case ContractError_Tags.Key: {
4424
+ ordinalConverter.write(14, into);
4425
+ const inner = value.inner;
4426
+ FfiConverterString.write(inner.message, into);
4427
+ return;
4428
+ }
4429
+ case ContractError_Tags.Serialization: {
4430
+ ordinalConverter.write(15, into);
4431
+ const inner = value.inner;
4432
+ FfiConverterString.write(inner.message, into);
4433
+ return;
4434
+ }
4435
+ case ContractError_Tags.InvalidNetwork: {
4436
+ ordinalConverter.write(16, into);
4437
+ const inner = value.inner;
4438
+ FfiConverterString.write(inner.message, into);
4439
+ return;
4440
+ }
4441
+ case ContractError_Tags.InvalidLength: {
4442
+ ordinalConverter.write(17, into);
4443
+ const inner = value.inner;
4444
+ FfiConverterString.write(inner.field, into);
4445
+ FfiConverterUInt32.write(inner.expected, into);
4446
+ FfiConverterUInt32.write(inner.actual, into);
4447
+ return;
4448
+ }
4449
+ default:
4450
+ // Throwing from here means that ContractError_Tags hasn't matched an ordinal.
4451
+ throw new UniffiInternalError.UnexpectedEnumCase();
4452
+ }
4453
+ }
4454
+ allocationSize(value: TypeName): number {
4455
+ switch (value.tag) {
4456
+ case ContractError_Tags.InvalidOffer: {
4457
+ const inner = value.inner;
4458
+ let size = ordinalConverter.allocationSize(1);
4459
+ size += FfiConverterString.allocationSize(inner.message);
4460
+ return size;
4461
+ }
4462
+ case ContractError_Tags.InvalidAccept: {
4463
+ const inner = value.inner;
4464
+ let size = ordinalConverter.allocationSize(2);
4465
+ size += FfiConverterString.allocationSize(inner.message);
4466
+ return size;
4467
+ }
4468
+ case ContractError_Tags.InvalidSign: {
4469
+ const inner = value.inner;
4470
+ let size = ordinalConverter.allocationSize(3);
4471
+ size += FfiConverterString.allocationSize(inner.message);
4472
+ return size;
4473
+ }
4474
+ case ContractError_Tags.InvalidFundingInput: {
4475
+ const inner = value.inner;
4476
+ let size = ordinalConverter.allocationSize(4);
4477
+ size += FfiConverterString.allocationSize(inner.message);
4478
+ return size;
4479
+ }
4480
+ case ContractError_Tags.PsbtMismatch: {
4481
+ const inner = value.inner;
4482
+ let size = ordinalConverter.allocationSize(5);
4483
+ size += FfiConverterString.allocationSize(inner.message);
4484
+ return size;
4485
+ }
4486
+ case ContractError_Tags.MissingFinalizedInput: {
4487
+ const inner = value.inner;
4488
+ let size = ordinalConverter.allocationSize(6);
4489
+ size += FfiConverterUInt32.allocationSize(inner.inputIndex);
4490
+ return size;
4491
+ }
4492
+ case ContractError_Tags.UnsupportedScriptType: {
4493
+ const inner = value.inner;
4494
+ let size = ordinalConverter.allocationSize(7);
4495
+ size += FfiConverterUInt32.allocationSize(inner.inputIndex);
4496
+ return size;
4497
+ }
4498
+ case ContractError_Tags.InvalidAttestation: {
4499
+ const inner = value.inner;
4500
+ let size = ordinalConverter.allocationSize(8);
4501
+ size += FfiConverterString.allocationSize(inner.message);
4502
+ return size;
4503
+ }
4504
+ case ContractError_Tags.NoMatchingOutcome: {
4505
+ return ordinalConverter.allocationSize(9);
4506
+ }
4507
+ case ContractError_Tags.Descriptor: {
4508
+ const inner = value.inner;
4509
+ let size = ordinalConverter.allocationSize(10);
4510
+ size += FfiConverterString.allocationSize(inner.message);
4511
+ return size;
4512
+ }
4513
+ case ContractError_Tags.Wallet: {
4514
+ const inner = value.inner;
4515
+ let size = ordinalConverter.allocationSize(11);
4516
+ size += FfiConverterString.allocationSize(inner.message);
4517
+ return size;
4518
+ }
4519
+ case ContractError_Tags.Bip32: {
4520
+ const inner = value.inner;
4521
+ let size = ordinalConverter.allocationSize(12);
4522
+ size += FfiConverterString.allocationSize(inner.message);
4523
+ return size;
4524
+ }
4525
+ case ContractError_Tags.Dlc: {
4526
+ const inner = value.inner;
4527
+ let size = ordinalConverter.allocationSize(13);
4528
+ size += FfiConverterString.allocationSize(inner.message);
4529
+ return size;
4530
+ }
4531
+ case ContractError_Tags.Key: {
4532
+ const inner = value.inner;
4533
+ let size = ordinalConverter.allocationSize(14);
4534
+ size += FfiConverterString.allocationSize(inner.message);
4535
+ return size;
4536
+ }
4537
+ case ContractError_Tags.Serialization: {
4538
+ const inner = value.inner;
4539
+ let size = ordinalConverter.allocationSize(15);
4540
+ size += FfiConverterString.allocationSize(inner.message);
4541
+ return size;
4542
+ }
4543
+ case ContractError_Tags.InvalidNetwork: {
4544
+ const inner = value.inner;
4545
+ let size = ordinalConverter.allocationSize(16);
4546
+ size += FfiConverterString.allocationSize(inner.message);
4547
+ return size;
4548
+ }
4549
+ case ContractError_Tags.InvalidLength: {
4550
+ const inner = value.inner;
4551
+ let size = ordinalConverter.allocationSize(17);
4552
+ size += FfiConverterString.allocationSize(inner.field);
4553
+ size += FfiConverterUInt32.allocationSize(inner.expected);
4554
+ size += FfiConverterUInt32.allocationSize(inner.actual);
4555
+ return size;
4556
+ }
4557
+ default:
4558
+ throw new UniffiInternalError.UnexpectedEnumCase();
4559
+ }
2078
4560
  }
2079
4561
  }
2080
4562
  return new FFIConverter();
@@ -2617,11 +5099,323 @@ const FfiConverterTypeDLCError = (() => {
2617
5099
  return new FFIConverter();
2618
5100
  })();
2619
5101
 
5102
+ /**
5103
+ * Identifies which party's funding inputs an operation applies to.
5104
+ */
5105
+ export enum Party {
5106
+ /**
5107
+ * The party that created the offer.
5108
+ */
5109
+ Offer,
5110
+ /**
5111
+ * The party that accepted the offer.
5112
+ */
5113
+ Accept,
5114
+ }
5115
+
5116
+ const FfiConverterTypeParty = (() => {
5117
+ const ordinalConverter = FfiConverterInt32;
5118
+ type TypeName = Party;
5119
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
5120
+ read(from: RustBuffer): TypeName {
5121
+ switch (ordinalConverter.read(from)) {
5122
+ case 1:
5123
+ return Party.Offer;
5124
+ case 2:
5125
+ return Party.Accept;
5126
+ default:
5127
+ throw new UniffiInternalError.UnexpectedEnumCase();
5128
+ }
5129
+ }
5130
+ write(value: TypeName, into: RustBuffer): void {
5131
+ switch (value) {
5132
+ case Party.Offer:
5133
+ return ordinalConverter.write(1, into);
5134
+ case Party.Accept:
5135
+ return ordinalConverter.write(2, into);
5136
+ }
5137
+ }
5138
+ allocationSize(value: TypeName): number {
5139
+ return ordinalConverter.allocationSize(0);
5140
+ }
5141
+ }
5142
+ return new FFIConverter();
5143
+ })();
5144
+
5145
+ /**
5146
+ * Deterministically derives DLC contract funding keys from a master extended
5147
+ * private key. Secret keys never leave this object.
5148
+ *
5149
+ * Construct one from whatever key material the consumer holds, then call
5150
+ * [`ContractKeyProvider::funding_pubkey`] to obtain the public key to publish
5151
+ * in an offer/accept message.
5152
+ */
5153
+ export interface ContractKeyProviderLike {
5154
+ /**
5155
+ * The 33-byte compressed funding public key for a contract, from its
5156
+ * 32-byte temporary id. Publish this in the offer or accept message.
5157
+ */
5158
+ fundingPubkey(temporaryContractId: ArrayBuffer) /*throws*/ : ArrayBuffer;
5159
+ }
5160
+ /**
5161
+ * @deprecated Use `ContractKeyProviderLike` instead.
5162
+ */
5163
+ export type ContractKeyProviderInterface = ContractKeyProviderLike;
5164
+
5165
+ /**
5166
+ * Deterministically derives DLC contract funding keys from a master extended
5167
+ * private key. Secret keys never leave this object.
5168
+ *
5169
+ * Construct one from whatever key material the consumer holds, then call
5170
+ * [`ContractKeyProvider::funding_pubkey`] to obtain the public key to publish
5171
+ * in an offer/accept message.
5172
+ */
5173
+ export class ContractKeyProvider
5174
+ extends UniffiAbstractObject
5175
+ implements ContractKeyProviderLike
5176
+ {
5177
+ readonly [uniffiTypeNameSymbol] = 'ContractKeyProvider';
5178
+ readonly [destructorGuardSymbol]: UniffiGcObject;
5179
+ readonly [pointerLiteralSymbol]: UniffiHandle;
5180
+ // No primary constructor declared for this class.
5181
+ private constructor(pointer: UniffiHandle) {
5182
+ super();
5183
+ this[pointerLiteralSymbol] = pointer;
5184
+ this[destructorGuardSymbol] =
5185
+ uniffiTypeContractKeyProviderObjectFactory.bless(pointer);
5186
+ }
5187
+
5188
+ /**
5189
+ * Builds a provider from an output descriptor that carries an extended
5190
+ * private key (e.g. `wpkh(xprv.../84h/1h/0h/0/*)`). Watch-only descriptors
5191
+ * are rejected; the descriptor's own path/wildcard is not applied to
5192
+ * contract-key derivation.
5193
+ */
5194
+ static fromDescriptor(
5195
+ descriptor: string
5196
+ ): ContractKeyProviderLike /*throws*/ {
5197
+ return FfiConverterTypeContractKeyProvider.lift(
5198
+ uniffiCaller.rustCallWithError(
5199
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
5200
+ FfiConverterTypeContractError
5201
+ ),
5202
+ /*caller:*/ (callStatus) => {
5203
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_constructor_contractkeyprovider_from_descriptor(
5204
+ FfiConverterString.lower(
5205
+ descriptor,
5206
+ nativeModule().rustbuffer_alloc
5207
+ ),
5208
+ callStatus
5209
+ );
5210
+ },
5211
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
5212
+ )
5213
+ );
5214
+ }
5215
+
5216
+ /**
5217
+ * Builds a provider from a BIP39 mnemonic (with optional passphrase).
5218
+ */
5219
+ static fromMnemonic(
5220
+ mnemonic: string,
5221
+ passphrase: string | undefined,
5222
+ network: string
5223
+ ): ContractKeyProviderLike /*throws*/ {
5224
+ return FfiConverterTypeContractKeyProvider.lift(
5225
+ uniffiCaller.rustCallWithError(
5226
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
5227
+ FfiConverterTypeContractError
5228
+ ),
5229
+ /*caller:*/ (callStatus) => {
5230
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_constructor_contractkeyprovider_from_mnemonic(
5231
+ FfiConverterString.lower(mnemonic, nativeModule().rustbuffer_alloc),
5232
+ FfiConverterOptionalString.lower(
5233
+ passphrase,
5234
+ nativeModule().rustbuffer_alloc
5235
+ ),
5236
+ FfiConverterString.lower(network, nativeModule().rustbuffer_alloc),
5237
+ callStatus
5238
+ );
5239
+ },
5240
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
5241
+ )
5242
+ );
5243
+ }
5244
+
5245
+ /**
5246
+ * Builds a provider from a raw seed (for example the 64 bytes produced by
5247
+ * `convert_mnemonic_to_seed`).
5248
+ */
5249
+ static fromSeed(
5250
+ seed: ArrayBuffer,
5251
+ network: string
5252
+ ): ContractKeyProviderLike /*throws*/ {
5253
+ return FfiConverterTypeContractKeyProvider.lift(
5254
+ uniffiCaller.rustCallWithError(
5255
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
5256
+ FfiConverterTypeContractError
5257
+ ),
5258
+ /*caller:*/ (callStatus) => {
5259
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_constructor_contractkeyprovider_from_seed(
5260
+ FfiConverterArrayBuffer.lower(
5261
+ seed,
5262
+ nativeModule().rustbuffer_alloc
5263
+ ),
5264
+ FfiConverterString.lower(network, nativeModule().rustbuffer_alloc),
5265
+ callStatus
5266
+ );
5267
+ },
5268
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
5269
+ )
5270
+ );
5271
+ }
5272
+
5273
+ /**
5274
+ * Builds a provider from a 78-byte encoded master extended private key
5275
+ * (the encoding produced by `create_extkey_from_seed`).
5276
+ */
5277
+ static fromXprv(xprv: ArrayBuffer): ContractKeyProviderLike /*throws*/ {
5278
+ return FfiConverterTypeContractKeyProvider.lift(
5279
+ uniffiCaller.rustCallWithError(
5280
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
5281
+ FfiConverterTypeContractError
5282
+ ),
5283
+ /*caller:*/ (callStatus) => {
5284
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_constructor_contractkeyprovider_from_xprv(
5285
+ FfiConverterArrayBuffer.lower(
5286
+ xprv,
5287
+ nativeModule().rustbuffer_alloc
5288
+ ),
5289
+ callStatus
5290
+ );
5291
+ },
5292
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
5293
+ )
5294
+ );
5295
+ }
5296
+
5297
+ /**
5298
+ * The 33-byte compressed funding public key for a contract, from its
5299
+ * 32-byte temporary id. Publish this in the offer or accept message.
5300
+ */
5301
+ fundingPubkey(temporaryContractId: ArrayBuffer): ArrayBuffer /*throws*/ {
5302
+ return ((__rb: Uint8Array) => {
5303
+ try {
5304
+ return FfiConverterArrayBuffer.lift(__rb);
5305
+ } finally {
5306
+ nativeModule().rustbuffer_free(__rb);
5307
+ }
5308
+ })(
5309
+ uniffiCaller.rustCallWithError(
5310
+ /*liftError:*/ FfiConverterTypeContractError.lift.bind(
5311
+ FfiConverterTypeContractError
5312
+ ),
5313
+ /*caller:*/ (callStatus) => {
5314
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_method_contractkeyprovider_funding_pubkey(
5315
+ uniffiTypeContractKeyProviderObjectFactory.clonePointer(this),
5316
+ FfiConverterArrayBuffer.lower(
5317
+ temporaryContractId,
5318
+ nativeModule().rustbuffer_alloc
5319
+ ),
5320
+ callStatus
5321
+ );
5322
+ },
5323
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
5324
+ )
5325
+ );
5326
+ }
5327
+
5328
+ uniffiDestroy(): void {
5329
+ const ptr = (this as any)[destructorGuardSymbol];
5330
+ if (ptr !== undefined) {
5331
+ const pointer = uniffiTypeContractKeyProviderObjectFactory.pointer(this);
5332
+ uniffiTypeContractKeyProviderObjectFactory.freePointer(pointer);
5333
+ uniffiTypeContractKeyProviderObjectFactory.unbless(ptr);
5334
+ delete (this as any)[destructorGuardSymbol];
5335
+ }
5336
+ }
5337
+
5338
+ static instanceOf(obj_: any): obj_ is ContractKeyProvider {
5339
+ return uniffiTypeContractKeyProviderObjectFactory.isConcreteType(obj_);
5340
+ }
5341
+ }
5342
+
5343
+ const uniffiTypeContractKeyProviderObjectFactory: UniffiObjectFactory<ContractKeyProviderLike> =
5344
+ (() => {
5345
+ return {
5346
+ create(pointer: UniffiHandle): ContractKeyProviderLike {
5347
+ const instance = Object.create(ContractKeyProvider.prototype);
5348
+ instance[pointerLiteralSymbol] = pointer;
5349
+ instance[destructorGuardSymbol] = this.bless(pointer);
5350
+ instance[uniffiTypeNameSymbol] = 'ContractKeyProvider';
5351
+ return instance;
5352
+ },
5353
+
5354
+ bless(p: UniffiHandle): UniffiGcObject {
5355
+ return uniffiCaller.rustCall(
5356
+ /*caller:*/ (status) =>
5357
+ nativeModule().ubrn_uniffi_internal_fn_method_contractkeyprovider_ffi__bless_pointer(
5358
+ p,
5359
+ status
5360
+ ),
5361
+ /*liftString:*/ FfiConverterString.lift
5362
+ );
5363
+ },
5364
+
5365
+ unbless(ptr_: UniffiGcObject) {
5366
+ ptr_.markDestroyed();
5367
+ },
5368
+
5369
+ pointer(obj_: ContractKeyProviderLike): UniffiHandle {
5370
+ if ((obj_ as any)[destructorGuardSymbol] === undefined) {
5371
+ throw new UniffiInternalError.UnexpectedNullPointer();
5372
+ }
5373
+ return (obj_ as any)[pointerLiteralSymbol];
5374
+ },
5375
+
5376
+ clonePointer(obj_: ContractKeyProviderLike): UniffiHandle {
5377
+ const pointer = this.pointer(obj_);
5378
+ return uniffiCaller.rustCall(
5379
+ /*caller:*/ (callStatus) =>
5380
+ nativeModule().ubrn_uniffi_ddk_ffi_fn_clone_contractkeyprovider(
5381
+ pointer,
5382
+ callStatus
5383
+ ),
5384
+ /*liftString:*/ FfiConverterString.lift
5385
+ );
5386
+ },
5387
+
5388
+ freePointer(pointer: UniffiHandle): void {
5389
+ uniffiCaller.rustCall(
5390
+ /*caller:*/ (callStatus) =>
5391
+ nativeModule().ubrn_uniffi_ddk_ffi_fn_free_contractkeyprovider(
5392
+ pointer,
5393
+ callStatus
5394
+ ),
5395
+ /*liftString:*/ FfiConverterString.lift
5396
+ );
5397
+ },
5398
+
5399
+ isConcreteType(obj_: any): obj_ is ContractKeyProviderLike {
5400
+ return (
5401
+ obj_[destructorGuardSymbol] &&
5402
+ obj_[uniffiTypeNameSymbol] === 'ContractKeyProvider'
5403
+ );
5404
+ },
5405
+ };
5406
+ })();
5407
+ const FfiConverterTypeContractKeyProvider = new FfiConverterObject(
5408
+ uniffiTypeContractKeyProviderObjectFactory
5409
+ );
5410
+
2620
5411
  // FfiConverter for Array<ArrayBuffer>
2621
5412
  const FfiConverterSequenceBytes = new FfiConverterArray(
2622
5413
  FfiConverterArrayBuffer
2623
5414
  );
2624
5415
 
5416
+ // FfiConverter for bigint | undefined
5417
+ const FfiConverterOptionalUInt64 = new FfiConverterOptional(FfiConverterUInt64);
5418
+
2625
5419
  // FfiConverter for Array<TxInput>
2626
5420
  const FfiConverterSequenceTypeTxInput = new FfiConverterArray(
2627
5421
  FfiConverterTypeTxInput
@@ -2637,6 +5431,19 @@ const FfiConverterSequenceTypeTransaction = new FfiConverterArray(
2637
5431
  FfiConverterTypeTransaction
2638
5432
  );
2639
5433
 
5434
+ // FfiConverter for string | undefined
5435
+ const FfiConverterOptionalString = new FfiConverterOptional(FfiConverterString);
5436
+
5437
+ // FfiConverter for Array<PayoutRow>
5438
+ const FfiConverterSequenceTypePayoutRow = new FfiConverterArray(
5439
+ FfiConverterTypePayoutRow
5440
+ );
5441
+
5442
+ // FfiConverter for ArrayBuffer | undefined
5443
+ const FfiConverterOptionalBytes = new FfiConverterOptional(
5444
+ FfiConverterArrayBuffer
5445
+ );
5446
+
2640
5447
  // FfiConverter for Array<TxInputInfo>
2641
5448
  const FfiConverterSequenceTypeTxInputInfo = new FfiConverterArray(
2642
5449
  FfiConverterTypeTxInputInfo
@@ -2647,9 +5454,6 @@ const FfiConverterSequenceTypeDlcInputInfo = new FfiConverterArray(
2647
5454
  FfiConverterTypeDlcInputInfo
2648
5455
  );
2649
5456
 
2650
- // FfiConverter for string | undefined
2651
- const FfiConverterOptionalString = new FfiConverterOptional(FfiConverterString);
2652
-
2653
5457
  // FfiConverter for Array<OracleInfo>
2654
5458
  const FfiConverterSequenceTypeOracleInfo = new FfiConverterArray(
2655
5459
  FfiConverterTypeOracleInfo
@@ -2675,6 +5479,21 @@ const FfiConverterSequenceTypePayout = new FfiConverterArray(
2675
5479
  FfiConverterTypePayout
2676
5480
  );
2677
5481
 
5482
+ // FfiConverter for Array<SpliceKeyRef>
5483
+ const FfiConverterSequenceTypeSpliceKeyRef = new FfiConverterArray(
5484
+ FfiConverterTypeSpliceKeyRef
5485
+ );
5486
+
5487
+ // FfiConverter for Array<OracleAttestationRef>
5488
+ const FfiConverterSequenceTypeOracleAttestationRef = new FfiConverterArray(
5489
+ FfiConverterTypeOracleAttestationRef
5490
+ );
5491
+
5492
+ // FfiConverter for Array<DescriptorInput>
5493
+ const FfiConverterSequenceTypeDescriptorInput = new FfiConverterArray(
5494
+ FfiConverterTypeDescriptorInput
5495
+ );
5496
+
2678
5497
  /**
2679
5498
  * This should be called before anything else.
2680
5499
  *
@@ -2697,6 +5516,37 @@ function uniffiEnsureInitialized() {
2697
5516
  bindingsContractVersion
2698
5517
  );
2699
5518
  }
5519
+ if (
5520
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_accept_offer() !== 49334
5521
+ ) {
5522
+ throw new UniffiInternalError.ApiChecksumMismatch(
5523
+ 'uniffi_ddk_ffi_checksum_func_accept_offer'
5524
+ );
5525
+ }
5526
+ if (
5527
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_chain_hash_from_network() !==
5528
+ 782
5529
+ ) {
5530
+ throw new UniffiInternalError.ApiChecksumMismatch(
5531
+ 'uniffi_ddk_ffi_checksum_func_chain_hash_from_network'
5532
+ );
5533
+ }
5534
+ if (
5535
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_compute_contract_id() !==
5536
+ 7849
5537
+ ) {
5538
+ throw new UniffiInternalError.ApiChecksumMismatch(
5539
+ 'uniffi_ddk_ffi_checksum_func_compute_contract_id'
5540
+ );
5541
+ }
5542
+ if (
5543
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_contract_info_payouts() !==
5544
+ 5148
5545
+ ) {
5546
+ throw new UniffiInternalError.ApiChecksumMismatch(
5547
+ 'uniffi_ddk_ffi_checksum_func_contract_info_payouts'
5548
+ );
5549
+ }
2700
5550
  if (
2701
5551
  nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_convert_mnemonic_to_seed() !==
2702
5552
  29793
@@ -2741,6 +5591,14 @@ function uniffiEnsureInitialized() {
2741
5591
  'uniffi_ddk_ffi_checksum_func_create_cets'
2742
5592
  );
2743
5593
  }
5594
+ if (
5595
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_create_dlc_splice_input() !==
5596
+ 50727
5597
+ ) {
5598
+ throw new UniffiInternalError.ApiChecksumMismatch(
5599
+ 'uniffi_ddk_ffi_checksum_func_create_dlc_splice_input'
5600
+ );
5601
+ }
2744
5602
  if (
2745
5603
  nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_create_dlc_transactions() !==
2746
5604
  60266
@@ -2773,6 +5631,21 @@ function uniffiEnsureInitialized() {
2773
5631
  'uniffi_ddk_ffi_checksum_func_create_fund_tx_locking_script'
2774
5632
  );
2775
5633
  }
5634
+ if (
5635
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_create_funding_psbt() !==
5636
+ 39942
5637
+ ) {
5638
+ throw new UniffiInternalError.ApiChecksumMismatch(
5639
+ 'uniffi_ddk_ffi_checksum_func_create_funding_psbt'
5640
+ );
5641
+ }
5642
+ if (
5643
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_create_offer() !== 39327
5644
+ ) {
5645
+ throw new UniffiInternalError.ApiChecksumMismatch(
5646
+ 'uniffi_ddk_ffi_checksum_func_create_offer'
5647
+ );
5648
+ }
2776
5649
  if (
2777
5650
  nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_create_refund_transaction() !==
2778
5651
  40230
@@ -2797,6 +5670,22 @@ function uniffiEnsureInitialized() {
2797
5670
  'uniffi_ddk_ffi_checksum_func_create_xpriv_from_parent_path'
2798
5671
  );
2799
5672
  }
5673
+ if (
5674
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_dlc_input_max_witness_len() !==
5675
+ 49586
5676
+ ) {
5677
+ throw new UniffiInternalError.ApiChecksumMismatch(
5678
+ 'uniffi_ddk_ffi_checksum_func_dlc_input_max_witness_len'
5679
+ );
5680
+ }
5681
+ if (
5682
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_dlc_transactions_from_messages() !==
5683
+ 56492
5684
+ ) {
5685
+ throw new UniffiInternalError.ApiChecksumMismatch(
5686
+ 'uniffi_ddk_ffi_checksum_func_dlc_transactions_from_messages'
5687
+ );
5688
+ }
2800
5689
  if (
2801
5690
  nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_extract_ecdsa_signature_from_oracle_signatures() !==
2802
5691
  4868
@@ -2805,6 +5694,28 @@ function uniffiEnsureInitialized() {
2805
5694
  'uniffi_ddk_ffi_checksum_func_extract_ecdsa_signature_from_oracle_signatures'
2806
5695
  );
2807
5696
  }
5697
+ if (
5698
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_finalize_sign() !== 20463
5699
+ ) {
5700
+ throw new UniffiInternalError.ApiChecksumMismatch(
5701
+ 'uniffi_ddk_ffi_checksum_func_finalize_sign'
5702
+ );
5703
+ }
5704
+ if (
5705
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_finalize_sign_spliced() !==
5706
+ 32005
5707
+ ) {
5708
+ throw new UniffiInternalError.ApiChecksumMismatch(
5709
+ 'uniffi_ddk_ffi_checksum_func_finalize_sign_spliced'
5710
+ );
5711
+ }
5712
+ if (
5713
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_funding_input() !== 64911
5714
+ ) {
5715
+ throw new UniffiInternalError.ApiChecksumMismatch(
5716
+ 'uniffi_ddk_ffi_checksum_func_funding_input'
5717
+ );
5718
+ }
2808
5719
  if (
2809
5720
  nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_get_pubkey_from_extkey() !==
2810
5721
  18050
@@ -2829,6 +5740,66 @@ function uniffiEnsureInitialized() {
2829
5740
  'uniffi_ddk_ffi_checksum_func_get_xpub_from_xpriv'
2830
5741
  );
2831
5742
  }
5743
+ if (
5744
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_sign_accept() !== 37062
5745
+ ) {
5746
+ throw new UniffiInternalError.ApiChecksumMismatch(
5747
+ 'uniffi_ddk_ffi_checksum_func_sign_accept'
5748
+ );
5749
+ }
5750
+ if (
5751
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_sign_accept_spliced() !==
5752
+ 32504
5753
+ ) {
5754
+ throw new UniffiInternalError.ApiChecksumMismatch(
5755
+ 'uniffi_ddk_ffi_checksum_func_sign_accept_spliced'
5756
+ );
5757
+ }
5758
+ if (
5759
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_sign_contract_cet() !==
5760
+ 36727
5761
+ ) {
5762
+ throw new UniffiInternalError.ApiChecksumMismatch(
5763
+ 'uniffi_ddk_ffi_checksum_func_sign_contract_cet'
5764
+ );
5765
+ }
5766
+ if (
5767
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_sign_contract_refund() !==
5768
+ 23156
5769
+ ) {
5770
+ throw new UniffiInternalError.ApiChecksumMismatch(
5771
+ 'uniffi_ddk_ffi_checksum_func_sign_contract_refund'
5772
+ );
5773
+ }
5774
+ if (
5775
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_sign_funding_psbt_with_descriptor() !==
5776
+ 25961
5777
+ ) {
5778
+ throw new UniffiInternalError.ApiChecksumMismatch(
5779
+ 'uniffi_ddk_ffi_checksum_func_sign_funding_psbt_with_descriptor'
5780
+ );
5781
+ }
5782
+ if (
5783
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_validate_accept() !== 9081
5784
+ ) {
5785
+ throw new UniffiInternalError.ApiChecksumMismatch(
5786
+ 'uniffi_ddk_ffi_checksum_func_validate_accept'
5787
+ );
5788
+ }
5789
+ if (
5790
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_validate_offer() !== 24632
5791
+ ) {
5792
+ throw new UniffiInternalError.ApiChecksumMismatch(
5793
+ 'uniffi_ddk_ffi_checksum_func_validate_offer'
5794
+ );
5795
+ }
5796
+ if (
5797
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_validate_sign() !== 7419
5798
+ ) {
5799
+ throw new UniffiInternalError.ApiChecksumMismatch(
5800
+ 'uniffi_ddk_ffi_checksum_func_validate_sign'
5801
+ );
5802
+ }
2832
5803
  if (
2833
5804
  nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_verify_cet_adaptor_sigs_from_oracle_info() !==
2834
5805
  32235
@@ -2842,21 +5813,74 @@ function uniffiEnsureInitialized() {
2842
5813
  'uniffi_ddk_ffi_checksum_func_version'
2843
5814
  );
2844
5815
  }
5816
+ if (
5817
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_constructor_contractkeyprovider_from_descriptor() !==
5818
+ 47034
5819
+ ) {
5820
+ throw new UniffiInternalError.ApiChecksumMismatch(
5821
+ 'uniffi_ddk_ffi_checksum_constructor_contractkeyprovider_from_descriptor'
5822
+ );
5823
+ }
5824
+ if (
5825
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_constructor_contractkeyprovider_from_mnemonic() !==
5826
+ 47667
5827
+ ) {
5828
+ throw new UniffiInternalError.ApiChecksumMismatch(
5829
+ 'uniffi_ddk_ffi_checksum_constructor_contractkeyprovider_from_mnemonic'
5830
+ );
5831
+ }
5832
+ if (
5833
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_constructor_contractkeyprovider_from_seed() !==
5834
+ 47192
5835
+ ) {
5836
+ throw new UniffiInternalError.ApiChecksumMismatch(
5837
+ 'uniffi_ddk_ffi_checksum_constructor_contractkeyprovider_from_seed'
5838
+ );
5839
+ }
5840
+ if (
5841
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_constructor_contractkeyprovider_from_xprv() !==
5842
+ 7002
5843
+ ) {
5844
+ throw new UniffiInternalError.ApiChecksumMismatch(
5845
+ 'uniffi_ddk_ffi_checksum_constructor_contractkeyprovider_from_xprv'
5846
+ );
5847
+ }
5848
+ if (
5849
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_method_contractkeyprovider_funding_pubkey() !==
5850
+ 58577
5851
+ ) {
5852
+ throw new UniffiInternalError.ApiChecksumMismatch(
5853
+ 'uniffi_ddk_ffi_checksum_method_contractkeyprovider_funding_pubkey'
5854
+ );
5855
+ }
2845
5856
  }
2846
5857
 
2847
5858
  export default Object.freeze({
2848
5859
  initialize: uniffiEnsureInitialized,
2849
5860
  converters: {
5861
+ FfiConverterTypeAcceptOfferParams,
5862
+ FfiConverterTypeAcceptResult,
2850
5863
  FfiConverterTypeAdaptorSignature,
2851
5864
  FfiConverterTypeCetAdaptorSignatureDebugInfo,
2852
5865
  FfiConverterTypeChangeOutputAndFees,
5866
+ FfiConverterTypeContractError,
5867
+ FfiConverterTypeContractKeyProvider,
5868
+ FfiConverterTypeContractPartyParams,
5869
+ FfiConverterTypeContractPayouts,
5870
+ FfiConverterTypeCreateOfferParams,
2853
5871
  FfiConverterTypeDLCError,
5872
+ FfiConverterTypeDescriptorInput,
2854
5873
  FfiConverterTypeDlcInputInfo,
2855
5874
  FfiConverterTypeDlcTransactions,
2856
5875
  FfiConverterTypeExtendedKey,
5876
+ FfiConverterTypeOracleAttestationRef,
2857
5877
  FfiConverterTypeOracleInfo,
5878
+ FfiConverterTypeParty,
2858
5879
  FfiConverterTypePartyParams,
2859
5880
  FfiConverterTypePayout,
5881
+ FfiConverterTypePayoutRow,
5882
+ FfiConverterTypeSignResult,
5883
+ FfiConverterTypeSpliceKeyRef,
2860
5884
  FfiConverterTypeTransaction,
2861
5885
  FfiConverterTypeTxInput,
2862
5886
  FfiConverterTypeTxInputInfo,