Skip to content

Commit 5da127e

Browse files
committed
fix premature deallocation in xcframework contexts
1 parent 9174e81 commit 5da127e

File tree

106 files changed

+4010
-7967
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+4010
-7967
lines changed

bindings/LDK/Bindings.swift

+303-303
Large diffs are not rendered by default.

bindings/LDK/structs/AcceptChannel.swift

+121-271
Large diffs are not rendered by default.

bindings/LDK/structs/AnnouncementSignatures.swift

+41-91
Original file line numberDiff line numberDiff line change
@@ -19,127 +19,77 @@ public class AnnouncementSignatures {
1919
/* STRUCT_METHODS_START */
2020

2121
public func get_channel_id() -> (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) {
22-
23-
24-
let this_ptrPointer = withUnsafePointer(to: self.cOpaqueStruct!) { (pointer: UnsafePointer<LDKAnnouncementSignatures>) in
25-
26-
pointer
27-
28-
}
29-
30-
return AnnouncementSignatures_get_channel_id(this_ptrPointer).pointee;
22+
/* NATIVE_CALL_PREP */
23+
return withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKAnnouncementSignatures>) in
24+
AnnouncementSignatures_get_channel_id(this_ptrPointer)
25+
}.pointee;
3126
}
3227

3328
public func set_channel_id(val: [UInt8]) -> Void {
34-
35-
36-
let this_ptrPointer = withUnsafeMutablePointer(to: &self.cOpaqueStruct!) { (pointer: UnsafeMutablePointer<LDKAnnouncementSignatures>) in
37-
38-
pointer
39-
40-
}
41-
42-
return AnnouncementSignatures_set_channel_id(this_ptrPointer, Bindings.new_LDKThirtyTwoBytes(array: val));
29+
/* NATIVE_CALL_PREP */
30+
return withUnsafeMutablePointer(to: &self.cOpaqueStruct!) { (this_ptrPointer: UnsafeMutablePointer<LDKAnnouncementSignatures>) in
31+
AnnouncementSignatures_set_channel_id(this_ptrPointer, Bindings.new_LDKThirtyTwoBytes(array: val))
32+
};
4333
}
4434

4535
public func get_short_channel_id() -> UInt64 {
46-
47-
48-
let this_ptrPointer = withUnsafePointer(to: self.cOpaqueStruct!) { (pointer: UnsafePointer<LDKAnnouncementSignatures>) in
49-
50-
pointer
51-
52-
}
53-
54-
return AnnouncementSignatures_get_short_channel_id(this_ptrPointer);
36+
/* NATIVE_CALL_PREP */
37+
return withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKAnnouncementSignatures>) in
38+
AnnouncementSignatures_get_short_channel_id(this_ptrPointer)
39+
};
5540
}
5641

5742
public func set_short_channel_id(val: UInt64) -> Void {
58-
59-
60-
let this_ptrPointer = withUnsafeMutablePointer(to: &self.cOpaqueStruct!) { (pointer: UnsafeMutablePointer<LDKAnnouncementSignatures>) in
61-
62-
pointer
63-
64-
}
65-
66-
return AnnouncementSignatures_set_short_channel_id(this_ptrPointer, val);
43+
/* NATIVE_CALL_PREP */
44+
return withUnsafeMutablePointer(to: &self.cOpaqueStruct!) { (this_ptrPointer: UnsafeMutablePointer<LDKAnnouncementSignatures>) in
45+
AnnouncementSignatures_set_short_channel_id(this_ptrPointer, val)
46+
};
6747
}
6848

6949
public func get_node_signature() -> [UInt8] {
70-
71-
72-
let this_ptrPointer = withUnsafePointer(to: self.cOpaqueStruct!) { (pointer: UnsafePointer<LDKAnnouncementSignatures>) in
73-
74-
pointer
75-
76-
}
77-
78-
return Bindings.LDKSignature_to_array(nativeType: AnnouncementSignatures_get_node_signature(this_ptrPointer));
50+
/* NATIVE_CALL_PREP */
51+
return Bindings.LDKSignature_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKAnnouncementSignatures>) in
52+
AnnouncementSignatures_get_node_signature(this_ptrPointer)
53+
});
7954
}
8055

8156
public func set_node_signature(val: [UInt8]) -> Void {
82-
83-
84-
let this_ptrPointer = withUnsafeMutablePointer(to: &self.cOpaqueStruct!) { (pointer: UnsafeMutablePointer<LDKAnnouncementSignatures>) in
85-
86-
pointer
87-
88-
}
89-
90-
return AnnouncementSignatures_set_node_signature(this_ptrPointer, Bindings.new_LDKSignature(array: val));
57+
/* NATIVE_CALL_PREP */
58+
return withUnsafeMutablePointer(to: &self.cOpaqueStruct!) { (this_ptrPointer: UnsafeMutablePointer<LDKAnnouncementSignatures>) in
59+
AnnouncementSignatures_set_node_signature(this_ptrPointer, Bindings.new_LDKSignature(array: val))
60+
};
9161
}
9262

9363
public func get_bitcoin_signature() -> [UInt8] {
94-
95-
96-
let this_ptrPointer = withUnsafePointer(to: self.cOpaqueStruct!) { (pointer: UnsafePointer<LDKAnnouncementSignatures>) in
97-
98-
pointer
99-
100-
}
101-
102-
return Bindings.LDKSignature_to_array(nativeType: AnnouncementSignatures_get_bitcoin_signature(this_ptrPointer));
64+
/* NATIVE_CALL_PREP */
65+
return Bindings.LDKSignature_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKAnnouncementSignatures>) in
66+
AnnouncementSignatures_get_bitcoin_signature(this_ptrPointer)
67+
});
10368
}
10469

10570
public func set_bitcoin_signature(val: [UInt8]) -> Void {
106-
107-
108-
let this_ptrPointer = withUnsafeMutablePointer(to: &self.cOpaqueStruct!) { (pointer: UnsafeMutablePointer<LDKAnnouncementSignatures>) in
109-
110-
pointer
111-
112-
}
113-
114-
return AnnouncementSignatures_set_bitcoin_signature(this_ptrPointer, Bindings.new_LDKSignature(array: val));
71+
/* NATIVE_CALL_PREP */
72+
return withUnsafeMutablePointer(to: &self.cOpaqueStruct!) { (this_ptrPointer: UnsafeMutablePointer<LDKAnnouncementSignatures>) in
73+
AnnouncementSignatures_set_bitcoin_signature(this_ptrPointer, Bindings.new_LDKSignature(array: val))
74+
};
11575
}
11676

11777
public func clone(orig: AnnouncementSignatures) -> AnnouncementSignatures {
118-
119-
120-
let origPointer = withUnsafePointer(to: orig.cOpaqueStruct!) { (pointer: UnsafePointer<LDKAnnouncementSignatures>) in
121-
122-
pointer
123-
124-
}
125-
126-
return AnnouncementSignatures(pointer: AnnouncementSignatures_clone(origPointer));
78+
/* NATIVE_CALL_PREP */
79+
return withUnsafePointer(to: orig.cOpaqueStruct!) { (origPointer: UnsafePointer<LDKAnnouncementSignatures>) in
80+
AnnouncementSignatures(pointer: AnnouncementSignatures_clone(origPointer))
81+
};
12782
}
12883

12984
public func write(obj: AnnouncementSignatures) -> [UInt8] {
130-
131-
132-
let objPointer = withUnsafePointer(to: obj.cOpaqueStruct!) { (pointer: UnsafePointer<LDKAnnouncementSignatures>) in
133-
134-
pointer
135-
136-
}
137-
138-
return Bindings.LDKCVec_u8Z_to_array(nativeType: AnnouncementSignatures_write(objPointer));
85+
/* NATIVE_CALL_PREP */
86+
return Bindings.LDKCVec_u8Z_to_array(nativeType: withUnsafePointer(to: obj.cOpaqueStruct!) { (objPointer: UnsafePointer<LDKAnnouncementSignatures>) in
87+
AnnouncementSignatures_write(objPointer)
88+
});
13989
}
14090

14191
public func read(ser: [UInt8]) -> Result_AnnouncementSignaturesDecodeErrorZ {
142-
92+
/* NATIVE_CALL_PREP */
14393
return Result_AnnouncementSignaturesDecodeErrorZ(pointer: AnnouncementSignatures_read(Bindings.new_LDKu8slice(array: ser)));
14494
}
14595

bindings/LDK/structs/BestBlock.swift

+12-27
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,24 @@ public class BestBlock {
1717
/* STRUCT_METHODS_START */
1818

1919
public func clone(orig: BestBlock) -> BestBlock {
20-
21-
22-
let origPointer = withUnsafePointer(to: orig.cOpaqueStruct!) { (pointer: UnsafePointer<LDKBestBlock>) in
23-
24-
pointer
25-
26-
}
27-
28-
return BestBlock(pointer: BestBlock_clone(origPointer));
20+
/* NATIVE_CALL_PREP */
21+
return withUnsafePointer(to: orig.cOpaqueStruct!) { (origPointer: UnsafePointer<LDKBestBlock>) in
22+
BestBlock(pointer: BestBlock_clone(origPointer))
23+
};
2924
}
3025

3126
public func block_hash(this_arg: BestBlock) -> [UInt8] {
32-
33-
34-
let this_argPointer = withUnsafePointer(to: this_arg.cOpaqueStruct!) { (pointer: UnsafePointer<LDKBestBlock>) in
35-
36-
pointer
37-
38-
}
39-
40-
return Bindings.LDKThirtyTwoBytes_to_array(nativeType: BestBlock_block_hash(this_argPointer));
27+
/* NATIVE_CALL_PREP */
28+
return Bindings.LDKThirtyTwoBytes_to_array(nativeType: withUnsafePointer(to: this_arg.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKBestBlock>) in
29+
BestBlock_block_hash(this_argPointer)
30+
});
4131
}
4232

4333
public func height(this_arg: BestBlock) -> UInt32 {
44-
45-
46-
let this_argPointer = withUnsafePointer(to: this_arg.cOpaqueStruct!) { (pointer: UnsafePointer<LDKBestBlock>) in
47-
48-
pointer
49-
50-
}
51-
52-
return BestBlock_height(this_argPointer);
34+
/* NATIVE_CALL_PREP */
35+
return withUnsafePointer(to: this_arg.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKBestBlock>) in
36+
BestBlock_height(this_argPointer)
37+
};
5338
}
5439

5540

bindings/LDK/structs/BuiltCommitmentTransaction.swift

+35-80
Original file line numberDiff line numberDiff line change
@@ -18,111 +18,66 @@ public class BuiltCommitmentTransaction {
1818
/* STRUCT_METHODS_START */
1919

2020
public func get_transaction() -> [UInt8] {
21-
22-
23-
let this_ptrPointer = withUnsafePointer(to: self.cOpaqueStruct!) { (pointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
24-
25-
pointer
26-
27-
}
28-
29-
return Bindings.LDKTransaction_to_array(nativeType: BuiltCommitmentTransaction_get_transaction(this_ptrPointer));
21+
/* NATIVE_CALL_PREP */
22+
return Bindings.LDKTransaction_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
23+
BuiltCommitmentTransaction_get_transaction(this_ptrPointer)
24+
});
3025
}
3126

3227
public func set_transaction(val: [UInt8]) -> Void {
33-
34-
35-
let this_ptrPointer = withUnsafeMutablePointer(to: &self.cOpaqueStruct!) { (pointer: UnsafeMutablePointer<LDKBuiltCommitmentTransaction>) in
36-
37-
pointer
38-
39-
}
40-
41-
return BuiltCommitmentTransaction_set_transaction(this_ptrPointer, Bindings.new_LDKTransaction(array: val));
28+
/* NATIVE_CALL_PREP */
29+
return withUnsafeMutablePointer(to: &self.cOpaqueStruct!) { (this_ptrPointer: UnsafeMutablePointer<LDKBuiltCommitmentTransaction>) in
30+
BuiltCommitmentTransaction_set_transaction(this_ptrPointer, Bindings.new_LDKTransaction(array: val))
31+
};
4232
}
4333

4434
public func get_txid() -> (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) {
45-
46-
47-
let this_ptrPointer = withUnsafePointer(to: self.cOpaqueStruct!) { (pointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
48-
49-
pointer
50-
51-
}
52-
53-
return BuiltCommitmentTransaction_get_txid(this_ptrPointer).pointee;
35+
/* NATIVE_CALL_PREP */
36+
return withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
37+
BuiltCommitmentTransaction_get_txid(this_ptrPointer)
38+
}.pointee;
5439
}
5540

5641
public func set_txid(val: [UInt8]) -> Void {
57-
58-
59-
let this_ptrPointer = withUnsafeMutablePointer(to: &self.cOpaqueStruct!) { (pointer: UnsafeMutablePointer<LDKBuiltCommitmentTransaction>) in
60-
61-
pointer
62-
63-
}
64-
65-
return BuiltCommitmentTransaction_set_txid(this_ptrPointer, Bindings.new_LDKThirtyTwoBytes(array: val));
42+
/* NATIVE_CALL_PREP */
43+
return withUnsafeMutablePointer(to: &self.cOpaqueStruct!) { (this_ptrPointer: UnsafeMutablePointer<LDKBuiltCommitmentTransaction>) in
44+
BuiltCommitmentTransaction_set_txid(this_ptrPointer, Bindings.new_LDKThirtyTwoBytes(array: val))
45+
};
6646
}
6747

6848
public func clone(orig: BuiltCommitmentTransaction) -> BuiltCommitmentTransaction {
69-
70-
71-
let origPointer = withUnsafePointer(to: orig.cOpaqueStruct!) { (pointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
72-
73-
pointer
74-
75-
}
76-
77-
return BuiltCommitmentTransaction(pointer: BuiltCommitmentTransaction_clone(origPointer));
49+
/* NATIVE_CALL_PREP */
50+
return withUnsafePointer(to: orig.cOpaqueStruct!) { (origPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
51+
BuiltCommitmentTransaction(pointer: BuiltCommitmentTransaction_clone(origPointer))
52+
};
7853
}
7954

8055
public func write(obj: BuiltCommitmentTransaction) -> [UInt8] {
81-
82-
83-
let objPointer = withUnsafePointer(to: obj.cOpaqueStruct!) { (pointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
84-
85-
pointer
86-
87-
}
88-
89-
return Bindings.LDKCVec_u8Z_to_array(nativeType: BuiltCommitmentTransaction_write(objPointer));
56+
/* NATIVE_CALL_PREP */
57+
return Bindings.LDKCVec_u8Z_to_array(nativeType: withUnsafePointer(to: obj.cOpaqueStruct!) { (objPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
58+
BuiltCommitmentTransaction_write(objPointer)
59+
});
9060
}
9161

9262
public func read(ser: [UInt8]) -> Result_BuiltCommitmentTransactionDecodeErrorZ {
93-
63+
/* NATIVE_CALL_PREP */
9464
return Result_BuiltCommitmentTransactionDecodeErrorZ(pointer: BuiltCommitmentTransaction_read(Bindings.new_LDKu8slice(array: ser)));
9565
}
9666

9767
public func get_sighash_all(this_arg: BuiltCommitmentTransaction, funding_redeemscript: [UInt8], channel_value_satoshis: UInt64) -> [UInt8] {
98-
99-
100-
let this_argPointer = withUnsafePointer(to: this_arg.cOpaqueStruct!) { (pointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
101-
102-
pointer
103-
104-
}
105-
106-
return Bindings.LDKThirtyTwoBytes_to_array(nativeType: BuiltCommitmentTransaction_get_sighash_all(this_argPointer, Bindings.new_LDKu8slice(array: funding_redeemscript), channel_value_satoshis));
68+
/* NATIVE_CALL_PREP */
69+
return Bindings.LDKThirtyTwoBytes_to_array(nativeType: withUnsafePointer(to: this_arg.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
70+
BuiltCommitmentTransaction_get_sighash_all(this_argPointer, Bindings.new_LDKu8slice(array: funding_redeemscript), channel_value_satoshis)
71+
});
10772
}
10873

10974
public func sign(this_arg: BuiltCommitmentTransaction, funding_key: [UInt8], funding_redeemscript: [UInt8], channel_value_satoshis: UInt64) -> [UInt8] {
110-
111-
112-
let this_argPointer = withUnsafePointer(to: this_arg.cOpaqueStruct!) { (pointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
113-
114-
pointer
115-
116-
}
117-
118-
119-
let funding_keyPointer = withUnsafePointer(to: Bindings.array_to_tuple32(array: funding_key)) { (pointer: 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
120-
121-
pointer
122-
123-
}
124-
125-
return Bindings.LDKSignature_to_array(nativeType: BuiltCommitmentTransaction_sign(this_argPointer, funding_keyPointer, Bindings.new_LDKu8slice(array: funding_redeemscript), channel_value_satoshis));
75+
/* NATIVE_CALL_PREP */
76+
return Bindings.LDKSignature_to_array(nativeType: withUnsafePointer(to: this_arg.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
77+
return 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
78+
BuiltCommitmentTransaction_sign(this_argPointer, funding_keyPointer, Bindings.new_LDKu8slice(array: funding_redeemscript), channel_value_satoshis)
79+
}
80+
});
12681
}
12782

12883

0 commit comments

Comments
 (0)