X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FShutdownScript.java;h=f60f0c25ee5dbbc2d9740f52f7a45856fef237a2;hb=f3e670e9341decac613d33fc52febf19cea32f20;hp=f6343a16847dd115c0322482a96f613ed00d8cd7;hpb=9d146759e11191b55130be7a1b6988d3f289a168;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ShutdownScript.java b/src/main/java/org/ldk/structs/ShutdownScript.java index f6343a16..f60f0c25 100644 --- a/src/main/java/org/ldk/structs/ShutdownScript.java +++ b/src/main/java/org/ldk/structs/ShutdownScript.java @@ -21,13 +21,18 @@ public class ShutdownScript extends CommonBase { if (ptr != 0) { bindings.ShutdownScript_free(ptr); } } + long clone_ptr() { + long ret = bindings.ShutdownScript_clone_ptr(this.ptr); + return ret; + } + /** * Creates a copy of the ShutdownScript */ 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 +50,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); + long ret = bindings.ShutdownScript_new_p2wpkh(InternalUtils.check_arr_len(pubkey_hash, 20)); + 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; } @@ -87,9 +70,9 @@ public class ShutdownScript extends CommonBase { * Generates a P2WSH script pubkey from the given [`WScriptHash`]. */ 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); + long ret = bindings.ShutdownScript_new_p2wsh(InternalUtils.check_arr_len(script_hash, 32)); + 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; } @@ -106,7 +89,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; }