@@ -97,10 +97,11 @@ const uint8_t block_2[81] = {
97
97
0x00 , // transaction count
98
98
};
99
99
100
- void print_log (const void *this_arg, const LDKRecord *record) {
101
- LDK::Str mod = Record_get_module_path (record);
102
- LDK::Str str = Record_get_args (record);
103
- printf (" %p - %.*s:%d - %.*s\n " , this_arg, (int )mod->len , mod->chars , Record_get_line (record), (int )str->len , str->chars );
100
+ void print_log (const void *this_arg, LDKRecord record_arg) {
101
+ LDK::Record record (std::move (record_arg));
102
+ LDK::Str mod = Record_get_module_path (&record);
103
+ LDK::Str str = Record_get_args (&record);
104
+ printf (" %p - %.*s:%d - %.*s\n " , this_arg, (int )mod->len , mod->chars , Record_get_line (&record), (int )str->len , str->chars );
104
105
}
105
106
106
107
uint32_t get_fee (const void *this_arg, LDKConfirmationTarget target) {
@@ -132,7 +133,7 @@ struct NodeMonitors {
132
133
void ConnectBlock (const uint8_t (*header)[80], uint32_t height, LDKCVec_C2Tuple_usizeTransactionZZ tx_data, LDKBroadcasterInterface broadcast, LDKFeeEstimator fee_est) {
133
134
std::unique_lock<std::mutex> l (mut);
134
135
for (auto & mon : mons) {
135
- LDK::CVec_TransactionOutputsZ res = ChannelMonitor_block_connected (&mon.second , header, tx_data, height, broadcast, fee_est, * logger);
136
+ LDK::CVec_TransactionOutputsZ res = ChannelMonitor_block_connected (&mon.second , header, tx_data, height, broadcast, fee_est, logger);
136
137
}
137
138
}
138
139
};
@@ -400,6 +401,12 @@ LDKCVec_u8Z custom_onion_msg_bytes(const void *this_arg) {
400
401
.data = bytes, .datalen = 1024
401
402
};
402
403
}
404
+ LDKStr custom_onion_msg_str (const void *this_arg) {
405
+ return LDKStr {
406
+ .chars = (const uint8_t *)" Custom Onion Message" ,
407
+ .len = 20 , .chars_is_owned = false
408
+ };
409
+ }
403
410
404
411
LDKCOption_OnionMessageContentsZ handle_custom_onion_message (const void * this_arg, struct LDKOnionMessageContents msg) {
405
412
CustomOnionMsgQueue* arg = (CustomOnionMsgQueue*) this_arg;
@@ -413,6 +420,8 @@ LDKOnionMessageContents build_custom_onion_message() {
413
420
.this_arg = NULL ,
414
421
.tlv_type = custom_onion_msg_type_id,
415
422
.write = custom_onion_msg_bytes,
423
+ .debug_str = custom_onion_msg_str,
424
+ .cloned = NULL ,
416
425
.free = NULL ,
417
426
};
418
427
}
@@ -502,7 +511,7 @@ LDKInitFeatures custom_init_features(const void *this_arg, struct LDKPublicKey t
502
511
return InitFeatures_empty ();
503
512
}
504
513
505
- uint64_t get_chan_score (const void *this_arg, uint64_t scid, const LDKNodeId *src, const LDKNodeId *dst , LDKChannelUsage usage_in, const LDKProbabilisticScoringFeeParameters *params) {
514
+ uint64_t get_chan_score (const void *this_arg, const LDKCandidateRouteHop *hop , LDKChannelUsage usage_in, const LDKProbabilisticScoringFeeParameters *params) {
506
515
LDK::ChannelUsage usage (std::move (usage_in));
507
516
return 42 ;
508
517
}
@@ -602,7 +611,7 @@ int main() {
602
611
LDK::IgnoringMessageHandler ignoring_handler1 = IgnoringMessageHandler_new ();
603
612
LDK::CustomMessageHandler custom_msg_handler1 = IgnoringMessageHandler_as_CustomMessageHandler (&ignoring_handler1);
604
613
LDK::CustomOnionMessageHandler custom_onion_msg_handler1 = IgnoringMessageHandler_as_CustomOnionMessageHandler (&ignoring_handler1);
605
- LDK::DefaultMessageRouter mr1 = DefaultMessageRouter_new ();
614
+ LDK::DefaultMessageRouter mr1 = DefaultMessageRouter_new (&net_graph1, KeysManager_as_EntropySource (&keys1) );
606
615
LDK::OnionMessenger om1 = OnionMessenger_new (KeysManager_as_EntropySource (&keys1), KeysManager_as_NodeSigner (&keys1), logger1, DefaultMessageRouter_as_MessageRouter (&mr1), IgnoringMessageHandler_as_OffersMessageHandler (&ignoring_handler1), std::move (custom_onion_msg_handler1));
607
616
608
617
LDK::CVec_ChannelDetailsZ channels = ChannelManager_list_channels (&cm1);
@@ -638,7 +647,7 @@ int main() {
638
647
LDK::IgnoringMessageHandler ignoring_handler2 = IgnoringMessageHandler_new ();
639
648
LDK::CustomMessageHandler custom_msg_handler2 = IgnoringMessageHandler_as_CustomMessageHandler (&ignoring_handler2);
640
649
LDK::CustomOnionMessageHandler custom_onion_msg_handler2 = IgnoringMessageHandler_as_CustomOnionMessageHandler (&ignoring_handler2);
641
- LDK::DefaultMessageRouter mr2 = DefaultMessageRouter_new ();
650
+ LDK::DefaultMessageRouter mr2 = DefaultMessageRouter_new (&net_graph2, KeysManager_as_EntropySource (&keys2) );
642
651
LDK::OnionMessenger om2 = OnionMessenger_new (KeysManager_as_EntropySource (&keys2), KeysManager_as_NodeSigner (&keys2), logger2, DefaultMessageRouter_as_MessageRouter (&mr2), IgnoringMessageHandler_as_OffersMessageHandler (&ignoring_handler2), std::move (custom_onion_msg_handler2));
643
652
644
653
LDK::CVec_ChannelDetailsZ channels2 = ChannelManager_list_channels (&cm2);
@@ -659,7 +668,7 @@ int main() {
659
668
PeersConnection conn (cm1, cm2, net1, net2);
660
669
661
670
// Note that we have to bind the result to a C++ class to make sure it gets free'd
662
- LDK::CResult_ThirtyTwoBytesAPIErrorZ res = ChannelManager_create_channel (&cm1, ChannelManager_get_our_node_id (&cm2), 40000 , 1000 , U128_new (user_id_1), UserConfig_default ());
671
+ LDK::CResult_ThirtyTwoBytesAPIErrorZ res = ChannelManager_create_channel (&cm1, ChannelManager_get_our_node_id (&cm2), 40000 , 1000 , U128_new (user_id_1), COption_ThirtyTwoBytesZ_none (), UserConfig_default ());
663
672
assert (res->result_ok );
664
673
PeerManager_process_events (&net1);
665
674
@@ -862,7 +871,7 @@ int main() {
862
871
}, Bolt11Invoice_min_final_cltv_expiry_delta (invoice->contents .result ));
863
872
LDK::RouteParameters route_params = RouteParameters_from_payment_params_and_value (
864
873
PaymentParameters_new (std::move (payee), COption_u64Z_none (), 0xffffffff , 1 , 2 ,
865
- LDKCVec_u64Z { .data = NULL , .datalen = 0 }),
874
+ LDKCVec_u64Z { .data = NULL , .datalen = 0 }, LDKCVec_u64Z { . data = NULL , . datalen = 0 } ),
866
875
5000 );
867
876
random_bytes = entropy_source1.get_secure_random_bytes ();
868
877
LDK::ProbabilisticScoringFeeParameters params = ProbabilisticScoringFeeParameters_default ();
@@ -978,7 +987,7 @@ int main() {
978
987
LDK::MultiThreadedLockableScore scorer_mtx1 = MultiThreadedLockableScore_new (std::move (scorer_trait1));
979
988
LDK::LockableScore scorer_mtx_trait1 = MultiThreadedLockableScore_as_LockableScore (&scorer_mtx1);
980
989
LDK::ProbabilisticScoringFeeParameters params = ProbabilisticScoringFeeParameters_default ();
981
- const LDK::DefaultRouter default_router_1 = DefaultRouter_new (&net_graph1, logger1, entropy_source1. get_secure_random_bytes ( ), std::move (scorer_mtx_trait1), std::move (params));
990
+ const LDK::DefaultRouter default_router_1 = DefaultRouter_new (&net_graph1, logger1, KeysManager_as_EntropySource (&keys1 ), std::move (scorer_mtx_trait1), std::move (params));
982
991
LDKRouter router1 = {
983
992
.this_arg = (void *)&default_router_1,
984
993
.find_route = NULL , // LDK currently doesn't use this, its just a default-impl
@@ -999,7 +1008,7 @@ int main() {
999
1008
.release_pending_custom_messages = release_no_messages,
1000
1009
.free = NULL ,
1001
1010
};
1002
- LDK::DefaultMessageRouter mr1 = DefaultMessageRouter_new ();
1011
+ LDK::DefaultMessageRouter mr1 = DefaultMessageRouter_new (&net_graph1, KeysManager_as_EntropySource (&keys1) );
1003
1012
LDK::IgnoringMessageHandler ignorer_1 = IgnoringMessageHandler_new ();
1004
1013
LDK::OnionMessenger om1 = OnionMessenger_new (KeysManager_as_EntropySource (&keys1), KeysManager_as_NodeSigner (&keys1), logger1, DefaultMessageRouter_as_MessageRouter (&mr1), IgnoringMessageHandler_as_OffersMessageHandler (&ignorer_1), std::move (custom_onion_msg_handler1));
1005
1014
@@ -1027,7 +1036,7 @@ int main() {
1027
1036
.release_pending_custom_messages = release_no_messages,
1028
1037
.free = NULL ,
1029
1038
};
1030
- LDK::DefaultMessageRouter mr2 = DefaultMessageRouter_new ();
1039
+ LDK::DefaultMessageRouter mr2 = DefaultMessageRouter_new (&net_graph2, KeysManager_as_EntropySource (&keys2) );
1031
1040
LDK::IgnoringMessageHandler ignorer_2 = IgnoringMessageHandler_new ();
1032
1041
LDK::OnionMessenger om2 = OnionMessenger_new (KeysManager_as_EntropySource (&keys2), KeysManager_as_NodeSigner (&keys2), logger2, DefaultMessageRouter_as_MessageRouter (&mr2), IgnoringMessageHandler_as_OffersMessageHandler (&ignorer_2), custom_onion_msg_handler2);
1033
1042
@@ -1098,7 +1107,16 @@ int main() {
1098
1107
}, 3600 , COption_u16Z_none ());
1099
1108
assert (invoice_res2->result_ok );
1100
1109
const LDKBolt11Invoice *invoice2 = invoice_res2->contents .result ;
1101
- LDK::CResult_ThirtyTwoBytesPaymentErrorZ invoice_pay_res = pay_invoice (invoice2, Retry_attempts (0 ), &cm1);
1110
+ LDK::CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ pay_params =
1111
+ payment_parameters_from_invoice (invoice2);
1112
+ LDK::RecipientOnionFields invoice2_recipient (std::move (pay_params->contents .result ->b ));
1113
+ LDK::RouteParameters invoice2_params (std::move (pay_params->contents .result ->c ));
1114
+ assert (pay_params->result_ok );
1115
+ LDKThirtyTwoBytes payment_id { .data = 0 };
1116
+ LDK::CResult_NoneRetryableSendFailureZ invoice_pay_res = ChannelManager_send_payment (
1117
+ &cm1, std::move (pay_params->contents .result ->a ), std::move (invoice2_recipient),
1118
+ std::move (payment_id), std::move (invoice2_params), Retry_attempts (0 )
1119
+ );
1102
1120
assert (invoice_pay_res->result_ok );
1103
1121
PeerManager_process_events (&net1);
1104
1122
@@ -1180,14 +1198,12 @@ int main() {
1180
1198
LDK::CVec_ChannelDetailsZ chans_after_close2 = ChannelManager_list_channels (&cm2);
1181
1199
assert (chans_after_close2->datalen == 0 );
1182
1200
1183
- assert (OnionMessenger_send_onion_message (&om1,
1184
- OnionMessagePath_new (
1185
- LDKCVec_PublicKeyZ { .data = NULL , .datalen = 0 , },
1186
- Destination_node (ChannelManager_get_our_node_id (&cm2))
1187
- ),
1201
+ LDK::CResult_SendSuccessSendErrorZ om_send_res =
1202
+ OnionMessenger_send_onion_message (&om1,
1188
1203
build_custom_onion_message (),
1189
- LDKBlindedPath { .inner = NULL , .is_owned = true })
1190
- .result_ok );
1204
+ Destination_node (ChannelManager_get_our_node_id (&cm2)),
1205
+ LDKBlindedPath { .inner = NULL , .is_owned = true });
1206
+ assert (om_send_res->result_ok );
1191
1207
PeerManager_process_events (&net1);
1192
1208
std::cout << __FILE__ << " :" << __LINE__ << " - " << " Awaiting onion message..." << std::endl;
1193
1209
while (true ) {
0 commit comments