return descriptor;
}
- private static v4_addr_from_ip(ip: string, port: number): ldk.NetAddress {
+ private static v4_addr_from_ip(ip: string, port: number): ldk.SocketAddress {
const sockaddr = ip.split(".").map(parseFloat);
- return ldk.NetAddress.constructor_ipv4(new Uint8Array(sockaddr), port);
+ return ldk.SocketAddress.constructor_tcp_ip_v4(new Uint8Array(sockaddr), port);
}
- private static v6_addr_from_ip(ip: string, port: number): ldk.NetAddress {
+ private static v6_addr_from_ip(ip: string, port: number): ldk.SocketAddress {
const sockaddr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
const halves = ip.split("::"); // either one or two elements
const first_half = halves[0].split(":");
sockaddr[15 - idx*2] = v & 0xff;
}
}
- return ldk.NetAddress.constructor_ipv6(new Uint8Array(sockaddr), port);
+ return ldk.SocketAddress.constructor_tcp_ip_v6(new Uint8Array(sockaddr), port);
}
- private static get_addr_from_socket(socket: net.Socket): ldk.Option_NetAddressZ {
+ private static get_addr_from_socket(socket: net.Socket): ldk.Option_SocketAddressZ {
const addr = socket.remoteAddress;
if (addr === undefined)
- return ldk.Option_NetAddressZ.constructor_none();
+ return ldk.Option_SocketAddressZ.constructor_none();
if (net.isIPv4(addr)) {
- return ldk.Option_NetAddressZ.constructor_some(NodeLDKNet.v4_addr_from_ip(addr, socket.remotePort));
+ return ldk.Option_SocketAddressZ.constructor_some(NodeLDKNet.v4_addr_from_ip(addr, socket.remotePort));
}
if (net.isIPv6(addr)) {
- return ldk.Option_NetAddressZ.constructor_some(NodeLDKNet.v6_addr_from_ip(addr, socket.remotePort));
+ return ldk.Option_SocketAddressZ.constructor_some(NodeLDKNet.v6_addr_from_ip(addr, socket.remotePort));
}
- return ldk.Option_NetAddressZ.constructor_none();
+ return ldk.Option_SocketAddressZ.constructor_none();
}
/**
}
const v4_parse = node_net.NodeLDKNet["v4_addr_from_ip"];
-console.assert((v4_parse("127.0.0.1", 4242) as ldk.NetAddress_IPv4).port == 4242);
-console.assert(arr_eq((v4_parse("127.0.0.1", 4242) as ldk.NetAddress_IPv4).addr, [127,0,0,1]));
-console.assert(arr_eq((v4_parse("0.0.0.0", 4242) as ldk.NetAddress_IPv4).addr, [0,0,0,0]));
+console.assert((v4_parse("127.0.0.1", 4242) as ldk.SocketAddress_TcpIpV4).port == 4242);
+console.assert(arr_eq((v4_parse("127.0.0.1", 4242) as ldk.SocketAddress_TcpIpV4).addr, [127,0,0,1]));
+console.assert(arr_eq((v4_parse("0.0.0.0", 4242) as ldk.SocketAddress_TcpIpV4).addr, [0,0,0,0]));
const v6_parse = node_net.NodeLDKNet["v6_addr_from_ip"];
-console.assert((v6_parse("::", 4242) as ldk.NetAddress_IPv4).port == 4242);
-console.assert(arr_eq((v6_parse("::", 4242) as ldk.NetAddress_IPv6).addr,
+console.assert((v6_parse("::", 4242) as ldk.SocketAddress_TcpIpV4).port == 4242);
+console.assert(arr_eq((v6_parse("::", 4242) as ldk.SocketAddress_TcpIpV6).addr,
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]));
-console.assert(arr_eq((v6_parse("fe80::", 4242) as ldk.NetAddress_IPv6).addr,
+console.assert(arr_eq((v6_parse("fe80::", 4242) as ldk.SocketAddress_TcpIpV6).addr,
[0xfe,0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0]));
-console.assert(arr_eq((v6_parse("fe80::42", 4242) as ldk.NetAddress_IPv6).addr,
+console.assert(arr_eq((v6_parse("fe80::42", 4242) as ldk.SocketAddress_TcpIpV6).addr,
[0xfe,0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0x42]));
-console.assert(arr_eq((v6_parse("fe80:A:b::", 4242) as ldk.NetAddress_IPv6).addr,
+console.assert(arr_eq((v6_parse("fe80:A:b::", 4242) as ldk.SocketAddress_TcpIpV6).addr,
[0xfe,0x80,0,0xa,0,0xb,0,0,0,0,0,0,0,0,0,0]));
-console.assert(arr_eq((v6_parse("2001:1:bad::beef:cafe", 4242) as ldk.NetAddress_IPv6).addr,
+console.assert(arr_eq((v6_parse("2001:1:bad::beef:cafe", 4242) as ldk.SocketAddress_TcpIpV6).addr,
[0x20, 0x01, 0, 1, 0xb, 0xad, 0, 0, 0, 0, 0, 0, 0xbe, 0xef, 0xca, 0xfe]));
const features = a.chan_man.as_ChannelMessageHandler().provided_init_features(b.chan_man.get_our_node_id());
- a.chan_man.as_ChannelMessageHandler().peer_connected(b.chan_man.get_our_node_id(), ldk.Init.constructor_new(features, ldk.Option_CVec_ChainHashZZ.constructor_none(), ldk.Option_NetAddressZ.constructor_none()), false);
- b.chan_man.as_ChannelMessageHandler().peer_connected(a.chan_man.get_our_node_id(), ldk.Init.constructor_new(features, ldk.Option_CVec_ChainHashZZ.constructor_none(), ldk.Option_NetAddressZ.constructor_none()), true);
+ a.chan_man.as_ChannelMessageHandler().peer_connected(b.chan_man.get_our_node_id(), ldk.Init.constructor_new(features, ldk.Option_CVec_ThirtyTwoBytesZZ.constructor_none(), ldk.Option_SocketAddressZ.constructor_none()), false);
+ b.chan_man.as_ChannelMessageHandler().peer_connected(a.chan_man.get_our_node_id(), ldk.Init.constructor_new(features, ldk.Option_CVec_ThirtyTwoBytesZZ.constructor_none(), ldk.Option_SocketAddressZ.constructor_none()), true);
const chan_create_err = a.chan_man.create_channel(b.chan_man.get_our_node_id(), BigInt(0), BigInt(400), BigInt(0), ldk.UserConfig.constructor_default());
if (chan_create_err.is_ok()) return false;
- if (!(chan_create_err instanceof ldk.Result__u832APIErrorZ_Err)) return false;
+ if (!(chan_create_err instanceof ldk.Result_ThirtyTwoBytesAPIErrorZ_Err)) return false;
if (!(chan_create_err.err instanceof ldk.APIError_APIMisuseError)) return false;
if (chan_create_err.err.err != "Channel value must be at least 1000 satoshis. It was 0") return false;
}
} as ldk.SocketDescriptorInterface);
- const update_fut = a.chan_man.get_persistable_update_future();
+ const update_fut = a.chan_man.get_event_or_persistence_needed_future();
var update_done = false;
update_fut.register_callback_fn(ldk.FutureCallback.new_impl({
call(): void { update_done = true; }
}));
if (update_done) return false;
- const v4_netaddr = ldk.NetAddress.constructor_ipv4(Uint8Array.from([42,0,42,1]), 9735);
- assert(pm_b.new_inbound_connection(sock_b, ldk.Option_NetAddressZ.constructor_some(v4_netaddr)) instanceof ldk.Result_NonePeerHandleErrorZ_OK);
- const init_bytes = pm_a.new_outbound_connection(b.node_id, sock_a, ldk.Option_NetAddressZ.constructor_none());
+ const v4_netaddr = ldk.SocketAddress.constructor_tcp_ip_v4(Uint8Array.from([42,0,42,1]), 9735);
+ assert(pm_b.new_inbound_connection(sock_b, ldk.Option_SocketAddressZ.constructor_some(v4_netaddr)) instanceof ldk.Result_NonePeerHandleErrorZ_OK);
+ const init_bytes = pm_a.new_outbound_connection(b.node_id, sock_a, ldk.Option_SocketAddressZ.constructor_none());
if (!(init_bytes instanceof ldk.Result_CVec_u8ZPeerHandleErrorZ_OK)) return false;
assert(pm_b.read_event(sock_b, init_bytes.res) instanceof ldk.Result_boolPeerHandleErrorZ_OK);
}
} as ldk.SocketDescriptorInterface);
- const v4_netaddr = ldk.NetAddress.constructor_ipv4(Uint8Array.from([42,0,42,1]), 9735);
- assert(pm_b.new_inbound_connection(sock_b, ldk.Option_NetAddressZ.constructor_some(v4_netaddr)) instanceof ldk.Result_NonePeerHandleErrorZ_OK);
- const init_bytes = pm_a.new_outbound_connection(b.node_id, sock_a, ldk.Option_NetAddressZ.constructor_none());
+ const v4_netaddr = ldk.SocketAddress.constructor_tcp_ip_v4(Uint8Array.from([42,0,42,1]), 9735);
+ assert(pm_b.new_inbound_connection(sock_b, ldk.Option_SocketAddressZ.constructor_some(v4_netaddr)) instanceof ldk.Result_NonePeerHandleErrorZ_OK);
+ const init_bytes = pm_a.new_outbound_connection(b.node_id, sock_a, ldk.Option_SocketAddressZ.constructor_none());
if (!(init_bytes instanceof ldk.Result_CVec_u8ZPeerHandleErrorZ_OK)) return false;
assert(pm_b.read_event(sock_b, init_bytes.res) instanceof ldk.Result_boolPeerHandleErrorZ_OK);