Ejemplo n.º 1
0
        /// <summary>
        /// Raw transaction data.
        /// </summary>
        /// <param name="wire">Iif true, include data size at the beginning.</param>
        /// <returns>Byte array with transaction data.</returns>
        public byte[] ToData(bool wire)
        {
            int txSize = 0;
            var txData = new NativeBuffer(TransactionNative.chain_transaction_to_data(nativeInstance_, wire? 1:0, ref txSize));

            return(txData.CopyToManagedArray(txSize));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Create a transaction from its binary hex representation.
 /// </summary>
 /// <param name="version">Transaction protocol version. </param>
 /// <param name="hexString">Raw transaction in hex</param>
 public Transaction(UInt32 version, string hexString)
 {
     //the raw tx is already reversed
     byte[] array = Binary.HexStringToByteArray(hexString, false);
     nativeInstance_   = TransactionNative.chain_transaction_factory_from_data(version, array, (UInt64)array.Length);
     ownsNativeObject_ = true;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 32 bytes transaction hash + 4 bytes signature hash type
        /// </summary>
        /// <param name="sigHashType"> Sighash type. </param>
        /// <returns> Hash and sighash type. </returns>
        public byte[] GetHashBySigHashType(UInt32 sigHashType)
        {
            var managedHash = new hash_t();

            TransactionNative.chain_transaction_hash_sighash_type_out(nativeInstance_, sigHashType, ref managedHash);
            return(managedHash.hash);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Create a transaction from its version, locktime, inputs and outputs (all its data).
 /// </summary>
 /// <param name="version"> Transaction protocol version. </param>
 /// <param name="locktime"> Transaction locktime. </param>
 /// <param name="inputs"> A list with all the transaction inputs. </param>
 /// <param name="outputs"> A list with all the transaction outputs. </param>
 public Transaction(UInt32 version, UInt32 locktime, InputList inputs, OutputList outputs)
 {
     nativeInstance_ = TransactionNative.chain_transaction_construct
                       (
         version, locktime, inputs.NativeInstance, outputs.NativeInstance
                       );
     ownsNativeObject_ = true;
 }
Ejemplo n.º 5
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         //Release managed resources and call Dispose for member variables
     }
     //Release unmanaged resources
     if (ownsNativeObject_)
     {
         //Logger.Log("Destroying transaction " + nativeInstance_.ToString("X") + " ...");
         TransactionNative.chain_transaction_destruct(nativeInstance_);
         //Logger.Log("Transaction " + nativeInstance_.ToString("X") + " destroyed!");
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Amount of signature operations in the transactions.
 /// </summary>
 /// <param name="bip16Active"> True if and only if BIP16 is active, false otherwise. </param>
 /// <returns></returns>
 public UInt64 GetSignatureOperationsBip16Active(bool bip16Active)
 {
     return(TransactionNative.chain_transaction_signature_operations_bip16_active(nativeInstance_, bip16Active ? 1 : 0));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Transaction size in bytes.
 /// </summary>
 /// <param name="wire"> If and only if true, size will
 /// include size of 'uint32' for storing spender output height </param>
 /// <returns> Size in bytes. </returns>
 public UInt64 GetSerializedSize(bool wire = true)
 {
     return(TransactionNative.chain_transaction_serialized_size(nativeInstance_, wire ? 1 : 0));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Returns true if and only if at least one of the inputs is not mature,
 /// false otherwise.
 /// </summary>
 /// <param name="targetHeight"></param>
 /// <returns></returns>
 public bool IsImmature(UInt64 targetHeight)
 {
     return(TransactionNative.chain_transaction_is_immature(nativeInstance_, targetHeight) != 0);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Returns true if and only if the transaction is final,
 /// false otherwise.
 /// </summary>
 /// <param name="blockHeight"></param>
 /// <param name="blockTime"></param>
 /// <returns></returns>
 public bool IsFinal(UInt64 blockHeight, UInt32 blockTime)
 {
     return(TransactionNative.chain_transaction_is_final(nativeInstance_, blockHeight, blockTime) != 0);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Returns true if at least one of the previous outputs was already spent,
 /// false otherwise.
 /// </summary>
 /// <param name="includeUnconfirmed"> Iif true, consider unconfirmed transactions. </param>
 /// <returns> True if and only if transaction is double spend. </returns>
 public bool IsDoubleSpend(bool includeUnconfirmed)
 {
     return(TransactionNative.chain_transaction_is_double_spend(nativeInstance_, includeUnconfirmed ? 1 : 0) != 0);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Create an empty tramsaction.
 /// </summary>
 public Transaction()
 {
     nativeInstance_   = TransactionNative.chain_transaction_construct_default();
     ownsNativeObject_ = true;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Amount of signature operations in the transactions.
 /// </summary>
 /// <param name="bip16Active"> True if and only if BIP16 is active, false otherwise. </param>
 /// <returns></returns>
 public UInt64 GetSignatureOperationsBip16Active(bool bip16Active)
 {
     return(TransactionNative.kth_chain_transaction_signature_operations_bip16_active(nativeInstance_, Helper.BoolToC(bip16Active)));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Transaction size in bytes.
 /// </summary>
 /// <param name="wire"> If and only if true, size will
 /// include size of 'uint32' for storing spender output height </param>
 /// <returns> Size in bytes. </returns>
 public UInt64 GetSerializedSize(bool wire = true)
 {
     return(TransactionNative.kth_chain_transaction_serialized_size(nativeInstance_, Helper.BoolToC(wire)));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Returns true if at least one of the previous outputs was already spent,
 /// false otherwise.
 /// </summary>
 /// <param name="includeUnconfirmed"> Iif true, consider unconfirmed transactions. </param>
 /// <returns> True if and only if transaction is double spend. </returns>
 public bool IsDoubleSpend(bool includeUnconfirmed)
 {
     return(TransactionNative.kth_chain_transaction_is_double_spend(nativeInstance_, Helper.BoolToC(includeUnconfirmed)) != 0);
 }