Skip to content

Commit 31e213d

Browse files
committed
fix owned==true premature deallocation and make this_arg use instance values
1 parent 1cdb98d commit 31e213d

File tree

107 files changed

+19084
-749
lines changed

Some content is hidden

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

107 files changed

+19084
-749
lines changed

bindings/LDK/Bindings.swift

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

bindings/LDK/structs/AcceptChannel.swift

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ public class AcceptChannel {
1010

1111
/* STRUCT_METHODS_START */
1212

13-
public func get_temporary_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) {
13+
public func get_temporary_channel_id() -> [UInt8] {
1414

15-
return withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKAcceptChannel>) in
15+
return Bindings.tuple32_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKAcceptChannel>) in
1616
AcceptChannel_get_temporary_channel_id(this_ptrPointer)
17-
}.pointee;
17+
}.pointee);
1818
}
1919

2020
public func set_temporary_channel_id(val: [UInt8]) -> Void {
@@ -241,9 +241,13 @@ AcceptChannel_write(objPointer)
241241

242242

243243
deinit {
244+
if self.cOpaqueStruct?.is_owned == false {
245+
244246

245247

246248
AcceptChannel_free(self.cOpaqueStruct!)
249+
250+
}
247251

248252
}
249253

bindings/LDK/structs/AnnouncementSignatures.swift

+7-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ public class AnnouncementSignatures {
1515

1616
/* STRUCT_METHODS_START */
1717

18-
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) {
18+
public func get_channel_id() -> [UInt8] {
1919

20-
return withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKAnnouncementSignatures>) in
20+
return Bindings.tuple32_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKAnnouncementSignatures>) in
2121
AnnouncementSignatures_get_channel_id(this_ptrPointer)
22-
}.pointee;
22+
}.pointee);
2323
}
2424

2525
public func set_channel_id(val: [UInt8]) -> Void {
@@ -96,9 +96,13 @@ AnnouncementSignatures_write(objPointer)
9696

9797

9898
deinit {
99+
if self.cOpaqueStruct?.is_owned == false {
100+
99101

100102

101103
AnnouncementSignatures_free(self.cOpaqueStruct!)
104+
105+
}
102106

103107
}
104108

bindings/LDK/structs/BestBlock.swift

+8-4
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,29 @@ BestBlock(pointer: BestBlock_clone(origPointer))
2222
};
2323
}
2424

25-
public func block_hash(this_arg: BestBlock) -> [UInt8] {
25+
public func block_hash() -> [UInt8] {
2626

27-
return Bindings.LDKThirtyTwoBytes_to_array(nativeType: withUnsafePointer(to: this_arg.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKBestBlock>) in
27+
return Bindings.LDKThirtyTwoBytes_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKBestBlock>) in
2828
BestBlock_block_hash(this_argPointer)
2929
});
3030
}
3131

32-
public func height(this_arg: BestBlock) -> UInt32 {
32+
public func height() -> UInt32 {
3333

34-
return withUnsafePointer(to: this_arg.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKBestBlock>) in
34+
return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKBestBlock>) in
3535
BestBlock_height(this_argPointer)
3636
};
3737
}
3838

3939

4040
deinit {
41+
if self.cOpaqueStruct?.is_owned == false {
42+
4143

4244

4345
BestBlock_free(self.cOpaqueStruct!)
46+
47+
}
4448

4549
}
4650

bindings/LDK/structs/BuiltCommitmentTransaction.swift

+11-7
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ BuiltCommitmentTransaction_get_transaction(this_ptrPointer)
3030
return BuiltCommitmentTransaction_set_transaction(this_ptrPointer, Bindings.new_LDKTransaction(array: val));
3131
}
3232

33-
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) {
33+
public func get_txid() -> [UInt8] {
3434

35-
return withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
35+
return Bindings.tuple32_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
3636
BuiltCommitmentTransaction_get_txid(this_ptrPointer)
37-
}.pointee;
37+
}.pointee);
3838
}
3939

4040
public func set_txid(val: [UInt8]) -> Void {
@@ -64,16 +64,16 @@ BuiltCommitmentTransaction_write(objPointer)
6464
return Result_BuiltCommitmentTransactionDecodeErrorZ(pointer: BuiltCommitmentTransaction_read(Bindings.new_LDKu8slice(array: ser)));
6565
}
6666

67-
public func get_sighash_all(this_arg: BuiltCommitmentTransaction, funding_redeemscript: [UInt8], channel_value_satoshis: UInt64) -> [UInt8] {
67+
public func get_sighash_all(funding_redeemscript: [UInt8], channel_value_satoshis: UInt64) -> [UInt8] {
6868

69-
return Bindings.LDKThirtyTwoBytes_to_array(nativeType: withUnsafePointer(to: this_arg.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
69+
return Bindings.LDKThirtyTwoBytes_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
7070
BuiltCommitmentTransaction_get_sighash_all(this_argPointer, Bindings.new_LDKu8slice(array: funding_redeemscript), channel_value_satoshis)
7171
});
7272
}
7373

74-
public func sign(this_arg: BuiltCommitmentTransaction, funding_key: [UInt8], funding_redeemscript: [UInt8], channel_value_satoshis: UInt64) -> [UInt8] {
74+
public func sign(funding_key: [UInt8], funding_redeemscript: [UInt8], channel_value_satoshis: UInt64) -> [UInt8] {
7575

76-
return Bindings.LDKSignature_to_array(nativeType: withUnsafePointer(to: this_arg.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
76+
return Bindings.LDKSignature_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKBuiltCommitmentTransaction>) in
7777
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
7878
BuiltCommitmentTransaction_sign(this_argPointer, funding_keyPointer, Bindings.new_LDKu8slice(array: funding_redeemscript), channel_value_satoshis)
7979
}
@@ -82,9 +82,13 @@ BuiltCommitmentTransaction_sign(this_argPointer, funding_keyPointer, Bindings.ne
8282

8383

8484
deinit {
85+
if self.cOpaqueStruct?.is_owned == false {
86+
8587

8688

8789
BuiltCommitmentTransaction_free(self.cOpaqueStruct!)
90+
91+
}
8892

8993
}
9094

bindings/LDK/structs/ChainMonitor.swift

+12-8
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,43 @@ public class ChainMonitor {
1818

1919
/* STRUCT_METHODS_START */
2020

21-
public func as_Listen(this_arg: ChainMonitor) -> Listen {
21+
public func as_Listen() -> Listen {
2222

23-
return Listen(pointer: withUnsafePointer(to: this_arg.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChainMonitor>) in
23+
return Listen(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChainMonitor>) in
2424
ChainMonitor_as_Listen(this_argPointer)
2525
});
2626
}
2727

28-
public func as_Confirm(this_arg: ChainMonitor) -> Confirm {
28+
public func as_Confirm() -> Confirm {
2929

30-
return Confirm(pointer: withUnsafePointer(to: this_arg.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChainMonitor>) in
30+
return Confirm(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChainMonitor>) in
3131
ChainMonitor_as_Confirm(this_argPointer)
3232
});
3333
}
3434

35-
public func as_Watch(this_arg: ChainMonitor) -> Watch {
35+
public func as_Watch() -> Watch {
3636

37-
return Watch(pointer: withUnsafePointer(to: this_arg.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChainMonitor>) in
37+
return Watch(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChainMonitor>) in
3838
ChainMonitor_as_Watch(this_argPointer)
3939
});
4040
}
4141

42-
public func as_EventsProvider(this_arg: ChainMonitor) -> EventsProvider {
42+
public func as_EventsProvider() -> EventsProvider {
4343

44-
return EventsProvider(pointer: withUnsafePointer(to: this_arg.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChainMonitor>) in
44+
return EventsProvider(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKChainMonitor>) in
4545
ChainMonitor_as_EventsProvider(this_argPointer)
4646
});
4747
}
4848

4949

5050
deinit {
51+
if self.cOpaqueStruct?.is_owned == false {
52+
5153

5254

5355
ChainMonitor_free(self.cOpaqueStruct!)
56+
57+
}
5458

5559
}
5660

bindings/LDK/structs/ChainParameters.swift

+4
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,13 @@ ChainParameters_get_best_block(this_ptrPointer)
4747

4848

4949
deinit {
50+
if self.cOpaqueStruct?.is_owned == false {
51+
5052

5153

5254
ChainParameters_free(self.cOpaqueStruct!)
55+
56+
}
5357

5458
}
5559

bindings/LDK/structs/ChannelAnnouncement.swift

+4
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,13 @@ ChannelAnnouncement_write(objPointer)
111111

112112

113113
deinit {
114+
if self.cOpaqueStruct?.is_owned == false {
115+
114116

115117

116118
ChannelAnnouncement_free(self.cOpaqueStruct!)
119+
120+
}
117121

118122
}
119123

bindings/LDK/structs/ChannelConfig.swift

+4
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,13 @@ ChannelConfig_write(objPointer)
9696

9797

9898
deinit {
99+
if self.cOpaqueStruct?.is_owned == false {
100+
99101

100102

101103
ChannelConfig_free(self.cOpaqueStruct!)
104+
105+
}
102106

103107
}
104108

bindings/LDK/structs/ChannelDetails.swift

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ public class ChannelDetails {
1010

1111
/* STRUCT_METHODS_START */
1212

13-
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) {
13+
public func get_channel_id() -> [UInt8] {
1414

15-
return withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKChannelDetails>) in
15+
return Bindings.tuple32_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKChannelDetails>) in
1616
ChannelDetails_get_channel_id(this_ptrPointer)
17-
}.pointee;
17+
}.pointee);
1818
}
1919

2020
public func set_channel_id(val: [UInt8]) -> Void {
@@ -154,9 +154,13 @@ ChannelDetails(pointer: ChannelDetails_clone(origPointer))
154154

155155

156156
deinit {
157+
if self.cOpaqueStruct?.is_owned == false {
158+
157159

158160

159161
ChannelDetails_free(self.cOpaqueStruct!)
162+
163+
}
160164

161165
}
162166

bindings/LDK/structs/ChannelFeatures.swift

+4
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ ChannelFeatures_write(objPointer)
3636

3737

3838
deinit {
39+
if self.cOpaqueStruct?.is_owned == false {
40+
3941

4042

4143
ChannelFeatures_free(self.cOpaqueStruct!)
44+
45+
}
4246

4347
}
4448

bindings/LDK/structs/ChannelHandshakeConfig.swift

+4
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,13 @@ ChannelHandshakeConfig(pointer: ChannelHandshakeConfig_clone(origPointer))
6969

7070

7171
deinit {
72+
if self.cOpaqueStruct?.is_owned == false {
73+
7274

7375

7476
ChannelHandshakeConfig_free(self.cOpaqueStruct!)
77+
78+
}
7579

7680
}
7781

bindings/LDK/structs/ChannelHandshakeLimits.swift

+4
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,13 @@ ChannelHandshakeLimits(pointer: ChannelHandshakeLimits_clone(origPointer))
174174

175175

176176
deinit {
177+
if self.cOpaqueStruct?.is_owned == false {
178+
177179

178180

179181
ChannelHandshakeLimits_free(self.cOpaqueStruct!)
182+
183+
}
180184

181185
}
182186

bindings/LDK/structs/ChannelInfo.swift

+4
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,13 @@ ChannelInfo_write(objPointer)
141141

142142

143143
deinit {
144+
if self.cOpaqueStruct?.is_owned == false {
145+
144146

145147

146148
ChannelInfo_free(self.cOpaqueStruct!)
149+
150+
}
147151

148152
}
149153

0 commit comments

Comments
 (0)