X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fdemo.cpp;h=ac82b739811ed9af4618e69140b5c274c5c5ff83;hb=544fd447db06fee681fa6d5e88138eac6d128a38;hp=1d29ed60293b96ca7789edc3e20b5f1e96320c9f;hpb=d15b7a463b2402bf6193599755fd7418da5d90d4;p=ldk-c-bindings diff --git a/lightning-c-bindings/demo.cpp b/lightning-c-bindings/demo.cpp index 1d29ed6..ac82b73 100644 --- a/lightning-c-bindings/demo.cpp +++ b/lightning-c-bindings/demo.cpp @@ -167,7 +167,7 @@ LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_monitor(const void *this_ LDKBroadcasterInterface broadcaster = { .broadcast_transaction = broadcast_tx, }; - LDK::CResult_NoneNoneZ res = ChannelMonitor_update_monitor(&mon.second, &update, &broadcaster, &fee_est, arg->logger); + LDK::CResult_NoneNoneZ res = ChannelMonitor_update_monitor(&mon.second, &update, &broadcaster, fee_est, arg->logger); assert(res->result_ok); } } @@ -176,12 +176,12 @@ LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_monitor(const void *this_ mons_updated += 1; return CResult_NoneChannelMonitorUpdateErrZ_ok(); } -LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ monitors_pending_monitor_events(const void *this_arg) { +LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ monitors_pending_monitor_events(const void *this_arg) { NodeMonitors* arg = (NodeMonitors*) this_arg; std::unique_lock l(arg->mut); if (arg->mons.size() == 0) { - return LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ { + return LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { .data = NULL, .datalen = 0, }; @@ -192,12 +192,13 @@ LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ monitors_pending_monitor_events(con LDK::CVec_MonitorEventZ events = ChannelMonitor_get_and_clear_pending_monitor_events(&arg->mons[0].second); LDK::C2Tuple_OutPointScriptZ funding_info = ChannelMonitor_get_funding_txo(&arg->mons[0].second); LDK::OutPoint outpoint = std::move(funding_info->a); - LDK::C2Tuple_OutPointCVec_MonitorEventZZ pair = C2Tuple_OutPointCVec_MonitorEventZZ_new(std::move(outpoint), std::move(events)); - auto vec = LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ { - .data = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)malloc(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ)), + LDKPublicKey counterparty_node_id = ChannelMonitor_get_counterparty_node_id(&arg->mons[0].second); + LDK::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ tuple = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(std::move(outpoint), std::move(events), std::move(counterparty_node_id)); + auto vec = LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + .data = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)malloc(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ)), .datalen = 1, }; - vec.data[0] = std::move(pair); + vec.data[0] = std::move(tuple); return vec; } } @@ -444,8 +445,7 @@ struct LDKCResult_RouteLightningErrorZ custom_find_route(const void *this_arg, s const struct CustomRouteFinderParams *params = (struct CustomRouteFinderParams *)this_arg; assert(first_hops->datalen == 1); assert(ChannelDetails_get_is_usable(&first_hops->data[0])); - LDK::ReadOnlyNetworkGraph graph_lock = NetworkGraph_read_only(params->graph_ref); - return find_route(payer, route_params, &graph_lock, first_hops, *params->logger, scorer, ¶ms->random_seed_bytes.data); + return find_route(payer, route_params, params->graph_ref, first_hops, *params->logger, scorer, ¶ms->random_seed_bytes.data); } int main() { @@ -556,7 +556,7 @@ int main() { LDK::ChannelHandshakeConfig handshake_config2 = ChannelHandshakeConfig_default(); ChannelHandshakeConfig_set_minimum_depth(&handshake_config2, 2); LDK::UserConfig config2 = UserConfig_default(); - UserConfig_set_own_channel_config(&config2, std::move(handshake_config2)); + UserConfig_set_channel_handshake_config(&config2, std::move(handshake_config2)); LDK::ChannelManager cm2 = ChannelManager_new(fee_est, mon2, broadcast, logger2, KeysManager_as_KeysInterface(&keys2), std::move(config2), ChainParameters_new(network, BestBlock_new(chain_tip, 0))); @@ -712,12 +712,12 @@ int main() { LDK::RouteParameters route_params = RouteParameters_new(PaymentParameters_new( ChannelManager_get_our_node_id(&cm2), LDKInvoiceFeatures { .inner = NULL, .is_owned = false - }, Invoice_route_hints(invoice->contents.result), COption_u64Z_none(), 0xffffffff), + }, Invoice_route_hints(invoice->contents.result), COption_u64Z_none(), 0xffffffff, + 1, 2, LDKCVec_u64Z { .data = NULL, .datalen = 0 }), 5000, Invoice_min_final_cltv_expiry(invoice->contents.result)); random_bytes = keys_source1->get_secure_random_bytes(keys_source1->this_arg); - LDK::ReadOnlyNetworkGraph graph_lock = NetworkGraph_read_only(&net_graph2); - LDK::CResult_RouteLightningErrorZ route = find_route(ChannelManager_get_our_node_id(&cm1), &route_params, &graph_lock, &outbound_channels, logger1, &chan_scorer, &random_bytes.data); + LDK::CResult_RouteLightningErrorZ route = find_route(ChannelManager_get_our_node_id(&cm1), &route_params, &net_graph2, &outbound_channels, logger1, &chan_scorer, &random_bytes.data); assert(route->result_ok); LDK::CVec_CVec_RouteHopZZ paths = Route_get_paths(route->contents.result);