@bennyblader/ddk-rn 0.2.7 → 0.3.1

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
@@ -36,6 +36,7 @@ import {
36
36
  FfiConverterArray,
37
37
  FfiConverterBool,
38
38
  FfiConverterInt32,
39
+ FfiConverterOptional,
39
40
  FfiConverterUInt32,
40
41
  FfiConverterUInt64,
41
42
  FfiConverterUInt8,
@@ -60,6 +61,30 @@ const uniffiIsDebug =
60
61
  true;
61
62
  // Public interface members begin here.
62
63
 
64
+ export function convertMnemonicToSeed(
65
+ mnemonic: string,
66
+ passphrase: string | undefined
67
+ ): Array</*u8*/ number> /*throws*/ {
68
+ return FfiConverterArrayUInt8.lift(
69
+ uniffiCaller.rustCallWithError(
70
+ /*liftError:*/ FfiConverterTypeDLCError.lift.bind(
71
+ FfiConverterTypeDLCError
72
+ ),
73
+ /*caller:*/ (callStatus) => {
74
+ return (() => {
75
+ console.debug(`-- uniffi_ddk_ffi_fn_func_convert_mnemonic_to_seed`);
76
+ return nativeModule()
77
+ .ubrn_uniffi_ddk_ffi_fn_func_convert_mnemonic_to_seed;
78
+ })()(
79
+ FfiConverterString.lower(mnemonic),
80
+ FfiConverterOptionalString.lower(passphrase),
81
+ callStatus
82
+ );
83
+ },
84
+ /*liftString:*/ FfiConverterString.lift
85
+ )
86
+ );
87
+ }
63
88
  export function createCet(
64
89
  localOutput: TxOutput,
65
90
  localPayoutSerialId: /*u64*/ bigint,
@@ -296,6 +321,36 @@ export function createSplicedDlcTransactions(
296
321
  )
297
322
  );
298
323
  }
324
+ export function createXprivFromParentPath(
325
+ xpriv: Array</*u8*/ number>,
326
+ baseDerivationPath: string,
327
+ network: string,
328
+ path: string
329
+ ): Array</*u8*/ number> /*throws*/ {
330
+ return FfiConverterArrayUInt8.lift(
331
+ uniffiCaller.rustCallWithError(
332
+ /*liftError:*/ FfiConverterTypeDLCError.lift.bind(
333
+ FfiConverterTypeDLCError
334
+ ),
335
+ /*caller:*/ (callStatus) => {
336
+ return (() => {
337
+ console.debug(
338
+ `-- uniffi_ddk_ffi_fn_func_create_xpriv_from_parent_path`
339
+ );
340
+ return nativeModule()
341
+ .ubrn_uniffi_ddk_ffi_fn_func_create_xpriv_from_parent_path;
342
+ })()(
343
+ FfiConverterArrayUInt8.lower(xpriv),
344
+ FfiConverterString.lower(baseDerivationPath),
345
+ FfiConverterString.lower(network),
346
+ FfiConverterString.lower(path),
347
+ callStatus
348
+ );
349
+ },
350
+ /*liftString:*/ FfiConverterString.lift
351
+ )
352
+ );
353
+ }
299
354
  export function getChangeOutputAndFees(
300
355
  params: PartyParams,
301
356
  feeRate: /*u64*/ bigint
@@ -366,6 +421,29 @@ export function getTotalInputVsize(inputs: Array<TxInputInfo>): /*u32*/ number {
366
421
  )
367
422
  );
368
423
  }
424
+ export function getXpubFromXpriv(
425
+ xpriv: Array</*u8*/ number>,
426
+ network: string
427
+ ): Array</*u8*/ number> /*throws*/ {
428
+ return FfiConverterArrayUInt8.lift(
429
+ uniffiCaller.rustCallWithError(
430
+ /*liftError:*/ FfiConverterTypeDLCError.lift.bind(
431
+ FfiConverterTypeDLCError
432
+ ),
433
+ /*caller:*/ (callStatus) => {
434
+ return (() => {
435
+ console.debug(`-- uniffi_ddk_ffi_fn_func_get_xpub_from_xpriv`);
436
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_get_xpub_from_xpriv;
437
+ })()(
438
+ FfiConverterArrayUInt8.lower(xpriv),
439
+ FfiConverterString.lower(network),
440
+ callStatus
441
+ );
442
+ },
443
+ /*liftString:*/ FfiConverterString.lift
444
+ )
445
+ );
446
+ }
369
447
  export function isDustOutput(output: TxOutput): boolean {
370
448
  return FfiConverterBool.lift(
371
449
  uniffiCaller.rustCall(
@@ -379,14 +457,34 @@ export function isDustOutput(output: TxOutput): boolean {
379
457
  )
380
458
  );
381
459
  }
382
- export function plzWork(): string {
383
- return FfiConverterString.lift(
384
- uniffiCaller.rustCall(
460
+ export function signCet(
461
+ cet: Transaction,
462
+ adaptorSignature: Array</*u8*/ number>,
463
+ oracleSignatures: Array<Array</*u8*/ number>>,
464
+ fundingSecretKey: Array</*u8*/ number>,
465
+ otherPubkey: Array</*u8*/ number>,
466
+ fundingScriptPubkey: Array</*u8*/ number>,
467
+ fundOutputValue: /*u64*/ bigint
468
+ ): Transaction /*throws*/ {
469
+ return FfiConverterTypeTransaction.lift(
470
+ uniffiCaller.rustCallWithError(
471
+ /*liftError:*/ FfiConverterTypeDLCError.lift.bind(
472
+ FfiConverterTypeDLCError
473
+ ),
385
474
  /*caller:*/ (callStatus) => {
386
475
  return (() => {
387
- console.debug(`-- uniffi_ddk_ffi_fn_func_plz_work`);
388
- return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_plz_work;
389
- })()(callStatus);
476
+ console.debug(`-- uniffi_ddk_ffi_fn_func_sign_cet`);
477
+ return nativeModule().ubrn_uniffi_ddk_ffi_fn_func_sign_cet;
478
+ })()(
479
+ FfiConverterTypeTransaction.lower(cet),
480
+ FfiConverterArrayUInt8.lower(adaptorSignature),
481
+ FfiConverterArrayArrayUInt8.lower(oracleSignatures),
482
+ FfiConverterArrayUInt8.lower(fundingSecretKey),
483
+ FfiConverterArrayUInt8.lower(otherPubkey),
484
+ FfiConverterArrayUInt8.lower(fundingScriptPubkey),
485
+ FfiConverterUInt64.lower(fundOutputValue),
486
+ callStatus
487
+ );
390
488
  },
391
489
  /*liftString:*/ FfiConverterString.lift
392
490
  )
@@ -1295,7 +1393,8 @@ export enum DlcError_Tags {
1295
1393
  SerializationError = 'SerializationError',
1296
1394
  Secp256k1Error = 'Secp256k1Error',
1297
1395
  MiniscriptError = 'MiniscriptError',
1298
- NetworkError = 'NetworkError',
1396
+ InvalidNetwork = 'InvalidNetwork',
1397
+ KeyError = 'KeyError',
1299
1398
  }
1300
1399
  export const DlcError = (() => {
1301
1400
  class InvalidSignature extends UniffiError {
@@ -1474,7 +1573,7 @@ export const DlcError = (() => {
1474
1573
  return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 8;
1475
1574
  }
1476
1575
  }
1477
- class NetworkError extends UniffiError {
1576
+ class InvalidNetwork extends UniffiError {
1478
1577
  /**
1479
1578
  * @private
1480
1579
  * This field is private and should not be used.
@@ -1486,16 +1585,38 @@ export const DlcError = (() => {
1486
1585
  */
1487
1586
  readonly [variantOrdinalSymbol] = 9;
1488
1587
 
1489
- public readonly tag = DlcError_Tags.NetworkError;
1588
+ public readonly tag = DlcError_Tags.InvalidNetwork;
1490
1589
 
1491
1590
  constructor(message: string) {
1492
- super('DlcError', 'NetworkError', message);
1591
+ super('DlcError', 'InvalidNetwork', message);
1493
1592
  }
1494
1593
 
1495
- static instanceOf(e: any): e is NetworkError {
1594
+ static instanceOf(e: any): e is InvalidNetwork {
1496
1595
  return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 9;
1497
1596
  }
1498
1597
  }
1598
+ class KeyError extends UniffiError {
1599
+ /**
1600
+ * @private
1601
+ * This field is private and should not be used.
1602
+ */
1603
+ readonly [uniffiTypeNameSymbol]: string = 'DlcError';
1604
+ /**
1605
+ * @private
1606
+ * This field is private and should not be used.
1607
+ */
1608
+ readonly [variantOrdinalSymbol] = 10;
1609
+
1610
+ public readonly tag = DlcError_Tags.KeyError;
1611
+
1612
+ constructor(message: string) {
1613
+ super('DlcError', 'KeyError', message);
1614
+ }
1615
+
1616
+ static instanceOf(e: any): e is KeyError {
1617
+ return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 10;
1618
+ }
1619
+ }
1499
1620
 
1500
1621
  // Utility function which does not rely on instanceof.
1501
1622
  function instanceOf(e: any): e is DlcError {
@@ -1510,7 +1631,8 @@ export const DlcError = (() => {
1510
1631
  SerializationError,
1511
1632
  Secp256k1Error,
1512
1633
  MiniscriptError,
1513
- NetworkError,
1634
+ InvalidNetwork,
1635
+ KeyError,
1514
1636
  instanceOf,
1515
1637
  };
1516
1638
  })();
@@ -1552,7 +1674,162 @@ const FfiConverterTypeDLCError = (() => {
1552
1674
  return new DlcError.MiniscriptError(FfiConverterString.read(from));
1553
1675
 
1554
1676
  case 9:
1555
- return new DlcError.NetworkError(FfiConverterString.read(from));
1677
+ return new DlcError.InvalidNetwork(FfiConverterString.read(from));
1678
+
1679
+ case 10:
1680
+ return new DlcError.KeyError(FfiConverterString.read(from));
1681
+
1682
+ default:
1683
+ throw new UniffiInternalError.UnexpectedEnumCase();
1684
+ }
1685
+ }
1686
+ write(value: TypeName, into: RustBuffer): void {
1687
+ const obj = value as any;
1688
+ const index = obj[variantOrdinalSymbol] as number;
1689
+ intConverter.write(index, into);
1690
+ }
1691
+ allocationSize(value: TypeName): number {
1692
+ return intConverter.allocationSize(0);
1693
+ }
1694
+ }
1695
+ return new FfiConverter();
1696
+ })();
1697
+
1698
+ // Flat error type: ExtendedKey
1699
+ export enum ExtendedKey_Tags {
1700
+ InvalidMnemonic = 'InvalidMnemonic',
1701
+ InvalidXpriv = 'InvalidXpriv',
1702
+ InvalidXpub = 'InvalidXpub',
1703
+ InvalidDerivationPath = 'InvalidDerivationPath',
1704
+ }
1705
+ export const ExtendedKey = (() => {
1706
+ class InvalidMnemonic extends UniffiError {
1707
+ /**
1708
+ * @private
1709
+ * This field is private and should not be used.
1710
+ */
1711
+ readonly [uniffiTypeNameSymbol]: string = 'ExtendedKey';
1712
+ /**
1713
+ * @private
1714
+ * This field is private and should not be used.
1715
+ */
1716
+ readonly [variantOrdinalSymbol] = 1;
1717
+
1718
+ public readonly tag = ExtendedKey_Tags.InvalidMnemonic;
1719
+
1720
+ constructor(message: string) {
1721
+ super('ExtendedKey', 'InvalidMnemonic', message);
1722
+ }
1723
+
1724
+ static instanceOf(e: any): e is InvalidMnemonic {
1725
+ return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 1;
1726
+ }
1727
+ }
1728
+ class InvalidXpriv extends UniffiError {
1729
+ /**
1730
+ * @private
1731
+ * This field is private and should not be used.
1732
+ */
1733
+ readonly [uniffiTypeNameSymbol]: string = 'ExtendedKey';
1734
+ /**
1735
+ * @private
1736
+ * This field is private and should not be used.
1737
+ */
1738
+ readonly [variantOrdinalSymbol] = 2;
1739
+
1740
+ public readonly tag = ExtendedKey_Tags.InvalidXpriv;
1741
+
1742
+ constructor(message: string) {
1743
+ super('ExtendedKey', 'InvalidXpriv', message);
1744
+ }
1745
+
1746
+ static instanceOf(e: any): e is InvalidXpriv {
1747
+ return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 2;
1748
+ }
1749
+ }
1750
+ class InvalidXpub extends UniffiError {
1751
+ /**
1752
+ * @private
1753
+ * This field is private and should not be used.
1754
+ */
1755
+ readonly [uniffiTypeNameSymbol]: string = 'ExtendedKey';
1756
+ /**
1757
+ * @private
1758
+ * This field is private and should not be used.
1759
+ */
1760
+ readonly [variantOrdinalSymbol] = 3;
1761
+
1762
+ public readonly tag = ExtendedKey_Tags.InvalidXpub;
1763
+
1764
+ constructor(message: string) {
1765
+ super('ExtendedKey', 'InvalidXpub', message);
1766
+ }
1767
+
1768
+ static instanceOf(e: any): e is InvalidXpub {
1769
+ return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 3;
1770
+ }
1771
+ }
1772
+ class InvalidDerivationPath extends UniffiError {
1773
+ /**
1774
+ * @private
1775
+ * This field is private and should not be used.
1776
+ */
1777
+ readonly [uniffiTypeNameSymbol]: string = 'ExtendedKey';
1778
+ /**
1779
+ * @private
1780
+ * This field is private and should not be used.
1781
+ */
1782
+ readonly [variantOrdinalSymbol] = 4;
1783
+
1784
+ public readonly tag = ExtendedKey_Tags.InvalidDerivationPath;
1785
+
1786
+ constructor(message: string) {
1787
+ super('ExtendedKey', 'InvalidDerivationPath', message);
1788
+ }
1789
+
1790
+ static instanceOf(e: any): e is InvalidDerivationPath {
1791
+ return instanceOf(e) && (e as any)[variantOrdinalSymbol] === 4;
1792
+ }
1793
+ }
1794
+
1795
+ // Utility function which does not rely on instanceof.
1796
+ function instanceOf(e: any): e is ExtendedKey {
1797
+ return (e as any)[uniffiTypeNameSymbol] === 'ExtendedKey';
1798
+ }
1799
+ return {
1800
+ InvalidMnemonic,
1801
+ InvalidXpriv,
1802
+ InvalidXpub,
1803
+ InvalidDerivationPath,
1804
+ instanceOf,
1805
+ };
1806
+ })();
1807
+
1808
+ // Union type for ExtendedKey error type.
1809
+
1810
+ export type ExtendedKey = InstanceType<
1811
+ (typeof ExtendedKey)[keyof Omit<typeof ExtendedKey, 'instanceOf'>]
1812
+ >;
1813
+
1814
+ const FfiConverterTypeExtendedKey = (() => {
1815
+ const intConverter = FfiConverterInt32;
1816
+ type TypeName = ExtendedKey;
1817
+ class FfiConverter extends AbstractFfiConverterByteArray<TypeName> {
1818
+ read(from: RustBuffer): TypeName {
1819
+ switch (intConverter.read(from)) {
1820
+ case 1:
1821
+ return new ExtendedKey.InvalidMnemonic(FfiConverterString.read(from));
1822
+
1823
+ case 2:
1824
+ return new ExtendedKey.InvalidXpriv(FfiConverterString.read(from));
1825
+
1826
+ case 3:
1827
+ return new ExtendedKey.InvalidXpub(FfiConverterString.read(from));
1828
+
1829
+ case 4:
1830
+ return new ExtendedKey.InvalidDerivationPath(
1831
+ FfiConverterString.read(from)
1832
+ );
1556
1833
 
1557
1834
  default:
1558
1835
  throw new UniffiInternalError.UnexpectedEnumCase();
@@ -1570,6 +1847,9 @@ const FfiConverterTypeDLCError = (() => {
1570
1847
  return new FfiConverter();
1571
1848
  })();
1572
1849
 
1850
+ // FfiConverter for string | undefined
1851
+ const FfiConverterOptionalString = new FfiConverterOptional(FfiConverterString);
1852
+
1573
1853
  // FfiConverter for Array<DlcInputInfo>
1574
1854
  const FfiConverterArrayTypeDlcInputInfo = new FfiConverterArray(
1575
1855
  FfiConverterTypeDlcInputInfo
@@ -1630,6 +1910,14 @@ function uniffiEnsureInitialized() {
1630
1910
  bindingsContractVersion
1631
1911
  );
1632
1912
  }
1913
+ if (
1914
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_convert_mnemonic_to_seed() !==
1915
+ 65049
1916
+ ) {
1917
+ throw new UniffiInternalError.ApiChecksumMismatch(
1918
+ 'uniffi_ddk_ffi_checksum_func_convert_mnemonic_to_seed'
1919
+ );
1920
+ }
1633
1921
  if (nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_create_cet() !== 23081) {
1634
1922
  throw new UniffiInternalError.ApiChecksumMismatch(
1635
1923
  'uniffi_ddk_ffi_checksum_func_create_cet'
@@ -1682,6 +1970,14 @@ function uniffiEnsureInitialized() {
1682
1970
  'uniffi_ddk_ffi_checksum_func_create_spliced_dlc_transactions'
1683
1971
  );
1684
1972
  }
1973
+ if (
1974
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_create_xpriv_from_parent_path() !==
1975
+ 50010
1976
+ ) {
1977
+ throw new UniffiInternalError.ApiChecksumMismatch(
1978
+ 'uniffi_ddk_ffi_checksum_func_create_xpriv_from_parent_path'
1979
+ );
1980
+ }
1685
1981
  if (
1686
1982
  nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_get_change_output_and_fees() !==
1687
1983
  44150
@@ -1706,6 +2002,14 @@ function uniffiEnsureInitialized() {
1706
2002
  'uniffi_ddk_ffi_checksum_func_get_total_input_vsize'
1707
2003
  );
1708
2004
  }
2005
+ if (
2006
+ nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_get_xpub_from_xpriv() !==
2007
+ 44344
2008
+ ) {
2009
+ throw new UniffiInternalError.ApiChecksumMismatch(
2010
+ 'uniffi_ddk_ffi_checksum_func_get_xpub_from_xpriv'
2011
+ );
2012
+ }
1709
2013
  if (
1710
2014
  nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_is_dust_output() !== 64174
1711
2015
  ) {
@@ -1713,9 +2017,9 @@ function uniffiEnsureInitialized() {
1713
2017
  'uniffi_ddk_ffi_checksum_func_is_dust_output'
1714
2018
  );
1715
2019
  }
1716
- if (nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_plz_work() !== 32972) {
2020
+ if (nativeModule().ubrn_uniffi_ddk_ffi_checksum_func_sign_cet() !== 43957) {
1717
2021
  throw new UniffiInternalError.ApiChecksumMismatch(
1718
- 'uniffi_ddk_ffi_checksum_func_plz_work'
2022
+ 'uniffi_ddk_ffi_checksum_func_sign_cet'
1719
2023
  );
1720
2024
  }
1721
2025
  if (
@@ -1750,6 +2054,7 @@ export default Object.freeze({
1750
2054
  FfiConverterTypeDlcInputInfo,
1751
2055
  FfiConverterTypeDlcOutcome,
1752
2056
  FfiConverterTypeDlcTransactions,
2057
+ FfiConverterTypeExtendedKey,
1753
2058
  FfiConverterTypeOracleInfo,
1754
2059
  FfiConverterTypePartyParams,
1755
2060
  FfiConverterTypePayout,
@@ -1,243 +0,0 @@
1
- // Creates a set of DLC transactions (fund, CETs, refund)
2
- [Throws=DLCError]
3
- DlcTransactions create_dlc_transactions(
4
- PartyParams offer_params,
5
- PartyParams accept_params,
6
- sequence<Payout> payouts,
7
- u32 refund_lock_time,
8
- u64 fee_rate_per_vb,
9
- u32 fund_lock_time,
10
- u32 cet_lock_time,
11
- u64 fund_output_serial_id
12
- );
13
-
14
- // Creates a single Contract Execution Transaction
15
- [Throws=DLCError]
16
- Transaction create_cet(
17
- TxOutput local_output,
18
- TxOutput remote_output,
19
- string fund_tx_id,
20
- u32 fund_vout,
21
- u32 lock_time,
22
- u64 local_serial_id,
23
- u64 remote_serial_id
24
- );
25
-
26
- // Creates multiple CETs for different outcomes
27
- [Throws=DLCError]
28
- sequence<Transaction> create_cets(
29
- string fund_tx_id,
30
- u32 fund_vout,
31
- sequence<u8> local_final_script_pubkey,
32
- sequence<u8> remote_final_script_pubkey,
33
- sequence<DlcOutcome> outcomes,
34
- u32 lock_time,
35
- u64 local_serial_id,
36
- u64 remote_serial_id
37
- );
38
-
39
- // Creates the funding transaction locking script (2-of-2 multisig)
40
- [Throws=DLCError]
41
- sequence<u8> create_fund_tx_locking_script(
42
- sequence<u8> local_fund_pubkey,
43
- sequence<u8> remote_fund_pubkey
44
- );
45
-
46
- // Creates a funding transaction
47
- [Throws=DLCError]
48
- Transaction create_fund_transaction(
49
- sequence<u8> local_fund_pubkey,
50
- sequence<u8> remote_fund_pubkey,
51
- u64 output_amount,
52
- sequence<TxInputInfo> local_inputs,
53
- TxOutput local_change_output,
54
- sequence<TxInputInfo> remote_inputs,
55
- TxOutput remote_change_output,
56
- string? option_dest,
57
- u64 option_premium,
58
- u32 lock_time,
59
- u64 local_serial_id,
60
- u64 remote_serial_id,
61
- u64 fund_output_serial_id
62
- );
63
-
64
- // Creates a refund transaction
65
- [Throws=DLCError]
66
- Transaction create_refund_transaction(
67
- sequence<u8> local_final_script_pubkey,
68
- sequence<u8> remote_final_script_pubkey,
69
- u64 local_amount,
70
- u64 remote_amount,
71
- u32 lock_time,
72
- string fund_tx_id,
73
- u32 fund_vout
74
- );
75
-
76
- // Signs a funding transaction input
77
- [Throws=DLCError]
78
- void sign_fund_transaction_input(
79
- Transaction fund_transaction,
80
- sequence<u8> privkey,
81
- string prev_tx_id,
82
- u32 prev_tx_vout,
83
- u64 value
84
- );
85
-
86
- // Adds a signature to a funding transaction
87
- [Throws=DLCError]
88
- void add_signature_to_fund_transaction(
89
- Transaction fund_transaction,
90
- sequence<u8> signature,
91
- sequence<u8> pubkey,
92
- string prev_tx_id,
93
- u32 prev_tx_vout
94
- );
95
-
96
- // Verifies a funding transaction signature
97
- [Throws=DLCError]
98
- boolean verify_fund_tx_signature(
99
- Transaction fund_tx,
100
- sequence<u8> signature,
101
- sequence<u8> pubkey,
102
- string txid,
103
- u32 vout,
104
- u64 input_amount
105
- );
106
-
107
- // Creates a CET adaptor signature
108
- [Throws=DLCError]
109
- AdaptorSignature create_cet_adaptor_signature(
110
- Transaction cet,
111
- sequence<u8> oracle_pubkey,
112
- sequence<sequence<u8>> oracle_r_values,
113
- sequence<u8> funding_privkey,
114
- sequence<u8> funding_script_pubkey,
115
- u64 total_collateral,
116
- sequence<sequence<u8>> messages
117
- );
118
-
119
- // Creates multiple CET adaptor signatures
120
- [Throws=DLCError]
121
- sequence<AdaptorSignature> create_cet_adaptor_signatures(
122
- sequence<Transaction> cets,
123
- sequence<u8> oracle_pubkey,
124
- sequence<sequence<u8>> oracle_r_values,
125
- sequence<u8> funding_privkey,
126
- sequence<u8> funding_script_pubkey,
127
- u64 total_collateral,
128
- sequence<sequence<sequence<u8>>> messages
129
- );
130
-
131
- // Verifies a CET adaptor signature
132
- [Throws=DLCError]
133
- boolean verify_cet_adaptor_signature(
134
- AdaptorSignature adaptor_sig,
135
- Transaction cet,
136
- sequence<u8> pubkey,
137
- sequence<u8> oracle_pubkey,
138
- sequence<sequence<u8>> oracle_r_values,
139
- sequence<u8> funding_script_pubkey,
140
- u64 total_collateral,
141
- sequence<sequence<u8>> messages
142
- );
143
-
144
- // Verifies multiple CET adaptor signatures
145
- [Throws=DLCError]
146
- boolean verify_cet_adaptor_signatures(
147
- sequence<Transaction> cets,
148
- sequence<AdaptorSignature> adaptor_sigs,
149
- sequence<sequence<sequence<u8>>> messages,
150
- sequence<u8> pubkey,
151
- sequence<u8> oracle_pubkey,
152
- sequence<sequence<u8>> oracle_r_values,
153
- sequence<u8> funding_script_pubkey,
154
- u64 total_collateral
155
- );
156
-
157
- // Signs a CET with oracle signatures
158
- [Throws=DLCError]
159
- void sign_cet(
160
- Transaction cet,
161
- AdaptorSignature adaptor_sig,
162
- sequence<sequence<u8>> oracle_signatures,
163
- sequence<u8> funding_privkey,
164
- sequence<u8> funding_script_pubkey,
165
- string fund_tx_id,
166
- u32 fund_vout,
167
- u64 fund_amount
168
- );
169
-
170
- // Gets raw funding transaction input signature
171
- [Throws=DLCError]
172
- sequence<u8> get_raw_funding_transaction_input_signature(
173
- Transaction funding_transaction,
174
- sequence<u8> privkey,
175
- string prev_tx_id,
176
- u32 prev_tx_vout,
177
- u64 value
178
- );
179
-
180
- // Adds signatures for multisig input
181
- [Throws=DLCError]
182
- void add_signatures_for_multisig_input(
183
- Transaction transaction,
184
- string prev_tx_id,
185
- u32 prev_tx_vout,
186
- sequence<u8> multisig_script,
187
- sequence<sequence<u8>> signatures
188
- );
189
-
190
- // Adds signatures to refund transaction
191
- [Throws=DLCError]
192
- void add_signatures_to_refund_tx(
193
- Transaction refund_tx,
194
- sequence<u8> fund_lockscript,
195
- sequence<sequence<u8>> signatures,
196
- string fund_tx_id,
197
- u32 fund_tx_vout
198
- );
199
-
200
- // Gets raw refund transaction signature
201
- [Throws=DLCError]
202
- sequence<u8> get_raw_refund_tx_signature(
203
- Transaction refund_tx,
204
- sequence<u8> privkey,
205
- sequence<u8> fund_lockscript,
206
- u64 input_amount,
207
- string fund_tx_id,
208
- u32 fund_tx_vout
209
- );
210
-
211
- // Verifies refund transaction signature
212
- [Throws=DLCError]
213
- boolean verify_refund_tx_signature(
214
- Transaction refund_tx,
215
- sequence<u8> signature,
216
- sequence<u8> pubkey,
217
- sequence<u8> lock_script,
218
- u64 input_amount,
219
- string fund_txid,
220
- u32 fund_vout
221
- );
222
-
223
- // Utility: Calculate total input virtual size
224
- u32 get_total_input_vsize(sequence<TxInput> inputs);
225
-
226
- // Utility: Check if output is dust
227
- boolean is_dust_output(TxOutput output);
228
-
229
- // Utility: Get change output and fees for a party
230
- [Throws=DLCError]
231
- ChangeOutputAndFees get_change_output_and_fees(
232
- PartyParams params,
233
- u64 fee_rate,
234
- u64? extra_fee
235
- );
236
-
237
- // Compute adaptor point from messages and oracle info
238
- [Throws=DLCError]
239
- sequence<u8> compute_adaptor_point(
240
- sequence<sequence<u8>> messages,
241
- sequence<sequence<u8>> r_values,
242
- sequence<u8> oracle_pubkey
243
- );