Skip to content

Commit 22416bd

Browse files
committed
Update C/C++ Demos to latest upstream API
1 parent c2700a6 commit 22416bd

File tree

2 files changed

+110
-106
lines changed

2 files changed

+110
-106
lines changed

lightning-c-bindings/demo.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void broadcast_tx(const void *this_arg, LDKTransaction tx) {
2828
LDKChannelMonitorUpdateStatus add_channel_monitor(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2929
return ChannelMonitorUpdateStatus_completed();
3030
}
31-
LDKChannelMonitorUpdateStatus update_channel_monitor(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate monitor) {
31+
LDKChannelMonitorUpdateStatus update_channel_monitor(const void *this_arg, LDKOutPoint funding_txo, const LDKChannelMonitorUpdate *monitor) {
3232
return ChannelMonitorUpdateStatus_completed();
3333
}
3434
LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ monitors_pending_monitor_events(const void *this_arg) {
@@ -44,6 +44,16 @@ void never_handle_event(const void *this_arg, const struct LDKEvent event) {
4444
assert(false);
4545
}
4646

47+
LDKCResult_RouteLightningErrorZ do_find_route(const void *this_arg, LDKPublicKey payer, const LDKRouteParameters *route_params, LDKCVec_ChannelDetailsZ *first_hops, const LDKInFlightHtlcs *inflight_htlcs) {
48+
LDKStr reason = { .chars = (const unsigned char*)"", .len = 0, .chars_is_owned = false };
49+
return CResult_RouteLightningErrorZ_err(LightningError_new(reason, ErrorAction_ignore_error()));
50+
}
51+
52+
LDKCResult_RouteLightningErrorZ do_find_route_with_id(const void *this_arg, LDKPublicKey payer, const LDKRouteParameters *route_params, LDKCVec_ChannelDetailsZ *first_hops, const LDKInFlightHtlcs *inflight_htlcs, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_id) {
53+
LDKStr reason = { .chars = (const unsigned char*)"", .len = 0, .chars_is_owned = false };
54+
return CResult_RouteLightningErrorZ_err(LightningError_new(reason, ErrorAction_ignore_error()));
55+
}
56+
4757
int main() {
4858
uint8_t node_seed[32];
4959
memset(node_seed, 0, 32);
@@ -71,19 +81,28 @@ int main() {
7181
};
7282

7383
LDKBroadcasterInterface broadcast = {
74-
broadcast.this_arg = NULL,
75-
broadcast.broadcast_transaction = broadcast_tx,
84+
.this_arg = NULL,
85+
.broadcast_transaction = broadcast_tx,
86+
.free = NULL,
87+
};
88+
89+
LDKRouter router = {
90+
.this_arg = NULL,
91+
.find_route = do_find_route,
92+
.find_route_with_id = do_find_route_with_id,
7693
.free = NULL,
7794
};
7895

7996
LDKKeysManager keys = KeysManager_new(&node_seed, 0, 0);
80-
LDKKeysInterface keys_source = KeysManager_as_KeysInterface(&keys);
97+
LDKEntropySource entropy_source = KeysManager_as_EntropySource(&keys);
98+
LDKNodeSigner node_signer = KeysManager_as_NodeSigner(&keys);
99+
LDKSignerProvider signer_provider = KeysManager_as_SignerProvider(&keys);
81100

82101
LDKUserConfig config = UserConfig_default();
83102
LDKThirtyTwoBytes chain_tip;
84103
memset(&chain_tip, 0, 32);
85104
LDKChainParameters chain = ChainParameters_new(net, BestBlock_new(chain_tip, 0));
86-
LDKChannelManager cm = ChannelManager_new(fee_est, mon, broadcast, logger, keys_source, config, chain);
105+
LDKChannelManager cm = ChannelManager_new(fee_est, mon, broadcast, router, logger, entropy_source, node_signer, signer_provider, config, chain);
87106

88107
LDKCVec_ChannelDetailsZ channels = ChannelManager_list_channels(&cm);
89108
assert((unsigned long)channels.data < 4096); // There's an offset, but it should still be an offset against null in the 0 page

0 commit comments

Comments
 (0)