@@ -137,7 +137,7 @@ struct NodeMonitors {
137
137
}
138
138
};
139
139
140
- LDKChannelMonitorUpdateStatus add_channel_monitor (const void *this_arg, LDKOutPoint funding_txo_arg, LDKChannelMonitor monitor_arg) {
140
+ LDKCResult_ChannelMonitorUpdateStatusNoneZ add_channel_monitor (const void *this_arg, LDKOutPoint funding_txo_arg, LDKChannelMonitor monitor_arg) {
141
141
// First bind the args to C++ objects so they auto-free
142
142
LDK::ChannelMonitor mon (std::move (monitor_arg));
143
143
LDK::OutPoint funding_txo (std::move (funding_txo_arg));
@@ -146,7 +146,7 @@ LDKChannelMonitorUpdateStatus add_channel_monitor(const void *this_arg, LDKOutPo
146
146
std::unique_lock<std::mutex> l (arg->mut );
147
147
148
148
arg->mons .push_back (std::make_pair (std::move (funding_txo), std::move (mon)));
149
- return ChannelMonitorUpdateStatus_completed ();
149
+ return CResult_ChannelMonitorUpdateStatusNoneZ_ok ( ChannelMonitorUpdateStatus_completed () );
150
150
}
151
151
static std::atomic_int mons_updated (0 );
152
152
LDKChannelMonitorUpdateStatus update_channel_monitor (const void *this_arg, LDKOutPoint funding_txo_arg, const LDKChannelMonitorUpdate *update) {
@@ -164,7 +164,7 @@ LDKChannelMonitorUpdateStatus update_channel_monitor(const void *this_arg, LDKOu
164
164
LDKBroadcasterInterface broadcaster = {
165
165
.broadcast_transactions = broadcast_txn,
166
166
};
167
- LDK::CResult_NoneNoneZ res = ChannelMonitor_update_monitor (&mon.second , update, &broadcaster, fee_est, arg->logger );
167
+ LDK::CResult_NoneNoneZ res = ChannelMonitor_update_monitor (&mon.second , update, &broadcaster, & fee_est, arg->logger );
168
168
assert (res->result_ok );
169
169
}
170
170
}
@@ -187,7 +187,7 @@ LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ monitors_pending_monitor_e
187
187
// Rust Vecs to each other from C++ will require a bit of effort.
188
188
assert (arg->mons .size () == 1 );
189
189
LDK::CVec_MonitorEventZ events = ChannelMonitor_get_and_clear_pending_monitor_events (&arg->mons [0 ].second );
190
- LDK::C2Tuple_OutPointScriptZ funding_info = ChannelMonitor_get_funding_txo (&arg->mons [0 ].second );
190
+ LDK::C2Tuple_OutPointCVec_u8ZZ funding_info = ChannelMonitor_get_funding_txo (&arg->mons [0 ].second );
191
191
LDK::OutPoint outpoint = std::move (funding_info->a );
192
192
LDKPublicKey counterparty_node_id = ChannelMonitor_get_counterparty_node_id (&arg->mons [0 ].second );
193
193
LDK::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ tuple = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new (std::move (outpoint), std::move (events), std::move (counterparty_node_id));
@@ -229,8 +229,8 @@ class PeersConnection {
229
229
std::cout << __FILE__ << " :" << __LINE__ << " - " << " Awaiting initial handshake completion..." << std::endl;
230
230
while (true ) {
231
231
// Wait for the initial handshakes to complete...
232
- LDK::CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ peers_1 = PeerManager_get_peer_node_ids (&net1);
233
- LDK::CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ peers_2 = PeerManager_get_peer_node_ids (&net2);
232
+ LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_1 = PeerManager_get_peer_node_ids (&net1);
233
+ LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_2 = PeerManager_get_peer_node_ids (&net2);
234
234
if (peers_1->datalen == 1 && peers_2->datalen == 1 ) { break ; }
235
235
std::this_thread::yield ();
236
236
}
@@ -247,8 +247,8 @@ class PeersConnection {
247
247
std::cout << __FILE__ << " :" << __LINE__ << " - " << " Awaiting new connection handshake..." << std::endl;
248
248
while (true ) {
249
249
// Wait for the new connection handshake...
250
- LDK::CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ peers_1 = PeerManager_get_peer_node_ids (&net1);
251
- LDK::CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ peers_2 = PeerManager_get_peer_node_ids (&net2);
250
+ LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_1 = PeerManager_get_peer_node_ids (&net1);
251
+ LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_2 = PeerManager_get_peer_node_ids (&net2);
252
252
if (peers_1->datalen == 1 && peers_2->datalen == 1 ) { break ; }
253
253
std::this_thread::yield ();
254
254
}
@@ -259,8 +259,8 @@ class PeersConnection {
259
259
while (true ) {
260
260
PeerManager_disconnect_by_node_id (&net1, ChannelManager_get_our_node_id (&cm2));
261
261
// Wait for the peers to disconnect...
262
- LDK::CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ peers_1 = PeerManager_get_peer_node_ids (&net1);
263
- LDK::CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ peers_2 = PeerManager_get_peer_node_ids (&net2);
262
+ LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_1 = PeerManager_get_peer_node_ids (&net1);
263
+ LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_2 = PeerManager_get_peer_node_ids (&net2);
264
264
if (peers_1->datalen == 0 && peers_2->datalen == 0 ) { break ; }
265
265
std::this_thread::yield ();
266
266
}
@@ -275,8 +275,8 @@ class PeersConnection {
275
275
std::cout << __FILE__ << " :" << __LINE__ << " - " << " Awaiting initial handshake completion..." << std::endl;
276
276
while (true ) {
277
277
// Wait for the initial handshakes to complete...
278
- LDK::CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ peers_1 = PeerManager_get_peer_node_ids (&net1);
279
- LDK::CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ peers_2 = PeerManager_get_peer_node_ids (&net2);
278
+ LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_1 = PeerManager_get_peer_node_ids (&net1);
279
+ LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_2 = PeerManager_get_peer_node_ids (&net2);
280
280
if (peers_1->datalen == 1 && peers_2->datalen == 1 ) { break ; }
281
281
std::this_thread::yield ();
282
282
}
@@ -354,9 +354,9 @@ class PeersConnection {
354
354
t2 = std::thread (&sock_read_data_thread, pipefds_1_to_2[0 ], &sock2, &net2);
355
355
356
356
// Note that we have to bind the result to a C++ class to make sure it gets free'd
357
- LDK::CResult_CVec_u8ZPeerHandleErrorZ con_res = PeerManager_new_outbound_connection (&net1, ChannelManager_get_our_node_id (&cm2), sock1, COption_NetAddressZ_none ());
357
+ LDK::CResult_CVec_u8ZPeerHandleErrorZ con_res = PeerManager_new_outbound_connection (&net1, ChannelManager_get_our_node_id (&cm2), sock1, COption_SocketAddressZ_none ());
358
358
assert (con_res->result_ok );
359
- LDK::CResult_NonePeerHandleErrorZ con_res2 = PeerManager_new_inbound_connection (&net2, sock2, COption_NetAddressZ_none ());
359
+ LDK::CResult_NonePeerHandleErrorZ con_res2 = PeerManager_new_inbound_connection (&net2, sock2, COption_SocketAddressZ_none ());
360
360
assert (con_res2->result_ok );
361
361
362
362
auto writelen = write (pipefds_1_to_2[1 ], con_res->contents .result ->data , con_res->contents .result ->datalen );
@@ -365,8 +365,8 @@ class PeersConnection {
365
365
std::cout << __FILE__ << " :" << __LINE__ << " - " << " Awaiting initial handshake completion..." << std::endl;
366
366
while (true ) {
367
367
// Wait for the initial handshakes to complete...
368
- LDK::CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ peers_1 = PeerManager_get_peer_node_ids (&net1);
369
- LDK::CVec_C2Tuple_PublicKeyCOption_NetAddressZZZ peers_2 = PeerManager_get_peer_node_ids (&net2);
368
+ LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_1 = PeerManager_get_peer_node_ids (&net1);
369
+ LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_2 = PeerManager_get_peer_node_ids (&net2);
370
370
if (peers_1->datalen == 1 && peers_2->datalen ==1 ) { break ; }
371
371
std::this_thread::yield ();
372
372
}
@@ -654,7 +654,7 @@ int main() {
654
654
PeersConnection conn (cm1, cm2, net1, net2);
655
655
656
656
// Note that we have to bind the result to a C++ class to make sure it gets free'd
657
- LDK::CResult__u832APIErrorZ res = ChannelManager_create_channel (&cm1, ChannelManager_get_our_node_id (&cm2), 40000 , 1000 , U128_new (user_id_1), UserConfig_default ());
657
+ LDK::CResult_ThirtyTwoBytesAPIErrorZ res = ChannelManager_create_channel (&cm1, ChannelManager_get_our_node_id (&cm2), 40000 , 1000 , U128_new (user_id_1), UserConfig_default ());
658
658
assert (res->result_ok );
659
659
PeerManager_process_events (&net1);
660
660
@@ -848,17 +848,15 @@ int main() {
848
848
849
849
{
850
850
LDK::CVec_ChannelDetailsZ outbound_channels = ChannelManager_list_usable_channels (&cm1);
851
- LDK::Score chan_scorer = LDKScore {
852
- .this_arg = NULL , .channel_penalty_msat = get_chan_score,
853
- .payment_path_failed = NULL , .payment_path_successful = NULL , .probe_failed = NULL ,
854
- .probe_successful = NULL , .write = NULL , .free = NULL ,
851
+ LDK::ScoreLookUp chan_scorer = LDKScoreLookUp {
852
+ .this_arg = NULL , .channel_penalty_msat = get_chan_score, .free = NULL ,
855
853
};
856
854
LDK::Payee payee = Payee_clear (ChannelManager_get_our_node_id (&cm2), Bolt11Invoice_route_hints (invoice->contents .result ),
857
855
LDKBolt11InvoiceFeatures {
858
856
.inner = NULL , .is_owned = false
859
857
}, Bolt11Invoice_min_final_cltv_expiry_delta (invoice->contents .result ));
860
- LDK::RouteParameters route_params = RouteParameters_new ( PaymentParameters_new (
861
- std::move (payee), COption_u64Z_none (), 0xffffffff , 1 , 2 ,
858
+ LDK::RouteParameters route_params = RouteParameters_from_payment_params_and_value (
859
+ PaymentParameters_new ( std::move (payee), COption_u64Z_none (), 0xffffffff , 1 , 2 ,
862
860
LDKCVec_u64Z { .data = NULL , .datalen = 0 }),
863
861
5000 );
864
862
random_bytes = entropy_source1.get_secure_random_bytes ();
@@ -918,7 +916,7 @@ int main() {
918
916
assert (!memcmp (queue.events [0 ]->payment_claimable .purpose .invoice_payment .payment_secret .data ,
919
917
Bolt11Invoice_payment_secret (invoice->contents .result ), 32 ));
920
918
assert (queue.events [0 ]->payment_claimable .amount_msat == 5000 );
921
- assert (queue.events [0 ]->payment_claimable .purpose .invoice_payment .payment_preimage .tag == LDKCOption_PaymentPreimageZ_Some );
919
+ assert (queue.events [0 ]->payment_claimable .purpose .invoice_payment .payment_preimage .tag == LDKCOption_ThirtyTwoBytesZ_Some );
922
920
memcpy (payment_preimage.data , queue.events [0 ]->payment_claimable .purpose .invoice_payment .payment_preimage .some .data , 32 );
923
921
ChannelManager_claim_funds (&cm2, payment_preimage);
924
922
@@ -931,11 +929,6 @@ int main() {
931
929
}
932
930
PeerManager_process_events (&net2);
933
931
// Wait until we've passed through a full set of monitor updates (ie new preimage + CS/RAA messages)
934
- std::cout << __FILE__ << " :" << __LINE__ << " - " << " Awaiting 5 updated monitors..." << std::endl;
935
- while (mons_updated != 5 ) {
936
- std::this_thread::yield ();
937
- }
938
- std::cout << __FILE__ << " :" << __LINE__ << " - " << " 5 monitors updated!" << std::endl;
939
932
{
940
933
EventQueue queue;
941
934
LDKEventHandler handler = { .this_arg = &queue, .handle_event = handle_event, .free = NULL };
@@ -949,9 +942,14 @@ int main() {
949
942
assert (queue.events [0 ]->tag == LDKEvent_PaymentSent);
950
943
assert (!memcmp (queue.events [0 ]->payment_sent .payment_preimage .data , payment_preimage.data , 32 ));
951
944
assert (queue.events [1 ]->tag == LDKEvent_PaymentPathSuccessful);
952
- assert (queue.events [1 ]->payment_path_successful .payment_hash .tag == LDKCOption_PaymentHashZ_Some );
945
+ assert (queue.events [1 ]->payment_path_successful .payment_hash .tag == LDKCOption_ThirtyTwoBytesZ_Some );
953
946
assert (!memcmp (queue.events [1 ]->payment_path_successful .payment_hash .some .data , payment_hash.data , 32 ));
954
947
}
948
+ std::cout << __FILE__ << " :" << __LINE__ << " - " << " Awaiting 5 updated monitors..." << std::endl;
949
+ while (mons_updated != 5 ) {
950
+ std::this_thread::yield ();
951
+ }
952
+ std::cout << __FILE__ << " :" << __LINE__ << " - " << " 5 monitors updated!" << std::endl;
955
953
956
954
conn.stop ();
957
955
@@ -984,8 +982,8 @@ int main() {
984
982
};
985
983
986
984
LDK::ChannelManagerReadArgs cm1_args = ChannelManagerReadArgs_new (KeysManager_as_EntropySource (&keys1), KeysManager_as_NodeSigner (&keys1), KeysManager_as_SignerProvider (&keys1), fee_est, mon1, broadcast, router1, logger1, UserConfig_default (), std::move (mons_list1));
987
- LDK::CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ cm1_read =
988
- C2Tuple_BlockHashChannelManagerZ_read (LDKu8slice { .data = cm1_ser->data , .datalen = cm1_ser -> datalen}, std::move (cm1_args));
985
+ LDK::CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ cm1_read =
986
+ C2Tuple_ThirtyTwoBytesChannelManagerZ_read (LDKu8slice { .data = cm1_ser->data , .datalen = cm1_ser -> datalen}, std::move (cm1_args));
989
987
assert (cm1_read->result_ok );
990
988
LDK::ChannelManager cm1 (std::move (cm1_read->contents .result ->b ));
991
989
@@ -1010,8 +1008,8 @@ int main() {
1010
1008
LDK::SignerProvider signer_provider2 = KeysManager_as_SignerProvider (&keys2);
1011
1009
1012
1010
LDK::ChannelManagerReadArgs cm2_args = ChannelManagerReadArgs_new (KeysManager_as_EntropySource (&keys2), KeysManager_as_NodeSigner (&keys2), KeysManager_as_SignerProvider (&keys2), fee_est, mon2, broadcast, panic_router, logger2, UserConfig_default (), std::move (mons_list2));
1013
- LDK::CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ cm2_read =
1014
- C2Tuple_BlockHashChannelManagerZ_read (LDKu8slice { .data = cm2_ser->data , .datalen = cm2_ser -> datalen}, std::move (cm2_args));
1011
+ LDK::CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ cm2_read =
1012
+ C2Tuple_ThirtyTwoBytesChannelManagerZ_read (LDKu8slice { .data = cm2_ser->data , .datalen = cm2_ser -> datalen}, std::move (cm2_args));
1015
1013
assert (cm2_read->result_ok );
1016
1014
LDK::ChannelManager cm2 (std::move (cm2_read->contents .result ->b ));
1017
1015
@@ -1093,7 +1091,7 @@ int main() {
1093
1091
}, 3600 , COption_u16Z_none ());
1094
1092
assert (invoice_res2->result_ok );
1095
1093
const LDKBolt11Invoice *invoice2 = invoice_res2->contents .result ;
1096
- LDK::CResult_PaymentIdPaymentErrorZ invoice_pay_res = pay_invoice (invoice2, Retry_attempts (0 ), &cm1);
1094
+ LDK::CResult_ThirtyTwoBytesPaymentErrorZ invoice_pay_res = pay_invoice (invoice2, Retry_attempts (0 ), &cm1);
1097
1095
assert (invoice_pay_res->result_ok );
1098
1096
PeerManager_process_events (&net1);
1099
1097
@@ -1128,7 +1126,7 @@ int main() {
1128
1126
assert (!memcmp (event_data->purpose .invoice_payment .payment_secret .data ,
1129
1127
Bolt11Invoice_payment_secret (invoice2), 32 ));
1130
1128
assert (event_data->amount_msat == 10000 );
1131
- assert (event_data->purpose .invoice_payment .payment_preimage .tag == LDKCOption_PaymentPreimageZ_Some );
1129
+ assert (event_data->purpose .invoice_payment .payment_preimage .tag == LDKCOption_ThirtyTwoBytesZ_Some );
1132
1130
ChannelManager_claim_funds (&cm2, event_data->purpose .invoice_payment .payment_preimage .some );
1133
1131
1134
1132
queue2.events .clear ();
0 commit comments