Update io::Read manual implementation to upstream API changes
[ldk-c-bindings] / lightning-c-bindings / demo.cpp
index b71edc324581052dc102f17d3a0dcbe331a055f2..1412f2b11b42441b44e279c11c244a830ed62c3f 100644 (file)
@@ -308,7 +308,7 @@ public:
                        .disconnect_socket = sock_disconnect_socket,
                        .eq = sock_eq,
                        .hash = sock_hash,
-                       .clone = NULL,
+                       .cloned = NULL,
                        .free = NULL,
                };
 
@@ -318,7 +318,7 @@ public:
                        .disconnect_socket = sock_disconnect_socket,
                        .eq = sock_eq,
                        .hash = sock_hash,
-                       .clone = NULL,
+                       .cloned = NULL,
                        .free = NULL,
                };
 
@@ -553,6 +553,7 @@ int main() {
                PeerManager_process_events(&net2);
 
                // Now send funds from 1 to 2!
+               uint64_t channel_scid;
                while (true) {
                        LDK::CVec_ChannelDetailsZ outbound_channels = ChannelManager_list_usable_channels(&cm1);
                        if (outbound_channels->datalen == 1) {
@@ -573,6 +574,9 @@ int main() {
                                if (inbound_capacity < 0) inbound_capacity = 0;
                                assert(ChannelDetails_get_inbound_capacity_msat(channel) == (uint64_t)inbound_capacity);
                                assert(ChannelDetails_get_is_usable(channel));
+                               LDK::COption_u64Z scid_opt = ChannelDetails_get_short_channel_id(channel);
+                               assert(scid_opt->some);
+                               channel_scid = scid_opt->some;
                                break;
                        }
                        std::this_thread::yield();
@@ -603,6 +607,12 @@ int main() {
                                }, &outbound_channels, Invoice_route_hints(invoice->contents.result),
                                5000, Invoice_min_final_cltv_expiry(invoice->contents.result), logger1);
                        assert(route->result_ok);
+                       LDK::CVec_CVec_RouteHopZZ paths = Route_get_paths(route->contents.result);
+                       assert(paths->datalen == 1);
+                       assert(paths->data[0].datalen == 1);
+                       assert(!memcmp(RouteHop_get_pubkey(&paths->data[0].data[0]).compressed_form,
+                               ChannelManager_get_our_node_id(&cm2).compressed_form, 33));
+                       assert(RouteHop_get_short_channel_id(&paths->data[0].data[0]) == channel_scid);
                        LDK::CResult_NonePaymentSendFailureZ send_res = ChannelManager_send_payment(&cm1, route->contents.result, payment_hash, Invoice_payment_secret(invoice->contents.result));
                        assert(send_res->result_ok);
                }
@@ -637,9 +647,11 @@ int main() {
                        assert(queue.events.size() == 1);
                        assert(queue.events[0]->tag == LDKEvent_PaymentReceived);
                        assert(!memcmp(queue.events[0]->payment_received.payment_hash.data, payment_hash.data, 32));
-                       assert(!memcmp(queue.events[0]->payment_received.payment_secret.data, Invoice_payment_secret(invoice->contents.result).data, 32));
+                       assert(queue.events[0]->payment_received.purpose.tag == LDKPaymentPurpose_InvoicePayment);
+                       assert(!memcmp(queue.events[0]->payment_received.purpose.invoice_payment.payment_secret.data,
+                                       Invoice_payment_secret(invoice->contents.result).data, 32));
                        assert(queue.events[0]->payment_received.amt == 5000);
-                       memcpy(payment_preimage.data, queue.events[0]->payment_received.payment_preimage.data, 32);
+                       memcpy(payment_preimage.data, queue.events[0]->payment_received.purpose.invoice_payment.payment_preimage.data, 32);
                        assert(ChannelManager_claim_funds(&cm2, payment_preimage));
                }
                PeerManager_process_events(&net2);