X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FOnionMessagePath.cs;h=8c825a435ce67e62642610fa47c36090943e9162;hb=592c64eb658d92e314a2b983cea16cecf3882474;hp=fca88d9716f9f5ea06d97c24baa72eaa08d4bb83;hpb=7811d2191440c55034e1abfbf3be442d4b25481b;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/OnionMessagePath.cs b/c_sharp/src/org/ldk/structs/OnionMessagePath.cs index fca88d97..8c825a43 100644 --- a/c_sharp/src/org/ldk/structs/OnionMessagePath.cs +++ b/c_sharp/src/org/ldk/structs/OnionMessagePath.cs @@ -7,7 +7,7 @@ namespace org { namespace ldk { namespace structs { /** - * A path for sending an [`msgs::OnionMessage`]. + * A path for sending an [`OnionMessage`]. */ public class OnionMessagePath : CommonBase { internal OnionMessagePath(object _dummy, long ptr) : base(ptr) { } @@ -21,16 +21,25 @@ public class OnionMessagePath : CommonBase { * Returns a copy of the field. */ public byte[][] get_intermediate_nodes() { - byte[][] ret = bindings.OnionMessagePath_get_intermediate_nodes(this.ptr); + long ret = bindings.OnionMessagePath_get_intermediate_nodes(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + int ret_conv_8_len = InternalUtils.getArrayLength(ret); + byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][]; + for (int i = 0; i < ret_conv_8_len; i++) { + long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i); + byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8); + ret_conv_8_arr[i] = ret_conv_8_conv; + } + bindings.free_buffer(ret); + return ret_conv_8_arr; } /** * Nodes on the path between the sender and the destination. */ public void set_intermediate_nodes(byte[][] val) { - bindings.OnionMessagePath_set_intermediate_nodes(this.ptr, val != null ? InternalUtils.mapArray(val, val_conv_8 => InternalUtils.check_arr_len(val_conv_8, 33)) : null); + bindings.OnionMessagePath_set_intermediate_nodes(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val_conv_8, 33))))); GC.KeepAlive(this); GC.KeepAlive(val); } @@ -57,17 +66,49 @@ public class OnionMessagePath : CommonBase { if (this != null) { this.ptrs_to.AddLast(val); }; } + /** + * Addresses that may be used to connect to [`OnionMessagePath::first_node`]. + * + * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use + * this to initiate such a connection. + * + * Returns a copy of the field. + */ + public Option_CVec_SocketAddressZZ get_first_node_addresses() { + long ret = bindings.OnionMessagePath_get_first_node_addresses(this.ptr); + GC.KeepAlive(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.Option_CVec_SocketAddressZZ ret_hu_conv = org.ldk.structs.Option_CVec_SocketAddressZZ.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); }; + return ret_hu_conv; + } + + /** + * Addresses that may be used to connect to [`OnionMessagePath::first_node`]. + * + * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use + * this to initiate such a connection. + */ + public void set_first_node_addresses(org.ldk.structs.Option_CVec_SocketAddressZZ val) { + bindings.OnionMessagePath_set_first_node_addresses(this.ptr, val.ptr); + GC.KeepAlive(this); + GC.KeepAlive(val); + if (this != null) { this.ptrs_to.AddLast(val); }; + } + /** * Constructs a new OnionMessagePath given each field */ - public static OnionMessagePath of(byte[][] intermediate_nodes_arg, org.ldk.structs.Destination destination_arg) { - long ret = bindings.OnionMessagePath_new(intermediate_nodes_arg != null ? InternalUtils.mapArray(intermediate_nodes_arg, intermediate_nodes_arg_conv_8 => InternalUtils.check_arr_len(intermediate_nodes_arg_conv_8, 33)) : null, destination_arg.ptr); + public static OnionMessagePath of(byte[][] intermediate_nodes_arg, org.ldk.structs.Destination destination_arg, org.ldk.structs.Option_CVec_SocketAddressZZ first_node_addresses_arg) { + long ret = bindings.OnionMessagePath_new(InternalUtils.encodeUint64Array(InternalUtils.mapArray(intermediate_nodes_arg, intermediate_nodes_arg_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(intermediate_nodes_arg_conv_8, 33)))), destination_arg.ptr, first_node_addresses_arg.ptr); GC.KeepAlive(intermediate_nodes_arg); GC.KeepAlive(destination_arg); + GC.KeepAlive(first_node_addresses_arg); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.OnionMessagePath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionMessagePath(null, ret); } if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(destination_arg); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(first_node_addresses_arg); }; return ret_hu_conv; } @@ -89,5 +130,18 @@ public class OnionMessagePath : CommonBase { return ret_hu_conv; } + /** + * Returns the first node in the path. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + public byte[] first_node() { + long ret = bindings.OnionMessagePath_first_node(this.ptr); + GC.KeepAlive(this); + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; + } + } } } }