@bennyblader/ddk-ts 0.1.5
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/LICENSE +21 -0
- package/README.md +150 -0
- package/index.js +524 -0
- package/package.json +95 -0
- package/src/conversions.rs +268 -0
- package/src/lib.rs +285 -0
- package/src/types.rs +111 -0
package/src/types.rs
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
use napi::bindgen_prelude::*;
|
|
2
|
+
use napi_derive::napi;
|
|
3
|
+
|
|
4
|
+
// Transaction representation - matches UDL exactly
|
|
5
|
+
#[napi(object)]
|
|
6
|
+
pub struct Transaction {
|
|
7
|
+
pub version: i32,
|
|
8
|
+
pub lock_time: u32,
|
|
9
|
+
pub inputs: Vec<TxInput>,
|
|
10
|
+
pub outputs: Vec<TxOutput>,
|
|
11
|
+
pub raw_bytes: Buffer,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Transaction input - matches UDL exactly
|
|
15
|
+
#[napi(object)]
|
|
16
|
+
pub struct TxInput {
|
|
17
|
+
pub txid: String,
|
|
18
|
+
pub vout: u32,
|
|
19
|
+
pub script_sig: Buffer,
|
|
20
|
+
pub sequence: u32,
|
|
21
|
+
pub witness: Vec<Buffer>,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Transaction output - matches UDL exactly
|
|
25
|
+
#[napi(object)]
|
|
26
|
+
pub struct TxOutput {
|
|
27
|
+
pub value: BigInt,
|
|
28
|
+
pub script_pubkey: Buffer,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Input information for funding - matches UDL exactly
|
|
32
|
+
#[napi(object)]
|
|
33
|
+
pub struct TxInputInfo {
|
|
34
|
+
pub txid: String,
|
|
35
|
+
pub vout: u32,
|
|
36
|
+
pub script_sig: Buffer,
|
|
37
|
+
pub max_witness_length: u32,
|
|
38
|
+
pub serial_id: BigInt,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// DLC outcome with payouts - matches UDL exactly
|
|
42
|
+
#[napi(object)]
|
|
43
|
+
pub struct DlcOutcome {
|
|
44
|
+
pub local_payout: BigInt,
|
|
45
|
+
pub remote_payout: BigInt,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Payout for offer and accept parties - matches UDL exactly
|
|
49
|
+
#[napi(object)]
|
|
50
|
+
pub struct Payout {
|
|
51
|
+
pub offer: BigInt,
|
|
52
|
+
pub accept: BigInt,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// DLC input information - matches UDL exactly
|
|
56
|
+
#[napi(object)]
|
|
57
|
+
pub struct DlcInputInfo {
|
|
58
|
+
pub fund_tx: Transaction,
|
|
59
|
+
pub fund_vout: u32,
|
|
60
|
+
pub local_fund_pubkey: Buffer,
|
|
61
|
+
pub remote_fund_pubkey: Buffer,
|
|
62
|
+
pub fund_amount: BigInt,
|
|
63
|
+
pub max_witness_len: u32,
|
|
64
|
+
pub input_serial_id: BigInt,
|
|
65
|
+
pub contract_id: Buffer,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Parameters for a party in the DLC - matches UDL exactly
|
|
69
|
+
#[napi(object)]
|
|
70
|
+
pub struct PartyParams {
|
|
71
|
+
pub fund_pubkey: Buffer,
|
|
72
|
+
pub change_script_pubkey: Buffer,
|
|
73
|
+
pub change_serial_id: BigInt,
|
|
74
|
+
pub payout_script_pubkey: Buffer,
|
|
75
|
+
pub payout_serial_id: BigInt,
|
|
76
|
+
pub inputs: Vec<TxInputInfo>,
|
|
77
|
+
pub input_amount: BigInt,
|
|
78
|
+
pub collateral: BigInt,
|
|
79
|
+
pub dlc_inputs: Vec<DlcInputInfo>,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Container for all DLC transactions - matches UDL exactly
|
|
83
|
+
#[napi(object)]
|
|
84
|
+
pub struct DlcTransactions {
|
|
85
|
+
pub fund: Transaction,
|
|
86
|
+
pub cets: Vec<Transaction>,
|
|
87
|
+
pub refund: Transaction,
|
|
88
|
+
pub funding_script_pubkey: Buffer,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Adaptor signature with proof - matches UDL exactly
|
|
92
|
+
#[napi(object)]
|
|
93
|
+
pub struct AdaptorSignature {
|
|
94
|
+
pub signature: Buffer,
|
|
95
|
+
pub proof: Buffer,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Change output and fees result - matches UDL exactly
|
|
99
|
+
#[napi(object)]
|
|
100
|
+
pub struct ChangeOutputAndFees {
|
|
101
|
+
pub change_output: TxOutput,
|
|
102
|
+
pub fund_fee: BigInt,
|
|
103
|
+
pub cet_fee: BigInt,
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Oracle information - matches UDL exactly
|
|
107
|
+
#[napi(object)]
|
|
108
|
+
pub struct OracleInfo {
|
|
109
|
+
pub public_key: Buffer,
|
|
110
|
+
pub nonces: Vec<Buffer>,
|
|
111
|
+
}
|