From: Matt Corallo Date: Wed, 27 Jul 2022 04:50:43 +0000 (+0000) Subject: Update C/C++ demos to latest upstream API X-Git-Tag: v0.0.110.0^2~2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=6becb3248617a383229c4d310d68308411fa6ede;p=ldk-c-bindings Update C/C++ demos to latest upstream API --- diff --git a/lightning-c-bindings/demo.c b/lightning-c-bindings/demo.c index 1e9bfb0..291f4db 100644 --- a/lightning-c-bindings/demo.c +++ b/lightning-c-bindings/demo.c @@ -31,8 +31,8 @@ LDKCResult_NoneChannelMonitorUpdateErrZ add_channel_monitor(const void *this_arg LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_monitor(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate monitor) { return CResult_NoneChannelMonitorUpdateErrZ_ok(); } -LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ monitors_pending_monitor_events(const void *this_arg) { - LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ empty_htlc_vec = { +LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ monitors_pending_monitor_events(const void *this_arg) { + LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ empty_htlc_vec = { .data = NULL, .datalen = 0, }; diff --git a/lightning-c-bindings/demo.cpp b/lightning-c-bindings/demo.cpp index e1e1b60..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; } } @@ -711,7 +712,8 @@ 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, 1), + }, 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);