Skip to content

Commit 356ee17

Browse files
authored
Merge pull request #49 from lightningdevkit/2022-06-ldkwitnessversion-108
Add unary byte container parameter
2 parents 0641db7 + ce45a62 commit 356ee17

File tree

60 files changed

+2453
-1089
lines changed

Some content is hidden

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

60 files changed

+2453
-1089
lines changed

.github/workflows/swift.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@ jobs:
2020
# Note this is a different endpoint, as we need one non-upstream commit!
2121
# git clone https://git.bitcoin.ninja/rust-lightning
2222
# git clone https://github.com/TheBlueMatt/rust-lightning
23-
git clone --branch 2021-03-java-bindings-base https://github.com/TheBlueMatt/rust-lightning
23+
# git clone --branch 2021-03-java-bindings-base https://github.com/TheBlueMatt/rust-lightning
24+
git clone --branch 2022-05-107-bindings-scratch https://github.com/TheBlueMatt/rust-lightning
2425
cd rust-lightning
2526
# git checkout origin/2021-03-java-bindings-base
2627
# git checkout v0.0.100
2728
# git checkout 8966f8d3d4911e034621c6d3c3d20140d3a7e76a
2829
echo "rust-lightning commit hash:"
2930
git rev-parse HEAD
3031
cd ..
31-
git clone https://github.com/lightningdevkit/ldk-c-bindings
32-
# git clone https://github.com/TheBlueMatt/ldk-c-bindings
32+
# git clone https://github.com/lightningdevkit/ldk-c-bindings
33+
git clone https://github.com/TheBlueMatt/ldk-c-bindings
3334
cd ldk-c-bindings
3435
# git checkout 1bb5ae1b34aeb74009b7b4b5ebefc957cddc30a6
3536
echo "ldk-c-bindings commit hash:"
@@ -91,7 +92,7 @@ jobs:
9192
echo "Sha sum: $(sha256sum swift-5.6-RELEASE-ubuntu20.04.tar.gz | awk '{ print $1 }')"
9293
if [ "$(sha256sum swift-5.6-RELEASE-ubuntu20.04.tar.gz | awk '{ print $1 }')" != "${EXPECTED_SWIFT_SHASUM}" ]; then
9394
echo "Bad hash"
94-
echo "Contents: \n$(cat swift-5.6-RELEASE-ubuntu20.04.tar.gz)"
95+
echo "Contents: \n$(cat swift-5.6-RELEASE-ubuntu20.04.tar.gz)"
9596
exit 1
9697
fi
9798
tar xvvf swift-5.6-RELEASE-ubuntu20.04.tar.gz
@@ -137,7 +138,7 @@ jobs:
137138
echo "Sha sum: $(sha256sum swift-5.6-RELEASE-ubuntu20.04.tar.gz | awk '{ print $1 }')"
138139
if [ "$(sha256sum swift-5.6-RELEASE-ubuntu20.04.tar.gz | awk '{ print $1 }')" != "${EXPECTED_SWIFT_SHASUM}" ]; then
139140
echo "Bad hash"
140-
echo "Contents: \n$(cat swift-5.6-RELEASE-ubuntu20.04.tar.gz)"
141+
echo "Contents: \n$(cat swift-5.6-RELEASE-ubuntu20.04.tar.gz)"
141142
exit 1
142143
fi
143144
tar xvvf swift-5.6-RELEASE-ubuntu20.04.tar.gz

bindings/LDK/Bindings.swift

Lines changed: 318 additions & 135 deletions
Large diffs are not rendered by default.

bindings/LDK/options/Event.swift

Lines changed: 165 additions & 106 deletions
Large diffs are not rendered by default.

bindings/LDK/options/GossipSync.swift

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
public class GossipSync: NativeTypeWrapper {
2+
3+
private static var instanceCounter: UInt = 0
4+
internal let instanceNumber: UInt
5+
6+
internal var cOpaqueStruct: LDKGossipSync?
7+
8+
9+
10+
public init(pointer: LDKGossipSync){
11+
Self.instanceCounter += 1
12+
self.instanceNumber = Self.instanceCounter
13+
self.cOpaqueStruct = pointer
14+
super.init(conflictAvoidingVariableName: 0)
15+
}
16+
17+
public init(pointer: LDKGossipSync, 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 GossipSyncValueType {
29+
case P2P, Rapid
30+
}
31+
32+
public func getValueType() -> GossipSyncValueType? {
33+
switch self.cOpaqueStruct?.tag {
34+
35+
case LDKGossipSync_P2P:
36+
return .P2P
37+
case LDKGossipSync_Rapid:
38+
return .Rapid
39+
default:
40+
return nil
41+
}
42+
}
43+
44+
45+
public func getValueAsP2P() -> P2PGossipSync? {
46+
if self.cOpaqueStruct?.tag != LDKGossipSync_P2P {
47+
return nil
48+
}
49+
return P2PGossipSync(pointer: self.cOpaqueStruct!.p2p, anchor: self)
50+
}
51+
52+
public func getValueAsRapid() -> RapidGossipSync? {
53+
if self.cOpaqueStruct?.tag != LDKGossipSync_Rapid {
54+
return nil
55+
}
56+
return RapidGossipSync(pointer: self.cOpaqueStruct!.rapid, anchor: self)
57+
}
58+
59+
60+
internal func free() -> Void {
61+
62+
return GossipSync_free(self.cOpaqueStruct!);
63+
}
64+
65+
internal func dangle() -> GossipSync {
66+
self.dangling = true
67+
return self
68+
}
69+
70+
deinit {
71+
if !self.dangling {
72+
Bindings.print("Freeing GossipSync \(self.instanceNumber).")
73+
self.free()
74+
} else {
75+
Bindings.print("Not freeing GossipSync \(self.instanceNumber) due to dangle.")
76+
}
77+
}
78+
79+
80+
public class func p2_p(a: P2PGossipSync) -> GossipSync {
81+
82+
return GossipSync(pointer: GossipSync_p2_p(a.cOpaqueStruct!));
83+
}
84+
85+
public class func rapid(a: RapidGossipSync) -> GossipSync {
86+
87+
return GossipSync(pointer: GossipSync_rapid(a.cOpaqueStruct!));
88+
}
89+
90+
public class func none() -> GossipSync {
91+
92+
return GossipSync(pointer: GossipSync_none());
93+
}
94+
95+
/* OPTION_METHODS_END */
96+
97+
/* TYPE_CLASSES */
98+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
public class GraphSyncError: NativeTypeWrapper {
2+
3+
private static var instanceCounter: UInt = 0
4+
internal let instanceNumber: UInt
5+
6+
internal var cOpaqueStruct: LDKGraphSyncError?
7+
8+
9+
10+
public init(pointer: LDKGraphSyncError){
11+
Self.instanceCounter += 1
12+
self.instanceNumber = Self.instanceCounter
13+
self.cOpaqueStruct = pointer
14+
super.init(conflictAvoidingVariableName: 0)
15+
}
16+
17+
public init(pointer: LDKGraphSyncError, 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 GraphSyncErrorValueType {
29+
case DecodeError, LightningError
30+
}
31+
32+
public func getValueType() -> GraphSyncErrorValueType? {
33+
switch self.cOpaqueStruct?.tag {
34+
35+
case LDKGraphSyncError_DecodeError:
36+
return .DecodeError
37+
case LDKGraphSyncError_LightningError:
38+
return .LightningError
39+
default:
40+
return nil
41+
}
42+
}
43+
44+
45+
public func getValueAsDecodeError() -> DecodeError? {
46+
if self.cOpaqueStruct?.tag != LDKGraphSyncError_DecodeError {
47+
return nil
48+
}
49+
return DecodeError(pointer: self.cOpaqueStruct!.decode_error, anchor: self)
50+
}
51+
52+
public func getValueAsLightningError() -> LightningError? {
53+
if self.cOpaqueStruct?.tag != LDKGraphSyncError_LightningError {
54+
return nil
55+
}
56+
return LightningError(pointer: self.cOpaqueStruct!.lightning_error, anchor: self)
57+
}
58+
59+
60+
internal func free() -> Void {
61+
62+
return GraphSyncError_free(self.cOpaqueStruct!);
63+
}
64+
65+
internal func dangle() -> GraphSyncError {
66+
self.dangling = true
67+
return self
68+
}
69+
70+
deinit {
71+
if !self.dangling {
72+
Bindings.print("Freeing GraphSyncError \(self.instanceNumber).")
73+
self.free()
74+
} else {
75+
Bindings.print("Not freeing GraphSyncError \(self.instanceNumber) due to dangle.")
76+
}
77+
}
78+
79+
80+
public func clone() -> GraphSyncError {
81+
82+
return GraphSyncError(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (origPointer: UnsafePointer<LDKGraphSyncError>) in
83+
GraphSyncError_clone(origPointer)
84+
});
85+
}
86+
87+
internal func danglingClone() -> GraphSyncError {
88+
let dangledClone = self.clone()
89+
dangledClone.dangling = true
90+
return dangledClone
91+
}
92+
93+
94+
public class func decode_error(a: DecodeError) -> GraphSyncError {
95+
96+
return GraphSyncError(pointer: GraphSyncError_decode_error(a.danglingClone().cOpaqueStruct!));
97+
}
98+
99+
public class func lightning_error(a: LightningError) -> GraphSyncError {
100+
101+
return GraphSyncError(pointer: GraphSyncError_lightning_error(a.danglingClone().cOpaqueStruct!));
102+
}
103+
104+
/* OPTION_METHODS_END */
105+
106+
/* TYPE_CLASSES */
107+
}

bindings/LDK/options/MessageSendEvent.swift

Lines changed: 14 additions & 14 deletions
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, SendGossipTimestampFilter
29+
case SendAcceptChannel, SendOpenChannel, SendFundingCreated, SendFundingSigned, SendChannelReady, SendAnnouncementSignatures, UpdateHTLCs, SendRevokeAndACK, SendClosingSigned, SendShutdown, SendChannelReestablish, BroadcastChannelAnnouncement, BroadcastNodeAnnouncement, BroadcastChannelUpdate, SendChannelUpdate, HandleError, SendChannelRangeQuery, SendShortIdsQuery, SendReplyChannelRange, SendGossipTimestampFilter
3030
}
3131

3232
public func getValueType() -> MessageSendEventValueType? {
@@ -40,8 +40,8 @@ public class MessageSendEvent: NativeTypeWrapper {
4040
return .SendFundingCreated
4141
case LDKMessageSendEvent_SendFundingSigned:
4242
return .SendFundingSigned
43-
case LDKMessageSendEvent_SendFundingLocked:
44-
return .SendFundingLocked
43+
case LDKMessageSendEvent_SendChannelReady:
44+
return .SendChannelReady
4545
case LDKMessageSendEvent_SendAnnouncementSignatures:
4646
return .SendAnnouncementSignatures
4747
case LDKMessageSendEvent_UpdateHTLCs:
@@ -106,11 +106,11 @@ public class MessageSendEvent: NativeTypeWrapper {
106106
return SendFundingSigned(pointer: self.cOpaqueStruct!.send_funding_signed, anchor: self)
107107
}
108108

109-
public func getValueAsSendFundingLocked() -> SendFundingLocked? {
110-
if self.cOpaqueStruct?.tag != LDKMessageSendEvent_SendFundingLocked {
109+
public func getValueAsSendChannelReady() -> SendChannelReady? {
110+
if self.cOpaqueStruct?.tag != LDKMessageSendEvent_SendChannelReady {
111111
return nil
112112
}
113-
return SendFundingLocked(pointer: self.cOpaqueStruct!.send_funding_locked, anchor: self)
113+
return SendChannelReady(pointer: self.cOpaqueStruct!.send_channel_ready, anchor: self)
114114
}
115115

116116
public func getValueAsSendAnnouncementSignatures() -> SendAnnouncementSignatures? {
@@ -273,9 +273,9 @@ MessageSendEvent_clone(origPointer)
273273
return MessageSendEvent(pointer: MessageSendEvent_send_funding_signed(Bindings.new_LDKPublicKey(array: node_id), msg.danglingClone().cOpaqueStruct!));
274274
}
275275

276-
public class func send_funding_locked(node_id: [UInt8], msg: FundingLocked) -> MessageSendEvent {
276+
public class func send_channel_ready(node_id: [UInt8], msg: ChannelReady) -> MessageSendEvent {
277277

278-
return MessageSendEvent(pointer: MessageSendEvent_send_funding_locked(Bindings.new_LDKPublicKey(array: node_id), msg.danglingClone().cOpaqueStruct!));
278+
return MessageSendEvent(pointer: MessageSendEvent_send_channel_ready(Bindings.new_LDKPublicKey(array: node_id), msg.danglingClone().cOpaqueStruct!));
279279
}
280280

281281
public class func send_announcement_signatures(node_id: [UInt8], msg: AnnouncementSignatures) -> MessageSendEvent {
@@ -473,15 +473,15 @@ MessageSendEvent_clone(origPointer)
473473
}
474474

475475

476-
public class SendFundingLocked: NativeTypeWrapper {
476+
public class SendChannelReady: NativeTypeWrapper {
477477

478478

479-
var cOpaqueStruct: LDKMessageSendEvent_LDKSendFundingLocked_Body?;
480-
fileprivate init(pointer: LDKMessageSendEvent_LDKSendFundingLocked_Body) {
479+
var cOpaqueStruct: LDKMessageSendEvent_LDKSendChannelReady_Body?;
480+
fileprivate init(pointer: LDKMessageSendEvent_LDKSendChannelReady_Body) {
481481
self.cOpaqueStruct = pointer
482482
super.init(conflictAvoidingVariableName: 0)
483483
}
484-
fileprivate init(pointer: LDKMessageSendEvent_LDKSendFundingLocked_Body, anchor: NativeTypeWrapper) {
484+
fileprivate init(pointer: LDKMessageSendEvent_LDKSendChannelReady_Body, anchor: NativeTypeWrapper) {
485485
self.cOpaqueStruct = pointer
486486
super.init(conflictAvoidingVariableName: 0)
487487
self.dangling = true
@@ -494,8 +494,8 @@ MessageSendEvent_clone(origPointer)
494494
return Bindings.LDKPublicKey_to_array(nativeType: self.cOpaqueStruct!.node_id)
495495
}
496496

497-
public func getMsg() -> FundingLocked {
498-
return FundingLocked(pointer: self.cOpaqueStruct!.msg, anchor: self)
497+
public func getMsg() -> ChannelReady {
498+
return ChannelReady(pointer: self.cOpaqueStruct!.msg, anchor: self)
499499
}
500500

501501

bindings/LDK/options/NetworkUpdate.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ public class NetworkUpdate: NativeTypeWrapper {
2626
/* OPTION_METHODS_START */
2727

2828
public enum NetworkUpdateValueType {
29-
case ChannelUpdateMessage, ChannelClosed, NodeFailure
29+
case ChannelUpdateMessage, ChannelFailure, NodeFailure
3030
}
3131

3232
public func getValueType() -> NetworkUpdateValueType? {
3333
switch self.cOpaqueStruct?.tag {
3434

3535
case LDKNetworkUpdate_ChannelUpdateMessage:
3636
return .ChannelUpdateMessage
37-
case LDKNetworkUpdate_ChannelClosed:
38-
return .ChannelClosed
37+
case LDKNetworkUpdate_ChannelFailure:
38+
return .ChannelFailure
3939
case LDKNetworkUpdate_NodeFailure:
4040
return .NodeFailure
4141
default:
@@ -51,11 +51,11 @@ public class NetworkUpdate: NativeTypeWrapper {
5151
return ChannelUpdateMessage(pointer: self.cOpaqueStruct!.channel_update_message, anchor: self)
5252
}
5353

54-
public func getValueAsChannelClosed() -> ChannelClosed? {
55-
if self.cOpaqueStruct?.tag != LDKNetworkUpdate_ChannelClosed {
54+
public func getValueAsChannelFailure() -> ChannelFailure? {
55+
if self.cOpaqueStruct?.tag != LDKNetworkUpdate_ChannelFailure {
5656
return nil
5757
}
58-
return ChannelClosed(pointer: self.cOpaqueStruct!.channel_closed, anchor: self)
58+
return ChannelFailure(pointer: self.cOpaqueStruct!.channel_failure, anchor: self)
5959
}
6060

6161
public func getValueAsNodeFailure() -> NodeFailure? {
@@ -105,9 +105,9 @@ NetworkUpdate_clone(origPointer)
105105
return NetworkUpdate(pointer: NetworkUpdate_channel_update_message(msg.danglingClone().cOpaqueStruct!));
106106
}
107107

108-
public class func channel_closed(short_channel_id: UInt64, is_permanent: Bool) -> NetworkUpdate {
108+
public class func channel_failure(short_channel_id: UInt64, is_permanent: Bool) -> NetworkUpdate {
109109

110-
return NetworkUpdate(pointer: NetworkUpdate_channel_closed(short_channel_id, is_permanent));
110+
return NetworkUpdate(pointer: NetworkUpdate_channel_failure(short_channel_id, is_permanent));
111111
}
112112

113113
public class func node_failure(node_id: [UInt8], is_permanent: Bool) -> NetworkUpdate {
@@ -161,15 +161,15 @@ NetworkUpdate_write(objPointer)
161161
}
162162

163163

164-
public class ChannelClosed: NativeTypeWrapper {
164+
public class ChannelFailure: NativeTypeWrapper {
165165

166166

167-
var cOpaqueStruct: LDKNetworkUpdate_LDKChannelClosed_Body?;
168-
fileprivate init(pointer: LDKNetworkUpdate_LDKChannelClosed_Body) {
167+
var cOpaqueStruct: LDKNetworkUpdate_LDKChannelFailure_Body?;
168+
fileprivate init(pointer: LDKNetworkUpdate_LDKChannelFailure_Body) {
169169
self.cOpaqueStruct = pointer
170170
super.init(conflictAvoidingVariableName: 0)
171171
}
172-
fileprivate init(pointer: LDKNetworkUpdate_LDKChannelClosed_Body, anchor: NativeTypeWrapper) {
172+
fileprivate init(pointer: LDKNetworkUpdate_LDKChannelFailure_Body, anchor: NativeTypeWrapper) {
173173
self.cOpaqueStruct = pointer
174174
super.init(conflictAvoidingVariableName: 0)
175175
self.dangling = true

0 commit comments

Comments
 (0)