X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FShutdownScript.java;h=19a81ae000754325750b38a23501674b1315342a;hb=c6bac88847b7c09560af81f00ba8dd3c2ebe3a19;hp=3d4a8eb87729b96b4b85c1714a3a94e1ca346253;hpb=d92b9f26eda1f6c1fbb970db797a03fac62c5606;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ShutdownScript.java b/src/main/java/org/ldk/structs/ShutdownScript.java index 3d4a8eb8..19a81ae0 100644 --- a/src/main/java/org/ldk/structs/ShutdownScript.java +++ b/src/main/java/org/ldk/structs/ShutdownScript.java @@ -26,8 +26,8 @@ public class ShutdownScript extends CommonBase { */ public ShutdownScript clone() { long ret = bindings.ShutdownScript_clone(this.ptr); - if (ret < 1024) { return null; } - ShutdownScript ret_hu_conv = new ShutdownScript(null, ret); + if (ret >= 0 && ret <= 4096) { return null; } + ShutdownScript ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ShutdownScript(null, ret); } ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } @@ -45,40 +45,18 @@ public class ShutdownScript extends CommonBase { */ public static Result_ShutdownScriptDecodeErrorZ read(byte[] ser) { long ret = bindings.ShutdownScript_read(ser); - if (ret < 1024) { return null; } + if (ret >= 0 && ret <= 4096) { return null; } Result_ShutdownScriptDecodeErrorZ ret_hu_conv = Result_ShutdownScriptDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; } - /** - * Generates a P2PKH script pubkey from the given [`PubkeyHash`]. - */ - public static ShutdownScript new_p2pkh(byte[] pubkey_hash) { - long ret = bindings.ShutdownScript_new_p2pkh(pubkey_hash); - if (ret < 1024) { return null; } - ShutdownScript ret_hu_conv = new ShutdownScript(null, ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - return ret_hu_conv; - } - - /** - * Generates a P2SH script pubkey from the given [`ScriptHash`]. - */ - public static ShutdownScript new_p2sh(byte[] script_hash) { - long ret = bindings.ShutdownScript_new_p2sh(script_hash); - if (ret < 1024) { return null; } - ShutdownScript ret_hu_conv = new ShutdownScript(null, ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - return ret_hu_conv; - } - /** * Generates a P2WPKH script pubkey from the given [`WPubkeyHash`]. */ public static ShutdownScript new_p2wpkh(byte[] pubkey_hash) { long ret = bindings.ShutdownScript_new_p2wpkh(pubkey_hash); - if (ret < 1024) { return null; } - ShutdownScript ret_hu_conv = new ShutdownScript(null, ret); + if (ret >= 0 && ret <= 4096) { return null; } + ShutdownScript ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ShutdownScript(null, ret); } ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; } @@ -88,14 +66,17 @@ public class ShutdownScript extends CommonBase { */ public static ShutdownScript new_p2wsh(byte[] script_hash) { long ret = bindings.ShutdownScript_new_p2wsh(script_hash); - if (ret < 1024) { return null; } - ShutdownScript ret_hu_conv = new ShutdownScript(null, ret); + if (ret >= 0 && ret <= 4096) { return null; } + ShutdownScript ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ShutdownScript(null, ret); } ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; } /** - * Generates a P2WSH script pubkey from the given segwit version and program. + * Generates a witness script pubkey from the given segwit version and program. + * + * Note for version-zero witness scripts you must use [`ShutdownScript::new_p2wpkh`] or + * [`ShutdownScript::new_p2wsh`] instead. * * # Errors * @@ -103,7 +84,7 @@ public class ShutdownScript extends CommonBase { */ public static Result_ShutdownScriptInvalidShutdownScriptZ new_witness_program(byte version, byte[] program) { long ret = bindings.ShutdownScript_new_witness_program(version, program); - if (ret < 1024) { return null; } + if (ret >= 0 && ret <= 4096) { return null; } Result_ShutdownScriptInvalidShutdownScriptZ ret_hu_conv = Result_ShutdownScriptInvalidShutdownScriptZ.constr_from_ptr(ret); return ret_hu_conv; } @@ -113,7 +94,7 @@ public class ShutdownScript extends CommonBase { */ public byte[] into_inner() { byte[] ret = bindings.ShutdownScript_into_inner(this.ptr); - this.ptrs_to.add(this); + ; return ret; }