X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FPaymentId.java;fp=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FPaymentId.java;h=21c1c75ac8ba14b92cb20f7d1abc0b2e5860a50e;hb=0e5e33e2bb46c905f6c9478fbfcda11be6b309ff;hp=0000000000000000000000000000000000000000;hpb=c33c485e953a0a22246fbb749b20d441ee8e4eb3;p=ldk-java diff --git a/src/main/java/org/ldk/structs/PaymentId.java b/src/main/java/org/ldk/structs/PaymentId.java new file mode 100644 index 00000000..21c1c75a --- /dev/null +++ b/src/main/java/org/ldk/structs/PaymentId.java @@ -0,0 +1,70 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import javax.annotation.Nullable; + + +/** + * A payment identifier used to uniquely identify a payment to LDK. + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class PaymentId extends CommonBase { + PaymentId(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.PaymentId_free(ptr); } + } + + /** + * Checks if two PaymentIds contain equal inner contents. + */ + public long hash() { + long ret = bindings.PaymentId_hash(this.ptr); + return ret; + } + + /** + * Creates a copy of the PaymentId + */ + public PaymentId clone() { + long ret = bindings.PaymentId_clone(this.ptr); + if (ret >= 0 && ret < 1024) { return null; } + PaymentId ret_hu_conv = new PaymentId(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * Checks if two PaymentIds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ + public boolean eq(PaymentId b) { + boolean ret = bindings.PaymentId_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + this.ptrs_to.add(b); + return ret; + } + + /** + * Serialize the PaymentId object into a byte array which can be read by PaymentId_read + */ + public byte[] write() { + byte[] ret = bindings.PaymentId_write(this.ptr); + return ret; + } + + /** + * Read a PaymentId from a byte array, created by PaymentId_write + */ + public static Result_PaymentIdDecodeErrorZ read(byte[] ser) { + long ret = bindings.PaymentId_read(ser); + if (ret >= 0 && ret < 1024) { return null; } + Result_PaymentIdDecodeErrorZ ret_hu_conv = Result_PaymentIdDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; + } + +}