Class Transaction

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Transaction(Pointer pointer)
      Transaction(NoPointer noPointer) This constructor can be used to instantiate a fake object.
      Transaction(ByteArray transactionBytes) Creates a new Transaction instance from serialized transaction bytes.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      Unit destroy()
      Unit close()
      final Pointer uniffiClonePointer()
      String computeTxid() Computes the Txid.
      List<TxIn> input() List of transaction inputs.
      Boolean isCoinbase() Checks if this is a coinbase transaction.
      Boolean isExplicitlyRbf() Returns true if the transaction itself opted in to be BIP-125-replaceable (RBF).
      Boolean isLockTimeEnabled() Returns true if this transactions nLockTime is enabled (BIP-65).
      UInt lockTime() Block height or timestamp.
      List<TxOut> output() List of transaction outputs.
      ByteArray serialize() Serialize transaction into consensus-valid format.
      ULong totalSize() Returns the total transaction sizeTotal transaction size is the transaction size in bytes serialized as described in BIP144, including base data and witness data.
      Integer version() The protocol version, is currently expected to be 1 or 2 (BIP 68).
      ULong vsize() Returns the "virtual size" (vsize) of this transaction.
      ULong weight() Returns the weight of this transaction, as defined by BIP-141.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Transaction

        Transaction(Pointer pointer)
      • Transaction

        Transaction(NoPointer noPointer)
        This constructor can be used to instantiate a fake object.
      • Transaction

        Transaction(ByteArray transactionBytes)
        Creates a new Transaction instance from serialized transaction bytes.
    • Method Detail

      • computeTxid

         String computeTxid()

        Computes the Txid. Hashes the transaction excluding the segwit data (i.e. the marker, flag bytes, and the witness fields themselves).

      • isCoinbase

         Boolean isCoinbase()

        Checks if this is a coinbase transaction. The first transaction in the block distributes the mining reward and is called the coinbase transaction. It is impossible to check if the transaction is first in the block, so this function checks the structure of the transaction instead - the previous output must be all-zeros (creates satoshis “out of thin air”).

      • serialize

         ByteArray serialize()

        Serialize transaction into consensus-valid format. See https://docs.rs/bitcoin/latest/bitcoin/struct.Transaction.html#serialization-notes for more notes on transaction serialization.

      • totalSize

         ULong totalSize()

        Returns the total transaction size

        Total transaction size is the transaction size in bytes serialized as described in BIP144, including base data and witness data.

      • version

         Integer version()

        The protocol version, is currently expected to be 1 or 2 (BIP 68).

      • vsize

         ULong vsize()

        Returns the "virtual size" (vsize) of this transaction.

        Will be ceil(weight / 4.0). Note this implements the virtual size as per BIP141, which is different to what is implemented in Bitcoin Core.

        Virtual transaction size is defined as Transaction weight / 4 (rounded up to the next integer).

      • weight

         ULong weight()

        Returns the weight of this transaction, as defined by BIP-141.

        Transaction weight is defined as Base transaction size * 3 + Total transaction size (ie. the same method as calculating Block weight from Base size and Total size).

        For transactions with an empty witness, this is simply the consensus-serialized size times four. For transactions with a witness, this is the non-witness consensus-serialized size multiplied by three plus the with-witness consensus-serialized size.

        For transactions with no inputs, this function will return a value 2 less than the actual weight of the serialized transaction. The reason is that zero-input transactions, post-segwit, cannot be unambiguously serialized; we make a choice that adds two extra bytes. For more details see BIP 141 which uses a "input count" of 0x00 as a marker for a Segwit-encoded transaction.

        If you need to use 0-input transactions, we strongly recommend you do so using the PSBT API. The unsigned transaction encoded within PSBT is always a non-segwit transaction and can therefore avoid this ambiguity.