+struct CustomOnionMsgQueue {
+ std::mutex mtx;
+ std::vector<LDK::CustomOnionMessageContents> msgs;
+};
+
+uint64_t custom_onion_msg_type_id(const void *this_arg) {
+ return 8888;
+}
+LDKCVec_u8Z custom_onion_msg_bytes(const void *this_arg) {
+ uint8_t *bytes = (uint8_t *) malloc(1024);
+ memset(bytes, 43, 1024);
+ return LDKCVec_u8Z {
+ .data = bytes, .datalen = 1024
+ };
+}
+
+void handle_custom_onion_message(const void* this_arg, struct LDKCustomOnionMessageContents msg) {
+ CustomOnionMsgQueue* arg = (CustomOnionMsgQueue*) this_arg;
+ std::unique_lock<std::mutex> lck(arg->mtx);
+ arg->msgs.push_back(std::move(msg));
+}
+
+LDKCustomOnionMessageContents build_custom_onion_message() {
+ return LDKCustomOnionMessageContents {
+ .this_arg = NULL,
+ .tlv_type = custom_onion_msg_type_id,
+ .write = custom_onion_msg_bytes,
+ .free = NULL,
+ };
+}
+
+LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ read_custom_onion_message(const void* this_arg, uint64_t type, LDKu8slice buf) {
+ assert(type == 8888);
+ assert(buf.datalen == 1024);
+ uint8_t cmp[1024];
+ memset(cmp, 43, 1024);
+ assert(!memcmp(cmp, buf.data, 1024));
+ return CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(COption_CustomOnionMessageContentsZ_some(build_custom_onion_message()));
+}
+
+