Skip to content

Commit e4477d2

Browse files
committed
Update generated files for 0.0.115
1 parent b2333da commit e4477d2

File tree

106 files changed

+9291
-651
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

+9291
-651
lines changed

out/Bindings.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ return returnValue
10311031
/// [`ChannelManager::list_usable_channels`] will never include such channels.
10321032
///
10331033
/// [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels
1034-
/// [`Event::PaymentPathFailed`]: crate::util::events::Event::PaymentPathFailed
1034+
/// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed
10351035
/// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
10361036
///
10371037
/// Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None

out/VersionDescriptor.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
extension Bindings {
77
public class func getLDKSwiftBindingsSerializationHash() -> String {
8-
return "4e8c574f7430b4e821f96c72b92afac96f4d156550f5a48f37368294157986bd"
8+
return "090938220b5365ba0727f9eb4420c0f4cc0d12d65a2810a014fa06e29e7d3ea7"
99
}
1010
public class func getLDKSwiftBindingsVersion() -> String {
11-
return "0.0.114-19-geb193641-dirty"
11+
return "0.0.114-22-gb2333da3-dirty"
1212
}
1313
public class func getLDKSwiftBindingsCommitHash() -> String {
14-
return "eb193641b9e7ace910c8a0f20c330230f00ec6dd"
14+
return "b2333da3e5d0122faa70102c6e228ee2ade21c71"
1515
}
1616
}
1717

out/enums/complex/ClosureReason.swift

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,15 @@
183183
}
184184

185185
/// Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason
186-
public class func initWithCounterpartyForceClosed(peerMsg: String) -> ClosureReason {
186+
public class func initWithCounterpartyForceClosed(peerMsg: Bindings.UntrustedString) -> ClosureReason {
187187
// native call variable prep
188188

189-
let peerMsgPrimitiveWrapper = Str(value: peerMsg, instantiationContext: "ClosureReason.swift::\(#function):\(#line)").dangle()
190-
191189

192190
// native method call
193-
let nativeCallResult = ClosureReason_counterparty_force_closed(peerMsgPrimitiveWrapper.cType!)
191+
let nativeCallResult = ClosureReason_counterparty_force_closed(peerMsg.dynamicallyDangledClone().cType!)
194192

195193
// cleanup
196194

197-
// for elided types, we need this
198-
peerMsgPrimitiveWrapper.noOpRetain()
199-
200195

201196

202197
// return value (do some wrapping)
@@ -527,12 +522,14 @@
527522

528523
/// The error which the peer sent us.
529524
///
530-
/// The string should be sanitized before it is used (e.g emitted to logs
531-
/// or printed to stdout). Otherwise, a well crafted error message may exploit
525+
/// Be careful about printing the peer_msg, a well-crafted message could exploit
532526
/// a security vulnerability in the terminal emulator or the logging subsystem.
533-
public func getPeerMsg() -> String {
527+
/// To be safe, use `Display` on `UntrustedString`
528+
///
529+
/// [`UntrustedString`]: crate::util::string::UntrustedString
530+
public func getPeerMsg() -> Bindings.UntrustedString {
534531
// return value (do some wrapping)
535-
let returnValue = Str(cType: self.cType!.peer_msg, instantiationContext: "ClosureReason.swift::\(#function):\(#line)", anchor: self).getValue()
532+
let returnValue = Bindings.UntrustedString(cType: self.cType!.peer_msg, instantiationContext: "ClosureReason.swift::\(#function):\(#line)", anchor: self)
536533

537534
return returnValue;
538535
}

out/enums/complex/Event.swift

Lines changed: 263 additions & 62 deletions
Large diffs are not rendered by default.

out/enums/complex/Fallback.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
public class func initWithSegWitProgram(version: UInt8, program: [UInt8]) -> Fallback {
136136
// native call variable prep
137137

138-
let versionPrimitiveWrapper = U5(value: version, instantiationContext: "Fallback.swift::\(#function):\(#line)")
138+
let versionPrimitiveWrapper = WitnessVersion(value: version, instantiationContext: "Fallback.swift::\(#function):\(#line)")
139139

140140
let programVector = Vec_u8Z(array: program, instantiationContext: "Fallback.swift::\(#function):\(#line)").dangle()
141141

@@ -207,7 +207,7 @@
207207
return returnValue
208208
}
209209

210-
/// Checks if two Fallbacks contain equal inner contents.
210+
/// Generates a non-cryptographic 64-bit hash of the Fallback.
211211
public func hash() -> UInt64 {
212212
// native call variable prep
213213

@@ -375,7 +375,7 @@
375375
///
376376
public func getVersion() -> UInt8 {
377377
// return value (do some wrapping)
378-
let returnValue = U5(cType: self.cType!.version, instantiationContext: "Fallback.swift::\(#function):\(#line)", anchor: self).getValue()
378+
let returnValue = WitnessVersion(cType: self.cType!.version, instantiationContext: "Fallback.swift::\(#function):\(#line)", anchor: self).getValue()
379379

380380
return returnValue;
381381
}

out/enums/complex/HTLCDestination.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,11 @@
7575
///
7676
/// Some of the reasons may include:
7777
/// * HTLC Timeouts
78-
/// * Expected MPP amount to claim does not equal HTLC total
79-
/// * Claimable amount does not match expected amount
78+
/// * Excess HTLCs for a payment that we have already fully received, over-paying for the
79+
/// payment,
80+
/// * The counterparty node modified the HTLC in transit,
81+
/// * A probing attack where an intermediary node is trying to detect if we are the ultimate
82+
/// recipient for a payment.
8083
case FailedPayment
8184

8285
}

out/enums/complex/Hints.swift

Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
2+
#if SWIFT_PACKAGE
3+
import LDKHeaders
4+
#endif
5+
6+
import Foundation
7+
8+
///
9+
public typealias Hints = Bindings.Hints
10+
11+
extension Bindings {
12+
13+
/// Routing hints for the tail of the route.
14+
public class Hints: NativeTypeWrapper {
15+
16+
17+
/// Set to false to suppress an individual type's deinit log statements.
18+
/// Only applicable when log threshold is set to `.Debug`.
19+
public static var enableDeinitLogging = true
20+
21+
/// Set to true to suspend the freeing of this type's associated Rust memory.
22+
/// Should only ever be used for debugging purposes, and will likely be
23+
/// deprecated soon.
24+
public static var suspendFreedom = false
25+
26+
private static var instanceCounter: UInt = 0
27+
internal let instanceNumber: UInt
28+
29+
internal var cType: LDKHints?
30+
31+
internal init(cType: LDKHints, instantiationContext: String) {
32+
Self.instanceCounter += 1
33+
self.instanceNumber = Self.instanceCounter
34+
self.cType = cType
35+
36+
super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext)
37+
}
38+
39+
internal init(cType: LDKHints, instantiationContext: String, anchor: NativeTypeWrapper) {
40+
Self.instanceCounter += 1
41+
self.instanceNumber = Self.instanceCounter
42+
self.cType = cType
43+
44+
super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext)
45+
self.dangling = true
46+
try! self.addAnchor(anchor: anchor)
47+
}
48+
49+
internal init(cType: LDKHints, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false) {
50+
Self.instanceCounter += 1
51+
self.instanceNumber = Self.instanceCounter
52+
self.cType = cType
53+
54+
super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext)
55+
self.dangling = dangle
56+
try! self.addAnchor(anchor: anchor)
57+
}
58+
59+
60+
public enum HintsType {
61+
62+
/// The recipient provided blinded paths and payinfo to reach them. The blinded paths themselves
63+
/// will be included in the final [`Route`].
64+
case Blinded
65+
66+
/// The recipient included these route hints in their BOLT11 invoice.
67+
case Clear
68+
69+
}
70+
71+
public func getValueType() -> HintsType {
72+
switch self.cType!.tag {
73+
case LDKHints_Blinded:
74+
return .Blinded
75+
76+
case LDKHints_Clear:
77+
return .Clear
78+
79+
default:
80+
Bindings.print("Error: Invalid value type for Hints! Aborting.", severity: .ERROR)
81+
abort()
82+
}
83+
84+
}
85+
86+
87+
/// Frees any resources used by the Hints
88+
internal func free() {
89+
// native call variable prep
90+
91+
92+
// native method call
93+
let nativeCallResult = Hints_free(self.cType!)
94+
95+
// cleanup
96+
97+
98+
99+
// return value (do some wrapping)
100+
let returnValue = nativeCallResult
101+
102+
103+
return returnValue
104+
}
105+
106+
/// Creates a copy of the Hints
107+
internal func clone() -> Hints {
108+
// native call variable prep
109+
110+
111+
// native method call
112+
let nativeCallResult =
113+
withUnsafePointer(to: self.cType!) { (origPointer: UnsafePointer<LDKHints>) in
114+
Hints_clone(origPointer)
115+
}
116+
117+
118+
// cleanup
119+
120+
121+
122+
// return value (do some wrapping)
123+
let returnValue = Hints(cType: nativeCallResult, instantiationContext: "Hints.swift::\(#function):\(#line)")
124+
125+
126+
return returnValue
127+
}
128+
129+
/// Utility method to constructs a new Blinded-variant Hints
130+
public class func initWithBlinded(a: [(BlindedPayInfo, BlindedPath)]) -> Hints {
131+
// native call variable prep
132+
133+
let aVector = Vec_C2Tuple_BlindedPayInfoBlindedPathZZ(array: a, instantiationContext: "Hints.swift::\(#function):\(#line)").dangle()
134+
135+
136+
// native method call
137+
let nativeCallResult = Hints_blinded(aVector.cType!)
138+
139+
// cleanup
140+
141+
// aVector.noOpRetain()
142+
143+
144+
145+
// return value (do some wrapping)
146+
let returnValue = Hints(cType: nativeCallResult, instantiationContext: "Hints.swift::\(#function):\(#line)")
147+
148+
149+
return returnValue
150+
}
151+
152+
/// Utility method to constructs a new Clear-variant Hints
153+
public class func initWithClear(a: [RouteHint]) -> Hints {
154+
// native call variable prep
155+
156+
let aVector = Vec_RouteHintZ(array: a, instantiationContext: "Hints.swift::\(#function):\(#line)").dangle()
157+
158+
159+
// native method call
160+
let nativeCallResult = Hints_clear(aVector.cType!)
161+
162+
// cleanup
163+
164+
// aVector.noOpRetain()
165+
166+
167+
168+
// return value (do some wrapping)
169+
let returnValue = Hints(cType: nativeCallResult, instantiationContext: "Hints.swift::\(#function):\(#line)")
170+
171+
172+
return returnValue
173+
}
174+
175+
/// Generates a non-cryptographic 64-bit hash of the Hints.
176+
public func hash() -> UInt64 {
177+
// native call variable prep
178+
179+
180+
// native method call
181+
let nativeCallResult =
182+
withUnsafePointer(to: self.cType!) { (oPointer: UnsafePointer<LDKHints>) in
183+
Hints_hash(oPointer)
184+
}
185+
186+
187+
// cleanup
188+
189+
190+
191+
// return value (do some wrapping)
192+
let returnValue = nativeCallResult
193+
194+
195+
return returnValue
196+
}
197+
198+
/// Checks if two Hintss contain equal inner contents.
199+
/// This ignores pointers and is_owned flags and looks at the values in fields.
200+
public class func eq(a: Hints, b: Hints) -> Bool {
201+
// native call variable prep
202+
203+
204+
// native method call
205+
let nativeCallResult =
206+
withUnsafePointer(to: a.cType!) { (aPointer: UnsafePointer<LDKHints>) in
207+
208+
withUnsafePointer(to: b.cType!) { (bPointer: UnsafePointer<LDKHints>) in
209+
Hints_eq(aPointer, bPointer)
210+
}
211+
212+
}
213+
214+
215+
// cleanup
216+
217+
218+
219+
// return value (do some wrapping)
220+
let returnValue = nativeCallResult
221+
222+
223+
return returnValue
224+
}
225+
226+
227+
228+
public func getValueAsBlinded() -> [(BlindedPayInfo, BlindedPath)]? {
229+
if self.cType?.tag != LDKHints_Blinded {
230+
return nil
231+
}
232+
233+
return Vec_C2Tuple_BlindedPayInfoBlindedPathZZ(cType: self.cType!.blinded, instantiationContext: "Hints.swift::\(#function):\(#line)", anchor: self).getValue()
234+
}
235+
236+
public func getValueAsClear() -> [RouteHint]? {
237+
if self.cType?.tag != LDKHints_Clear {
238+
return nil
239+
}
240+
241+
return Vec_RouteHintZ(cType: self.cType!.clear, instantiationContext: "Hints.swift::\(#function):\(#line)", anchor: self).getValue()
242+
}
243+
244+
245+
internal func dangle(_ shouldDangle: Bool = true) -> Hints {
246+
self.dangling = shouldDangle
247+
return self
248+
}
249+
250+
251+
internal func danglingClone() -> Hints {
252+
let dangledClone = self.clone()
253+
dangledClone.dangling = true
254+
return dangledClone
255+
}
256+
257+
deinit {
258+
if Bindings.suspendFreedom || Self.suspendFreedom {
259+
return
260+
}
261+
262+
if !self.dangling {
263+
if Self.enableDeinitLogging {
264+
Bindings.print("Freeing Hints \(self.instanceNumber). (Origin: \(self.instantiationContext))")
265+
}
266+
267+
self.free()
268+
} else if Self.enableDeinitLogging {
269+
Bindings.print("Not freeing Hints \(self.instanceNumber) due to dangle. (Origin: \(self.instantiationContext))")
270+
}
271+
}
272+
273+
274+
275+
276+
}
277+
278+
}
279+

out/enums/complex/NetworkUpdate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
case ChannelUpdateMessage
6868

6969
/// An error indicating that a channel failed to route a payment, which should be applied via
70-
/// [`NetworkGraph::channel_failed`].
70+
/// [`NetworkGraph::channel_failed_permanent`] if permanent.
7171
case ChannelFailure
7272

7373
/// An error indicating that a node failed to route a payment, which should be applied via

0 commit comments

Comments
 (0)