Skip to content

Commit 496949c

Browse files
committed
Detect nullable LDKOutpoint values
1 parent 3430eb6 commit 496949c

16 files changed

+170
-36
lines changed

bindings/LDK/options/MonitorEvent.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,16 @@ public class MonitorEvent: NativeTypeWrapper {
5353
if self.cOpaqueStruct?.tag != LDKMonitorEvent_CommitmentTxBroadcasted {
5454
return nil
5555
}
56-
return OutPoint(pointer: self.cOpaqueStruct!.commitment_tx_broadcasted, anchor: self)
56+
return
57+
{ () in
58+
let cStruct =
59+
self.cOpaqueStruct!.commitment_tx_broadcasted;
60+
if cStruct.inner == nil {
61+
return nil
62+
}
63+
return OutPoint(pointer: cStruct, anchor: self)
64+
}()
65+
5766
}
5867

5968

bindings/LDK/options/SpendableOutputDescriptor.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,17 @@ SpendableOutputDescriptor_write(objPointer)
153153

154154

155155

156-
public func getOutpoint() -> OutPoint {
157-
return OutPoint(pointer: self.cOpaqueStruct!.outpoint, anchor: self)
156+
public func getOutpoint() -> OutPoint? {
157+
return
158+
{ () in
159+
let cStruct =
160+
self.cOpaqueStruct!.outpoint;
161+
if cStruct.inner == nil {
162+
return nil
163+
}
164+
return OutPoint(pointer: cStruct, anchor: self)
165+
}()
166+
158167
}
159168

160169
public func getOutput() -> TxOut {

bindings/LDK/results/Result_OutPointDecodeErrorZ.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,16 @@ public class Result_OutPointDecodeErrorZ: NativeTypeWrapper {
4747

4848
public func getValue() -> OutPoint? {
4949
if self.cOpaqueStruct?.result_ok == true {
50-
return OutPoint(pointer: self.cOpaqueStruct!.contents.result.pointee, anchor: self)
50+
return
51+
{ () in
52+
let cStruct =
53+
self.cOpaqueStruct!.contents.result.pointee;
54+
if cStruct.inner == nil {
55+
return nil
56+
}
57+
return OutPoint(pointer: cStruct, anchor: self)
58+
}()
59+
5160
}
5261
return nil
5362
}

bindings/LDK/structs/ChannelDetails.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,20 @@ ChannelDetails_get_counterparty(this_ptrPointer)
6464
return ChannelDetails_set_counterparty(this_ptrPointer, val.danglingClone().cOpaqueStruct!);
6565
}
6666

67-
public func get_funding_txo() -> OutPoint {
67+
public func get_funding_txo() -> OutPoint? {
6868

69-
return OutPoint(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKChannelDetails>) in
69+
return
70+
{ () in
71+
let cStruct =
72+
withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKChannelDetails>) in
7073
ChannelDetails_get_funding_txo(this_ptrPointer)
71-
});
74+
};
75+
if cStruct.inner == nil {
76+
return nil
77+
}
78+
return OutPoint(pointer: cStruct)
79+
}()
80+
;
7281
}
7382

7483
public func set_funding_txo(val: OutPoint) -> Void {

bindings/LDK/structs/ChannelTransactionParameters.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,20 @@ ChannelTransactionParameters_get_counterparty_parameters(this_ptrPointer)
9494
return ChannelTransactionParameters_set_counterparty_parameters(this_ptrPointer, val.danglingClone().cOpaqueStruct!);
9595
}
9696

97-
public func get_funding_outpoint() -> OutPoint {
97+
public func get_funding_outpoint() -> OutPoint? {
9898

99-
return OutPoint(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKChannelTransactionParameters>) in
99+
return
100+
{ () in
101+
let cStruct =
102+
withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKChannelTransactionParameters>) in
100103
ChannelTransactionParameters_get_funding_outpoint(this_ptrPointer)
101-
});
104+
};
105+
if cStruct.inner == nil {
106+
return nil
107+
}
108+
return OutPoint(pointer: cStruct)
109+
}()
110+
;
102111
}
103112

104113
public func set_funding_outpoint(val: OutPoint) -> Void {

bindings/LDK/structs/DelayedPaymentOutputDescriptor.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,20 @@ public class DelayedPaymentOutputDescriptor: NativeTypeWrapper {
3434

3535
/* STRUCT_METHODS_START */
3636

37-
public func get_outpoint() -> OutPoint {
37+
public func get_outpoint() -> OutPoint? {
3838

39-
return OutPoint(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKDelayedPaymentOutputDescriptor>) in
39+
return
40+
{ () in
41+
let cStruct =
42+
withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKDelayedPaymentOutputDescriptor>) in
4043
DelayedPaymentOutputDescriptor_get_outpoint(this_ptrPointer)
41-
});
44+
};
45+
if cStruct.inner == nil {
46+
return nil
47+
}
48+
return OutPoint(pointer: cStruct)
49+
}()
50+
;
4251
}
4352

4453
public func set_outpoint(val: OutPoint) -> Void {

bindings/LDK/structs/DirectedChannelTransactionParameters.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,20 @@ DirectedChannelTransactionParameters_is_outbound(this_argPointer)
5454
};
5555
}
5656

57-
public func funding_outpoint() -> OutPoint {
57+
public func funding_outpoint() -> OutPoint? {
5858

59-
return OutPoint(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKDirectedChannelTransactionParameters>) in
59+
return
60+
{ () in
61+
let cStruct =
62+
withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKDirectedChannelTransactionParameters>) in
6063
DirectedChannelTransactionParameters_funding_outpoint(this_argPointer)
61-
});
64+
};
65+
if cStruct.inner == nil {
66+
return nil
67+
}
68+
return OutPoint(pointer: cStruct)
69+
}()
70+
;
6271
}
6372

6473
internal func free() -> Void {

bindings/LDK/structs/InMemorySigner.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,20 @@ InMemorySigner_is_outbound(this_argPointer)
166166
};
167167
}
168168

169-
public func funding_outpoint() -> OutPoint {
169+
public func funding_outpoint() -> OutPoint? {
170170

171-
return OutPoint(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInMemorySigner>) in
171+
return
172+
{ () in
173+
let cStruct =
174+
withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKInMemorySigner>) in
172175
InMemorySigner_funding_outpoint(this_argPointer)
173-
});
176+
};
177+
if cStruct.inner == nil {
178+
return nil
179+
}
180+
return OutPoint(pointer: cStruct)
181+
}()
182+
;
174183
}
175184

176185
public func get_channel_parameters() -> ChannelTransactionParameters {

bindings/LDK/structs/StaticPaymentOutputDescriptor.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,20 @@ public class StaticPaymentOutputDescriptor: NativeTypeWrapper {
3434

3535
/* STRUCT_METHODS_START */
3636

37-
public func get_outpoint() -> OutPoint {
37+
public func get_outpoint() -> OutPoint? {
3838

39-
return OutPoint(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKStaticPaymentOutputDescriptor>) in
39+
return
40+
{ () in
41+
let cStruct =
42+
withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKStaticPaymentOutputDescriptor>) in
4043
StaticPaymentOutputDescriptor_get_outpoint(this_ptrPointer)
41-
});
44+
};
45+
if cStruct.inner == nil {
46+
return nil
47+
}
48+
return OutPoint(pointer: cStruct)
49+
}()
50+
;
4251
}
4352

4453
public func set_outpoint(val: OutPoint) -> Void {

bindings/LDK/structs/WatchedOutput.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,20 @@ WatchedOutput_get_block_hash(this_ptrPointer)
5454
return WatchedOutput_set_block_hash(this_ptrPointer, Bindings.new_LDKThirtyTwoBytes(array: val));
5555
}
5656

57-
public func get_outpoint() -> OutPoint {
57+
public func get_outpoint() -> OutPoint? {
5858

59-
return OutPoint(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKWatchedOutput>) in
59+
return
60+
{ () in
61+
let cStruct =
62+
withUnsafePointer(to: self.cOpaqueStruct!) { (this_ptrPointer: UnsafePointer<LDKWatchedOutput>) in
6063
WatchedOutput_get_outpoint(this_ptrPointer)
61-
});
64+
};
65+
if cStruct.inner == nil {
66+
return nil
67+
}
68+
return OutPoint(pointer: cStruct)
69+
}()
70+
;
6271
}
6372

6473
public func set_outpoint(val: OutPoint) -> Void {

0 commit comments

Comments
 (0)