Skip to content

Commit e1e1c09

Browse files
committed
Update to 0.0.14
1 parent f740a9b commit e1e1c09

Some content is hidden

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

42 files changed

+1907
-642
lines changed

bindings/LDK/Bindings.swift

Lines changed: 1410 additions & 157 deletions
Large diffs are not rendered by default.

bindings/LDK/options/ClosureReason.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ ClosureReason_clone(origPointer)
111111
return ClosureReason(pointer: ClosureReason_commitment_tx_confirmed());
112112
}
113113

114+
public class func funding_timed_out() -> ClosureReason {
115+
116+
return ClosureReason(pointer: ClosureReason_funding_timed_out());
117+
}
118+
114119
public class func processing_error(err: String) -> ClosureReason {
115120

116121
return ClosureReason(pointer: ClosureReason_processing_error(Bindings.new_LDKStr(string: err)));
@@ -133,6 +138,16 @@ ClosureReason_write(objPointer)
133138
});
134139
}
135140

141+
public class func read(ser: [UInt8]) -> Result_COption_ClosureReasonZDecodeErrorZ {
142+
143+
let serWrapper = Bindings.new_LDKu8sliceWrapper(array: ser)
144+
defer {
145+
serWrapper.noOpRetain()
146+
}
147+
148+
return Result_COption_ClosureReasonZDecodeErrorZ(pointer: ClosureReason_read(serWrapper.cOpaqueStruct!));
149+
}
150+
136151
/* OPTION_METHODS_END */
137152

138153

bindings/LDK/options/ErrorAction.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ ErrorAction_clone(origPointer)
115115
return ErrorAction(pointer: ErrorAction_ignore_and_log(a));
116116
}
117117

118+
public class func ignore_duplicate_gossip() -> ErrorAction {
119+
120+
return ErrorAction(pointer: ErrorAction_ignore_duplicate_gossip());
121+
}
122+
118123
public class func send_error_message(msg: ErrorMessage) -> ErrorAction {
119124

120125
return ErrorAction(pointer: ErrorAction_send_error_message(msg.danglingClone().cOpaqueStruct!));

bindings/LDK/options/Event.swift

Lines changed: 116 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class Event: NativeTypeWrapper {
2626
/* OPTION_METHODS_START */
2727

2828
public enum EventValueType {
29-
case FundingGenerationReady, PaymentReceived, PaymentSent, PaymentPathFailed, PendingHTLCsForwardable, SpendableOutputs, PaymentForwarded, ChannelClosed, DiscardFunding
29+
case FundingGenerationReady, PaymentReceived, PaymentSent, PaymentPathFailed, PaymentFailed, PendingHTLCsForwardable, SpendableOutputs, PaymentForwarded, ChannelClosed, DiscardFunding, PaymentPathSuccessful
3030
}
3131

3232
public func getValueType() -> EventValueType? {
@@ -40,6 +40,8 @@ public class Event: NativeTypeWrapper {
4040
return .PaymentSent
4141
case LDKEvent_PaymentPathFailed:
4242
return .PaymentPathFailed
43+
case LDKEvent_PaymentFailed:
44+
return .PaymentFailed
4345
case LDKEvent_PendingHTLCsForwardable:
4446
return .PendingHTLCsForwardable
4547
case LDKEvent_SpendableOutputs:
@@ -50,6 +52,8 @@ public class Event: NativeTypeWrapper {
5052
return .ChannelClosed
5153
case LDKEvent_DiscardFunding:
5254
return .DiscardFunding
55+
case LDKEvent_PaymentPathSuccessful:
56+
return .PaymentPathSuccessful
5357
default:
5458
return nil
5559
}
@@ -84,6 +88,13 @@ public class Event: NativeTypeWrapper {
8488
return PaymentPathFailed(pointer: self.cOpaqueStruct!.payment_path_failed, anchor: self)
8589
}
8690

91+
public func getValueAsPaymentFailed() -> PaymentFailed? {
92+
if self.cOpaqueStruct?.tag != LDKEvent_PaymentFailed {
93+
return nil
94+
}
95+
return PaymentFailed(pointer: self.cOpaqueStruct!.payment_failed, anchor: self)
96+
}
97+
8798
public func getValueAsPendingHTLCsForwardable() -> PendingHTLCsForwardable? {
8899
if self.cOpaqueStruct?.tag != LDKEvent_PendingHTLCsForwardable {
89100
return nil
@@ -119,6 +130,13 @@ public class Event: NativeTypeWrapper {
119130
return DiscardFunding(pointer: self.cOpaqueStruct!.discard_funding, anchor: self)
120131
}
121132

133+
public func getValueAsPaymentPathSuccessful() -> PaymentPathSuccessful? {
134+
if self.cOpaqueStruct?.tag != LDKEvent_PaymentPathSuccessful {
135+
return nil
136+
}
137+
return PaymentPathSuccessful(pointer: self.cOpaqueStruct!.payment_path_successful, anchor: self)
138+
}
139+
122140

123141
internal func free() -> Void {
124142

@@ -189,6 +207,11 @@ Event_clone(origPointer)
189207
return Event(pointer: Event_payment_path_failed(Bindings.new_LDKThirtyTwoBytes(array: payment_id), Bindings.new_LDKThirtyTwoBytes(array: payment_hash), rejected_by_dest, network_update.danglingClone().cOpaqueStruct!, all_paths_failed, pathWrapper.dangle().cOpaqueStruct!, short_channel_id.danglingClone().cOpaqueStruct!, retry.danglingClone().cOpaqueStruct!));
190208
}
191209

210+
public class func payment_failed(payment_id: [UInt8], payment_hash: [UInt8]) -> Event {
211+
212+
return Event(pointer: Event_payment_failed(Bindings.new_LDKThirtyTwoBytes(array: payment_id), Bindings.new_LDKThirtyTwoBytes(array: payment_hash)));
213+
}
214+
192215
public class func pending_htlcs_forwardable(time_forwardable: UInt64) -> Event {
193216

194217
return Event(pointer: Event_pending_htlcs_forwardable(time_forwardable));
@@ -229,13 +252,38 @@ Event_clone(origPointer)
229252
return Event(pointer: Event_discard_funding(Bindings.new_LDKThirtyTwoBytes(array: channel_id), transactionWrapper.dangle().cOpaqueStruct!));
230253
}
231254

255+
public class func payment_path_successful(payment_id: [UInt8], payment_hash: [UInt8], path: [RouteHop]) -> Event {
256+
257+
let pathUnwrapped = path.map { (pathCurrentValue) in
258+
pathCurrentValue
259+
.danglingClone().cOpaqueStruct!
260+
}
261+
262+
let pathWrapper = Bindings.new_LDKCVec_RouteHopZWrapper(array: pathUnwrapped)
263+
defer {
264+
pathWrapper.noOpRetain()
265+
}
266+
267+
return Event(pointer: Event_payment_path_successful(Bindings.new_LDKThirtyTwoBytes(array: payment_id), Bindings.new_LDKThirtyTwoBytes(array: payment_hash), pathWrapper.dangle().cOpaqueStruct!));
268+
}
269+
232270
public func write() -> [UInt8] {
233271

234272
return Bindings.LDKCVec_u8Z_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (objPointer: UnsafePointer<LDKEvent>) in
235273
Event_write(objPointer)
236274
});
237275
}
238276

277+
public class func read(ser: [UInt8]) -> Result_COption_EventZDecodeErrorZ {
278+
279+
let serWrapper = Bindings.new_LDKu8sliceWrapper(array: ser)
280+
defer {
281+
serWrapper.noOpRetain()
282+
}
283+
284+
return Result_COption_EventZDecodeErrorZ(pointer: Event_read(serWrapper.cOpaqueStruct!));
285+
}
286+
239287
/* OPTION_METHODS_END */
240288

241289

@@ -405,6 +453,35 @@ Event_write(objPointer)
405453
}
406454

407455

456+
public class PaymentFailed: NativeTypeWrapper {
457+
458+
459+
var cOpaqueStruct: LDKEvent_LDKPaymentFailed_Body?;
460+
fileprivate init(pointer: LDKEvent_LDKPaymentFailed_Body) {
461+
self.cOpaqueStruct = pointer
462+
super.init(conflictAvoidingVariableName: 0)
463+
}
464+
fileprivate init(pointer: LDKEvent_LDKPaymentFailed_Body, anchor: NativeTypeWrapper) {
465+
self.cOpaqueStruct = pointer
466+
super.init(conflictAvoidingVariableName: 0)
467+
self.dangling = true
468+
try! self.addAnchor(anchor: anchor)
469+
}
470+
471+
472+
473+
public func getPayment_id() -> [UInt8] {
474+
return Bindings.LDKThirtyTwoBytes_to_array(nativeType: self.cOpaqueStruct!.payment_id)
475+
}
476+
477+
public func getPayment_hash() -> [UInt8] {
478+
return Bindings.LDKThirtyTwoBytes_to_array(nativeType: self.cOpaqueStruct!.payment_hash)
479+
}
480+
481+
482+
}
483+
484+
408485
public class PendingHTLCsForwardable: NativeTypeWrapper {
409486

410487

@@ -550,4 +627,42 @@ Event_write(objPointer)
550627

551628
}
552629

630+
631+
public class PaymentPathSuccessful: NativeTypeWrapper {
632+
633+
634+
var cOpaqueStruct: LDKEvent_LDKPaymentPathSuccessful_Body?;
635+
fileprivate init(pointer: LDKEvent_LDKPaymentPathSuccessful_Body) {
636+
self.cOpaqueStruct = pointer
637+
super.init(conflictAvoidingVariableName: 0)
638+
}
639+
fileprivate init(pointer: LDKEvent_LDKPaymentPathSuccessful_Body, anchor: NativeTypeWrapper) {
640+
self.cOpaqueStruct = pointer
641+
super.init(conflictAvoidingVariableName: 0)
642+
self.dangling = true
643+
try! self.addAnchor(anchor: anchor)
644+
}
645+
646+
647+
648+
public func getPayment_id() -> [UInt8] {
649+
return Bindings.LDKThirtyTwoBytes_to_array(nativeType: self.cOpaqueStruct!.payment_id)
650+
}
651+
652+
public func getPayment_hash() -> [UInt8] {
653+
return Bindings.LDKThirtyTwoBytes_to_array(nativeType: self.cOpaqueStruct!.payment_hash)
654+
}
655+
656+
public func getPath() -> [RouteHop] {
657+
return Bindings.LDKCVec_RouteHopZ_to_array(nativeType: self.cOpaqueStruct!.path, deallocate: false)
658+
659+
.map { (cOpaqueStruct) in
660+
RouteHop(pointer: cOpaqueStruct).dangle()
661+
}
662+
663+
}
664+
665+
666+
}
667+
553668
}

bindings/LDK/options/MonitorEvent.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,16 @@ MonitorEvent_write(objPointer)
154154
});
155155
}
156156

157+
public class func read(ser: [UInt8]) -> Result_COption_MonitorEventZDecodeErrorZ {
158+
159+
let serWrapper = Bindings.new_LDKu8sliceWrapper(array: ser)
160+
defer {
161+
serWrapper.noOpRetain()
162+
}
163+
164+
return Result_COption_MonitorEventZDecodeErrorZ(pointer: MonitorEvent_read(serWrapper.cOpaqueStruct!));
165+
}
166+
157167
/* OPTION_METHODS_END */
158168

159169

bindings/LDK/options/NetAddress.swift

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ public class NetAddress: NativeTypeWrapper {
6060
return IPv6(pointer: self.cOpaqueStruct!.i_pv6, anchor: self)
6161
}
6262

63-
public func getValueAsOnionV2() -> OnionV2? {
63+
public func getValueAsOnionV2() -> [UInt8]? {
6464
if self.cOpaqueStruct?.tag != LDKNetAddress_OnionV2 {
6565
return nil
6666
}
67-
return OnionV2(pointer: self.cOpaqueStruct!.onion_v2, anchor: self)
67+
return Bindings.LDKTwelveBytes_to_array(nativeType: self.cOpaqueStruct!.onion_v2)
6868
}
6969

7070
public func getValueAsOnionV3() -> OnionV3? {
@@ -119,9 +119,9 @@ NetAddress_clone(origPointer)
119119
return NetAddress(pointer: NetAddress_ipv6(Bindings.new_LDKSixteenBytes(array: addr), port));
120120
}
121121

122-
public class func onion_v2(addr: [UInt8], port: UInt16) -> NetAddress {
122+
public class func onion_v2(a: [UInt8]) -> NetAddress {
123123

124-
return NetAddress(pointer: NetAddress_onion_v2(Bindings.new_LDKTenBytes(array: addr), port));
124+
return NetAddress(pointer: NetAddress_onion_v2(Bindings.new_LDKTwelveBytes(array: a)));
125125
}
126126

127127
public class func onion_v3(ed25519_pubkey: [UInt8], checksum: UInt16, version: UInt8, port: UInt16) -> NetAddress {
@@ -208,35 +208,6 @@ NetAddress_write(objPointer)
208208
}
209209

210210

211-
public class OnionV2: NativeTypeWrapper {
212-
213-
214-
var cOpaqueStruct: LDKNetAddress_LDKOnionV2_Body?;
215-
fileprivate init(pointer: LDKNetAddress_LDKOnionV2_Body) {
216-
self.cOpaqueStruct = pointer
217-
super.init(conflictAvoidingVariableName: 0)
218-
}
219-
fileprivate init(pointer: LDKNetAddress_LDKOnionV2_Body, anchor: NativeTypeWrapper) {
220-
self.cOpaqueStruct = pointer
221-
super.init(conflictAvoidingVariableName: 0)
222-
self.dangling = true
223-
try! self.addAnchor(anchor: anchor)
224-
}
225-
226-
227-
228-
public func getAddr() -> [UInt8] {
229-
return Bindings.LDKTenBytes_to_array(nativeType: self.cOpaqueStruct!.addr)
230-
}
231-
232-
public func getPort() -> UInt16 {
233-
return self.cOpaqueStruct!.port
234-
}
235-
236-
237-
}
238-
239-
240211
public class OnionV3: NativeTypeWrapper {
241212

242213

bindings/LDK/options/NetworkUpdate.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,16 @@ NetworkUpdate_write(objPointer)
122122
});
123123
}
124124

125+
public class func read(ser: [UInt8]) -> Result_COption_NetworkUpdateZDecodeErrorZ {
126+
127+
let serWrapper = Bindings.new_LDKu8sliceWrapper(array: ser)
128+
defer {
129+
serWrapper.noOpRetain()
130+
}
131+
132+
return Result_COption_NetworkUpdateZDecodeErrorZ(pointer: NetworkUpdate_read(serWrapper.cOpaqueStruct!));
133+
}
134+
125135
/* OPTION_METHODS_END */
126136

127137

bindings/LDK/options/Option_TypeZ.swift

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class Option_TypeZ: NativeTypeWrapper {
5959

6060
public class func some(o: Type) -> Option_TypeZ {
6161

62-
return Option_TypeZ(pointer: COption_TypeZ_some(o.danglingClone().cOpaqueStruct!));
62+
return Option_TypeZ(pointer: COption_TypeZ_some(o.cOpaqueStruct!));
6363
}
6464

6565
public class func none() -> Option_TypeZ {
@@ -87,20 +87,6 @@ public class Option_TypeZ: NativeTypeWrapper {
8787
}
8888

8989

90-
public func clone() -> Option_TypeZ {
91-
92-
return Option_TypeZ(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (origPointer: UnsafePointer<LDKCOption_TypeZ>) in
93-
COption_TypeZ_clone(origPointer)
94-
});
95-
}
96-
97-
internal func danglingClone() -> Option_TypeZ {
98-
let dangledClone = self.clone()
99-
dangledClone.dangling = true
100-
return dangledClone
101-
}
102-
103-
10490
/* OPTION_METHODS_END */
10591

10692
/* TYPE_CLASSES */

bindings/LDK/options/PaymentPurpose.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ PaymentPurpose_clone(origPointer)
9191
}
9292

9393

94-
public class func invoice_payment(payment_preimage: [UInt8], payment_secret: [UInt8], user_payment_id: UInt64) -> PaymentPurpose {
94+
public class func invoice_payment(payment_preimage: [UInt8], payment_secret: [UInt8]) -> PaymentPurpose {
9595

96-
return PaymentPurpose(pointer: PaymentPurpose_invoice_payment(Bindings.new_LDKThirtyTwoBytes(array: payment_preimage), Bindings.new_LDKThirtyTwoBytes(array: payment_secret), user_payment_id));
96+
return PaymentPurpose(pointer: PaymentPurpose_invoice_payment(Bindings.new_LDKThirtyTwoBytes(array: payment_preimage), Bindings.new_LDKThirtyTwoBytes(array: payment_secret)));
9797
}
9898

9999
public class func spontaneous_payment(a: [UInt8]) -> PaymentPurpose {
@@ -130,10 +130,6 @@ PaymentPurpose_clone(origPointer)
130130
return Bindings.LDKThirtyTwoBytes_to_array(nativeType: self.cOpaqueStruct!.payment_secret)
131131
}
132132

133-
public func getUser_payment_id() -> UInt64 {
134-
return self.cOpaqueStruct!.user_payment_id
135-
}
136-
137133

138134
}
139135

0 commit comments

Comments
 (0)