Skip to content

Commit 954b521

Browse files
committed
create LDKError workarounds for 0.0.106
1 parent 8e00d9a commit 954b521

37 files changed

+1337
-479
lines changed

bindings/LDK/Bindings.swift

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4973,16 +4973,6 @@ public class Bindings {
49734973

49744974
CResult_ScorerDecodeErrorZ_is_ok(oPointer)
49754975

4976-
}
4977-
4978-
}
4979-
public class func swift_CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok(o: Result_ProbabilisticScoringParametersDecodeErrorZ) -> Bool {
4980-
4981-
4982-
return withUnsafePointer(to: o.cOpaqueStruct!) { (oPointer: UnsafePointer<LDKCResult_ProbabilisticScoringParametersDecodeErrorZ>) in
4983-
4984-
CResult_ProbabilisticScoringParametersDecodeErrorZ_is_ok(oPointer)
4985-
49864976
}
49874977

49884978
}
@@ -5366,32 +5356,32 @@ public class Bindings {
53665356
}
53675357

53685358
}
5369-
public class func swift_CResult_SiPrefixNoneZ_is_ok(o: Result_SiPrefixNoneZ) -> Bool {
5359+
public class func swift_CResult_SiPrefixParseErrorZ_is_ok(o: Result_SiPrefixParseErrorZ) -> Bool {
53705360

53715361

5372-
return withUnsafePointer(to: o.cOpaqueStruct!) { (oPointer: UnsafePointer<LDKCResult_SiPrefixNoneZ>) in
5362+
return withUnsafePointer(to: o.cOpaqueStruct!) { (oPointer: UnsafePointer<LDKCResult_SiPrefixParseErrorZ>) in
53735363

5374-
CResult_SiPrefixNoneZ_is_ok(oPointer)
5364+
CResult_SiPrefixParseErrorZ_is_ok(oPointer)
53755365

53765366
}
53775367

53785368
}
5379-
public class func swift_CResult_InvoiceNoneZ_is_ok(o: Result_InvoiceNoneZ) -> Bool {
5369+
public class func swift_CResult_InvoiceParseOrSemanticErrorZ_is_ok(o: Result_InvoiceParseOrSemanticErrorZ) -> Bool {
53805370

53815371

5382-
return withUnsafePointer(to: o.cOpaqueStruct!) { (oPointer: UnsafePointer<LDKCResult_InvoiceNoneZ>) in
5372+
return withUnsafePointer(to: o.cOpaqueStruct!) { (oPointer: UnsafePointer<LDKCResult_InvoiceParseOrSemanticErrorZ>) in
53835373

5384-
CResult_InvoiceNoneZ_is_ok(oPointer)
5374+
CResult_InvoiceParseOrSemanticErrorZ_is_ok(oPointer)
53855375

53865376
}
53875377

53885378
}
5389-
public class func swift_CResult_SignedRawInvoiceNoneZ_is_ok(o: Result_SignedRawInvoiceNoneZ) -> Bool {
5379+
public class func swift_CResult_SignedRawInvoiceParseErrorZ_is_ok(o: Result_SignedRawInvoiceParseErrorZ) -> Bool {
53905380

53915381

5392-
return withUnsafePointer(to: o.cOpaqueStruct!) { (oPointer: UnsafePointer<LDKCResult_SignedRawInvoiceNoneZ>) in
5382+
return withUnsafePointer(to: o.cOpaqueStruct!) { (oPointer: UnsafePointer<LDKCResult_SignedRawInvoiceParseErrorZ>) in
53935383

5394-
CResult_SignedRawInvoiceNoneZ_is_ok(oPointer)
5384+
CResult_SignedRawInvoiceParseErrorZ_is_ok(oPointer)
53955385

53965386
}
53975387

@@ -6223,7 +6213,7 @@ withUnsafePointer(to: htlc.cOpaqueStruct!) { (htlcPointer: UnsafePointer<LDKHTLC
62236213

62246214

62256215
}
6226-
public class func swift_find_route(our_node_pubkey: [UInt8], route_params: RouteParameters, network: NetworkGraph, first_hops: [ChannelDetails]?, logger: Logger, scorer: Score) -> Result_RouteLightningErrorZ {
6216+
public class func swift_find_route(our_node_pubkey: [UInt8], route_params: RouteParameters, network: NetworkGraph, first_hops: [ChannelDetails]?, logger: Logger, scorer: Score, random_seed_bytes: [UInt8]) -> Result_RouteLightningErrorZ {
62276217

62286218

62296219
var first_hopsPointer: UnsafeMutablePointer<LDKCVec_ChannelDetailsZ>? = nil
@@ -6241,11 +6231,13 @@ withUnsafePointer(to: htlc.cOpaqueStruct!) { (htlcPointer: UnsafePointer<LDKHTLC
62416231
return withUnsafePointer(to: route_params.cOpaqueStruct!) { (route_paramsPointer: UnsafePointer<LDKRouteParameters>) in
62426232
withUnsafePointer(to: network.cOpaqueStruct!) { (networkPointer: UnsafePointer<LDKNetworkGraph>) in
62436233
withUnsafePointer(to: scorer.cOpaqueStruct!) { (scorerPointer: UnsafePointer<LDKScore>) in
6234+
withUnsafePointer(to: Bindings.array_to_tuple32(array: random_seed_bytes)) { (random_seed_bytesPointer: 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
62446235

6245-
Result_RouteLightningErrorZ(pointer: find_route(Bindings.new_LDKPublicKey(array: our_node_pubkey), route_paramsPointer, networkPointer, first_hopsPointer, logger.cOpaqueStruct!, scorerPointer))
6236+
Result_RouteLightningErrorZ(pointer: find_route(Bindings.new_LDKPublicKey(array: our_node_pubkey), route_paramsPointer, networkPointer, first_hopsPointer, logger.cOpaqueStruct!, scorerPointer, random_seed_bytesPointer))
62466237

62476238
}
62486239
}
6240+
}
62496241
}
62506242

62516243
}
@@ -6266,6 +6258,24 @@ withUnsafePointer(to: scorer.cOpaqueStruct!) { (scorerPointer: UnsafePointer<LDK
62666258
Result_InvoiceSignOrCreationErrorZ(pointer: create_phantom_invoice(amt_msat.danglingClone().cOpaqueStruct!, Bindings.new_LDKStr(string: description), Bindings.new_LDKThirtyTwoBytes(array: payment_hash), Bindings.new_LDKThirtyTwoBytes(array: payment_secret), phantom_route_hintsWrapper.dangle().cOpaqueStruct!, keys_manager.cOpaqueStruct!, network))
62676259

62686260

6261+
}
6262+
public class func swift_create_phantom_invoice_with_description_hash(amt_msat: Option_u64Z, description_hash: Sha256, payment_hash: [UInt8], payment_secret: [UInt8], phantom_route_hints: [PhantomRouteHints], keys_manager: KeysInterface, network: LDKCurrency) -> Result_InvoiceSignOrCreationErrorZ {
6263+
6264+
6265+
let phantom_route_hintsUnwrapped = phantom_route_hints.map { (phantom_route_hintsCurrentValue) in
6266+
phantom_route_hintsCurrentValue
6267+
.danglingClone().cOpaqueStruct!
6268+
}
6269+
6270+
let phantom_route_hintsWrapper = Bindings.new_LDKCVec_PhantomRouteHintsZWrapper(array: phantom_route_hintsUnwrapped)
6271+
defer {
6272+
phantom_route_hintsWrapper.noOpRetain()
6273+
}
6274+
6275+
return
6276+
Result_InvoiceSignOrCreationErrorZ(pointer: create_phantom_invoice_with_description_hash(amt_msat.danglingClone().cOpaqueStruct!, description_hash.danglingClone().cOpaqueStruct!, Bindings.new_LDKThirtyTwoBytes(array: payment_hash), Bindings.new_LDKThirtyTwoBytes(array: payment_secret), phantom_route_hintsWrapper.dangle().cOpaqueStruct!, keys_manager.cOpaqueStruct!, network))
6277+
6278+
62696279
}
62706280
public class func swift_create_invoice_from_channelmanager(channelmanager: ChannelManager, keys_manager: KeysInterface, network: LDKCurrency, amt_msat: Option_u64Z, description: String) -> Result_InvoiceSignOrCreationErrorZ {
62716281

@@ -6274,6 +6284,26 @@ withUnsafePointer(to: scorer.cOpaqueStruct!) { (scorerPointer: UnsafePointer<LDK
62746284

62756285
Result_InvoiceSignOrCreationErrorZ(pointer: create_invoice_from_channelmanager(channelmanagerPointer, keys_manager.cOpaqueStruct!, network, amt_msat.danglingClone().cOpaqueStruct!, Bindings.new_LDKStr(string: description)))
62766286

6287+
}
6288+
6289+
}
6290+
public class func swift_create_invoice_from_channelmanager_with_description_hash(channelmanager: ChannelManager, keys_manager: KeysInterface, network: LDKCurrency, amt_msat: Option_u64Z, description_hash: Sha256) -> Result_InvoiceSignOrCreationErrorZ {
6291+
6292+
6293+
return withUnsafePointer(to: channelmanager.cOpaqueStruct!) { (channelmanagerPointer: UnsafePointer<LDKChannelManager>) in
6294+
6295+
Result_InvoiceSignOrCreationErrorZ(pointer: create_invoice_from_channelmanager_with_description_hash(channelmanagerPointer, keys_manager.cOpaqueStruct!, network, amt_msat.danglingClone().cOpaqueStruct!, description_hash.danglingClone().cOpaqueStruct!))
6296+
6297+
}
6298+
6299+
}
6300+
public class func swift_create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager: ChannelManager, keys_manager: KeysInterface, network: LDKCurrency, amt_msat: Option_u64Z, description_hash: Sha256, duration_since_epoch: UInt64) -> Result_InvoiceSignOrCreationErrorZ {
6301+
6302+
6303+
return withUnsafePointer(to: channelmanager.cOpaqueStruct!) { (channelmanagerPointer: UnsafePointer<LDKChannelManager>) in
6304+
6305+
Result_InvoiceSignOrCreationErrorZ(pointer: create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanagerPointer, keys_manager.cOpaqueStruct!, network, amt_msat.danglingClone().cOpaqueStruct!, description_hash.danglingClone().cOpaqueStruct!, duration_since_epoch))
6306+
62776307
}
62786308

62796309
}
@@ -6460,7 +6490,7 @@ withUnsafePointer(to: scorer.cOpaqueStruct!) { (scorerPointer: UnsafePointer<LDK
64606490
*/
64616491

64626492
public class func get_ldk_swift_bindings_version() -> String {
6463-
return "a086cb7d66870a61b4c5b98ae5d293d840342ad0"
6493+
return "8e00d9af56a2d5df10febaa37026399f925b414b"
64646494
}
64656495

64666496
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
public class Bech32Error: NativeTypeWrapper {
2+
3+
private static var instanceCounter: UInt = 0
4+
internal let instanceNumber: UInt
5+
6+
internal var cOpaqueStruct: LDKBech32Error?
7+
8+
9+
10+
public init(pointer: LDKBech32Error){
11+
Self.instanceCounter += 1
12+
self.instanceNumber = Self.instanceCounter
13+
self.cOpaqueStruct = pointer
14+
super.init(conflictAvoidingVariableName: 0)
15+
}
16+
17+
public init(pointer: LDKBech32Error, anchor: NativeTypeWrapper){
18+
Self.instanceCounter += 1
19+
self.instanceNumber = Self.instanceCounter
20+
self.cOpaqueStruct = pointer
21+
super.init(conflictAvoidingVariableName: 0)
22+
self.dangling = true
23+
try! self.addAnchor(anchor: anchor)
24+
}
25+
26+
/* OPTION_METHODS_START */
27+
28+
public enum Bech32ErrorValueType {
29+
case InvalidChar, InvalidData
30+
}
31+
32+
public func getValueType() -> Bech32ErrorValueType? {
33+
switch self.cOpaqueStruct?.tag {
34+
35+
case LDKBech32Error_InvalidChar:
36+
return .InvalidChar
37+
case LDKBech32Error_InvalidData:
38+
return .InvalidData
39+
default:
40+
return nil
41+
}
42+
}
43+
44+
45+
public func getValueAsInvalidChar() -> UInt32? {
46+
if self.cOpaqueStruct?.tag != LDKBech32Error_InvalidChar {
47+
return nil
48+
}
49+
return self.cOpaqueStruct!.invalid_char
50+
}
51+
52+
public func getValueAsInvalidData() -> UInt8? {
53+
if self.cOpaqueStruct?.tag != LDKBech32Error_InvalidData {
54+
return nil
55+
}
56+
return self.cOpaqueStruct!.invalid_data
57+
}
58+
59+
60+
/* OPTION_METHODS_END */
61+
62+
/* TYPE_CLASSES */
63+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
public class BindingsError: NativeTypeWrapper {
2+
3+
private static var instanceCounter: UInt = 0
4+
internal let instanceNumber: UInt
5+
6+
internal var cOpaqueStruct: LDKError?
7+
8+
9+
10+
public init(pointer: LDKError){
11+
Self.instanceCounter += 1
12+
self.instanceNumber = Self.instanceCounter
13+
self.cOpaqueStruct = pointer
14+
super.init(conflictAvoidingVariableName: 0)
15+
}
16+
17+
public init(pointer: LDKError, anchor: NativeTypeWrapper){
18+
Self.instanceCounter += 1
19+
self.instanceNumber = Self.instanceCounter
20+
self.cOpaqueStruct = pointer
21+
super.init(conflictAvoidingVariableName: 0)
22+
self.dangling = true
23+
try! self.addAnchor(anchor: anchor)
24+
}
25+
26+
/* OPTION_METHODS_START */
27+
28+
/* OPTION_METHODS_END */
29+
30+
/* TYPE_CLASSES */
31+
}

bindings/LDK/options/Event.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,9 @@ Event_clone(origPointer)
276276
return Event(pointer: Event_payment_path_successful(Bindings.new_LDKThirtyTwoBytes(array: payment_id), Bindings.new_LDKThirtyTwoBytes(array: payment_hash), pathWrapper.dangle().cOpaqueStruct!));
277277
}
278278

279-
public class func open_channel_request(temporary_channel_id: [UInt8], counterparty_node_id: [UInt8], funding_satoshis: UInt64, push_msat: UInt64) -> Event {
279+
public class func open_channel_request(temporary_channel_id: [UInt8], counterparty_node_id: [UInt8], funding_satoshis: UInt64, push_msat: UInt64, channel_type: ChannelTypeFeatures) -> Event {
280280

281-
return Event(pointer: Event_open_channel_request(Bindings.new_LDKThirtyTwoBytes(array: temporary_channel_id), Bindings.new_LDKPublicKey(array: counterparty_node_id), funding_satoshis, push_msat));
281+
return Event(pointer: Event_open_channel_request(Bindings.new_LDKThirtyTwoBytes(array: temporary_channel_id), Bindings.new_LDKPublicKey(array: counterparty_node_id), funding_satoshis, push_msat, channel_type.danglingClone().cOpaqueStruct!));
282282
}
283283

284284
public func write() -> [UInt8] {
@@ -713,6 +713,10 @@ Event_write(objPointer)
713713
return self.cOpaqueStruct!.push_msat
714714
}
715715

716+
public func getChannel_type() -> ChannelTypeFeatures {
717+
return ChannelTypeFeatures(pointer: self.cOpaqueStruct!.channel_type, anchor: self)
718+
}
719+
716720

717721
}
718722

bindings/LDK/options/MessageSendEvent.swift

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

2828
public enum MessageSendEventValueType {
29-
case SendAcceptChannel, SendOpenChannel, SendFundingCreated, SendFundingSigned, SendFundingLocked, SendAnnouncementSignatures, UpdateHTLCs, SendRevokeAndACK, SendClosingSigned, SendShutdown, SendChannelReestablish, BroadcastChannelAnnouncement, BroadcastNodeAnnouncement, BroadcastChannelUpdate, SendChannelUpdate, HandleError, SendChannelRangeQuery, SendShortIdsQuery, SendReplyChannelRange
29+
case SendAcceptChannel, SendOpenChannel, SendFundingCreated, SendFundingSigned, SendFundingLocked, SendAnnouncementSignatures, UpdateHTLCs, SendRevokeAndACK, SendClosingSigned, SendShutdown, SendChannelReestablish, BroadcastChannelAnnouncement, BroadcastNodeAnnouncement, BroadcastChannelUpdate, SendChannelUpdate, HandleError, SendChannelRangeQuery, SendShortIdsQuery, SendReplyChannelRange, SendGossipTimestampFilter
3030
}
3131

3232
public func getValueType() -> MessageSendEventValueType? {
@@ -70,6 +70,8 @@ public class MessageSendEvent: NativeTypeWrapper {
7070
return .SendShortIdsQuery
7171
case LDKMessageSendEvent_SendReplyChannelRange:
7272
return .SendReplyChannelRange
73+
case LDKMessageSendEvent_SendGossipTimestampFilter:
74+
return .SendGossipTimestampFilter
7375
default:
7476
return nil
7577
}
@@ -209,6 +211,13 @@ public class MessageSendEvent: NativeTypeWrapper {
209211
return SendReplyChannelRange(pointer: self.cOpaqueStruct!.send_reply_channel_range, anchor: self)
210212
}
211213

214+
public func getValueAsSendGossipTimestampFilter() -> SendGossipTimestampFilter? {
215+
if self.cOpaqueStruct?.tag != LDKMessageSendEvent_SendGossipTimestampFilter {
216+
return nil
217+
}
218+
return SendGossipTimestampFilter(pointer: self.cOpaqueStruct!.send_gossip_timestamp_filter, anchor: self)
219+
}
220+
212221

213222
internal func free() -> Void {
214223

@@ -339,6 +348,11 @@ MessageSendEvent_clone(origPointer)
339348
return MessageSendEvent(pointer: MessageSendEvent_send_reply_channel_range(Bindings.new_LDKPublicKey(array: node_id), msg.danglingClone().cOpaqueStruct!));
340349
}
341350

351+
public class func send_gossip_timestamp_filter(node_id: [UInt8], msg: GossipTimestampFilter) -> MessageSendEvent {
352+
353+
return MessageSendEvent(pointer: MessageSendEvent_send_gossip_timestamp_filter(Bindings.new_LDKPublicKey(array: node_id), msg.danglingClone().cOpaqueStruct!));
354+
}
355+
342356
/* OPTION_METHODS_END */
343357

344358

@@ -885,4 +899,33 @@ MessageSendEvent_clone(origPointer)
885899

886900
}
887901

902+
903+
public class SendGossipTimestampFilter: NativeTypeWrapper {
904+
905+
906+
var cOpaqueStruct: LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body?;
907+
fileprivate init(pointer: LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body) {
908+
self.cOpaqueStruct = pointer
909+
super.init(conflictAvoidingVariableName: 0)
910+
}
911+
fileprivate init(pointer: LDKMessageSendEvent_LDKSendGossipTimestampFilter_Body, anchor: NativeTypeWrapper) {
912+
self.cOpaqueStruct = pointer
913+
super.init(conflictAvoidingVariableName: 0)
914+
self.dangling = true
915+
try! self.addAnchor(anchor: anchor)
916+
}
917+
918+
919+
920+
public func getNode_id() -> [UInt8] {
921+
return Bindings.LDKPublicKey_to_array(nativeType: self.cOpaqueStruct!.node_id)
922+
}
923+
924+
public func getMsg() -> GossipTimestampFilter {
925+
return GossipTimestampFilter(pointer: self.cOpaqueStruct!.msg, anchor: self)
926+
}
927+
928+
929+
}
930+
888931
}

0 commit comments

Comments
 (0)