Initial checkin
[ldk-swift-linux] / LDKSwift / Sources / LDKSwift / structs / BuiltCommitmentTransaction.swift
1 import LDKCHeaders
2
3 public class BuiltCommitmentTransaction {
4
5     public internal(set) var cOpaqueStruct: LDKBuiltCommitmentTransaction?;
6
7         /* DEFAULT_CONSTRUCTOR_START */
8     public init(transaction_arg: [UInt8], txid_arg: [UInt8]) {
9         
10         self.cOpaqueStruct = BuiltCommitmentTransaction_new(Bindings.new_LDKTransaction(array: transaction_arg), Bindings.new_LDKThirtyTwoBytes(array: txid_arg))
11     }
12     /* DEFAULT_CONSTRUCTOR_END */
13
14     public init(pointer: LDKBuiltCommitmentTransaction){
15                 self.cOpaqueStruct = pointer
16         }
17
18     /* STRUCT_METHODS_START */
19
20     public func get_transaction() -> [UInt8] {
21         
22         return Bindings.LDKTransaction_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
23 BuiltCommitmentTransaction_get_transaction(this_ptrPointer)
24 });
25     }
26
27     public func set_transaction(val: [UInt8]) -> Void {
28         
29                                                         let this_ptrPointer = UnsafeMutablePointer<LDKBuiltCommitmentTransaction>.allocate(capacity: 1)
30                                                         this_ptrPointer.initialize(to: self.cOpaqueStruct!)
31                                                 
32         return BuiltCommitmentTransaction_set_transaction(this_ptrPointer, Bindings.new_LDKTransaction(array: val));
33     }
34
35     public func get_txid() -> [UInt8] {
36         
37         return Bindings.tuple32_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
38 BuiltCommitmentTransaction_get_txid(this_ptrPointer)
39 }.pointee);
40     }
41
42     public func set_txid(val: [UInt8]) -> Void {
43         
44                                                         let this_ptrPointer = UnsafeMutablePointer<LDKBuiltCommitmentTransaction>.allocate(capacity: 1)
45                                                         this_ptrPointer.initialize(to: self.cOpaqueStruct!)
46                                                 
47         return BuiltCommitmentTransaction_set_txid(this_ptrPointer, Bindings.new_LDKThirtyTwoBytes(array: val));
48     }
49
50     public func clone(orig: BuiltCommitmentTransaction) -> BuiltCommitmentTransaction {
51         
52         return withUnsafePointer(to: orig.cOpaqueStruct!) { (origPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
53 BuiltCommitmentTransaction(pointer: BuiltCommitmentTransaction_clone(origPointer))
54 };
55     }
56
57     public func write(obj: BuiltCommitmentTransaction) -> [UInt8] {
58         
59         return Bindings.LDKCVec_u8Z_to_array(nativeType: withUnsafePointer(to: obj.cOpaqueStruct!) { (objPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
60 BuiltCommitmentTransaction_write(objPointer)
61 });
62     }
63
64     public func read(ser: [UInt8]) -> Result_BuiltCommitmentTransactionDecodeErrorZ {
65         
66         return Result_BuiltCommitmentTransactionDecodeErrorZ(pointer: BuiltCommitmentTransaction_read(Bindings.new_LDKu8slice(array: ser)));
67     }
68
69     public func get_sighash_all(funding_redeemscript: [UInt8], channel_value_satoshis: UInt64) -> [UInt8] {
70         
71         return Bindings.LDKThirtyTwoBytes_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
72 BuiltCommitmentTransaction_get_sighash_all(this_argPointer, Bindings.new_LDKu8slice(array: funding_redeemscript), channel_value_satoshis)
73 });
74     }
75
76     public func sign(funding_key: [UInt8], funding_redeemscript: [UInt8], channel_value_satoshis: UInt64) -> [UInt8] {
77         
78         return Bindings.LDKSignature_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
79 withUnsafePointer(to: Bindings.array_to_tuple32(array: funding_key)) { (funding_keyPointer: UnsafePointer<(UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8)>) in
80 BuiltCommitmentTransaction_sign(this_argPointer, funding_keyPointer, Bindings.new_LDKu8slice(array: funding_redeemscript), channel_value_satoshis)
81 }
82 });
83     }
84
85                                 
86         deinit {
87                                         if self.cOpaqueStruct?.is_owned == false {
88
89                                         
90                                         
91                 BuiltCommitmentTransaction_free(self.cOpaqueStruct!)
92                                         
93 }
94                                 
95         }
96                         
97     /* STRUCT_METHODS_END */
98
99 }