namespace org { namespace ldk { namespace structs {
/**
- * The reason the channel was closed. See individual variants more details.
+ * The reason the channel was closed. See individual variants for more details.
*/
public class ClosureReason : CommonBase {
protected ClosureReason(object _dummy, long ptr) : base(ptr) { }
case 5: return new ClosureReason_ProcessingError(ptr);
case 6: return new ClosureReason_DisconnectedPeer(ptr);
case 7: return new ClosureReason_OutdatedChannelManager(ptr);
+ case 8: return new ClosureReason_CounterpartyCoopClosedUnfundedChannel(ptr);
+ case 9: return new ClosureReason_FundingBatchClosure(ptr);
default:
throw new ArgumentException("Impossible enum variant");
}
/**
* The error which the peer sent us.
*
- * The string should be sanitized before it is used (e.g emitted to logs
- * or printed to stdout). Otherwise, a well crafted error message may exploit
+ * Be careful about printing the peer_msg, a well-crafted message could exploit
* a security vulnerability in the terminal emulator or the logging subsystem.
+ * To be safe, use `Display` on `UntrustedString`
+ *
+ * [`UntrustedString`]: crate::util::string::UntrustedString
*/
- public string peer_msg;
+ public UntrustedString peer_msg;
internal ClosureReason_CounterpartyForceClosed(long ptr) : base(null, ptr) {
- this.peer_msg = bindings.LDKClosureReason_CounterpartyForceClosed_get_peer_msg(ptr);
+ long peer_msg = bindings.LDKClosureReason_CounterpartyForceClosed_get_peer_msg(ptr);
+ org.ldk.structs.UntrustedString peer_msg_hu_conv = null; if (peer_msg < 0 || peer_msg > 4096) { peer_msg_hu_conv = new org.ldk.structs.UntrustedString(null, peer_msg); }
+ if (peer_msg_hu_conv != null) { peer_msg_hu_conv.ptrs_to.AddLast(this); };
+ this.peer_msg = peer_msg_hu_conv;
}
}
/** A ClosureReason of type HolderForceClosed */
*/
public string err;
internal ClosureReason_ProcessingError(long ptr) : base(null, ptr) {
- this.err = bindings.LDKClosureReason_ProcessingError_get_err(ptr);
+ long err = bindings.LDKClosureReason_ProcessingError_get_err(ptr);
+ string err_conv = InternalUtils.decodeString(err);
+ this.err = err_conv;
}
}
/** A ClosureReason of type DisconnectedPeer */
internal ClosureReason_OutdatedChannelManager(long ptr) : base(null, ptr) {
}
}
+ /** A ClosureReason of type CounterpartyCoopClosedUnfundedChannel */
+ public class ClosureReason_CounterpartyCoopClosedUnfundedChannel : ClosureReason {
+ internal ClosureReason_CounterpartyCoopClosedUnfundedChannel(long ptr) : base(null, ptr) {
+ }
+ }
+ /** A ClosureReason of type FundingBatchClosure */
+ public class ClosureReason_FundingBatchClosure : ClosureReason {
+ internal ClosureReason_FundingBatchClosure(long ptr) : base(null, ptr) {
+ }
+ }
internal long clone_ptr() {
long ret = bindings.ClosureReason_clone_ptr(this.ptr);
GC.KeepAlive(this);
/**
* Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason
*/
- public static ClosureReason counterparty_force_closed(string peer_msg) {
- long ret = bindings.ClosureReason_counterparty_force_closed(peer_msg);
+ public static ClosureReason counterparty_force_closed(org.ldk.structs.UntrustedString peer_msg) {
+ long ret = bindings.ClosureReason_counterparty_force_closed(peer_msg == null ? 0 : peer_msg.ptr);
GC.KeepAlive(peer_msg);
if (ret >= 0 && ret <= 4096) { return null; }
org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(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(peer_msg); };
return ret_hu_conv;
}
* Utility method to constructs a new ProcessingError-variant ClosureReason
*/
public static ClosureReason processing_error(string err) {
- long ret = bindings.ClosureReason_processing_error(err);
+ long ret = bindings.ClosureReason_processing_error(InternalUtils.encodeString(err));
GC.KeepAlive(err);
if (ret >= 0 && ret <= 4096) { return null; }
org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
return ret_hu_conv;
}
+ /**
+ * Utility method to constructs a new CounterpartyCoopClosedUnfundedChannel-variant ClosureReason
+ */
+ public static ClosureReason counterparty_coop_closed_unfunded_channel() {
+ long ret = bindings.ClosureReason_counterparty_coop_closed_unfunded_channel();
+ if (ret >= 0 && ret <= 4096) { return null; }
+ org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Utility method to constructs a new FundingBatchClosure-variant ClosureReason
+ */
+ public static ClosureReason funding_batch_closure() {
+ long ret = bindings.ClosureReason_funding_batch_closure();
+ if (ret >= 0 && ret <= 4096) { return null; }
+ org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
+ return ret_hu_conv;
+ }
+
/**
* Checks if two ClosureReasons contain equal inner contents.
* This ignores pointers and is_owned flags and looks at the values in fields.
* Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read
*/
public byte[] write() {
- byte[] ret = bindings.ClosureReason_write(this.ptr);
+ long ret = bindings.ClosureReason_write(this.ptr);
GC.KeepAlive(this);
- return ret;
+ if (ret >= 0 && ret <= 4096) { return null; }
+ byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
+ return ret_conv;
}
}