Beispiel #1
0
 /// <summary>
 /// The sum of all inputs of all transactions in the block.
 /// </summary>
 /// <param name="withCoinbase">If and only if true, consider coinbase transactions. </param>
 /// <returns> UInt64 representation of the sum </returns>
 public UInt64 GetTotalInputs(bool withCoinbase)
 {
     return(BlockNative.chain_block_total_inputs
            (
                nativeInstance_, withCoinbase ? 1 : 0
            ));
 }
Beispiel #2
0
        /// <summary>
        /// Given a position in the block, returns the corresponding transaction.
        /// </summary>
        /// <param name="n"> Zero-based index </param>
        /// <returns> Full transaction object </returns>
        public ITransaction GetNthTransaction(UInt64 n)
        {
            // return new Transaction(BlockNative.kth_chain_block_transaction_nth(nativeInstance_, (UIntPtr)n), false);
            var nativeTransactionList = BlockNative.kth_chain_block_transactions(nativeInstance_);

            return(new Transaction(TransactionListNative.kth_chain_transaction_list_nth(nativeTransactionList, n), false));
        }
Beispiel #3
0
        /// <summary>
        /// Raw block data.
        /// </summary>
        /// <param name="wire">if and only if true, include data size at the beginning.</param>
        /// <returns>Byte array with block data.</returns>
        public byte[] ToData(bool wire)
        {
            int blockSize = 0;
            var blockData = new NativeBuffer(BlockNative.kth_chain_block_to_data(nativeInstance_, wire? 1:0, ref blockSize));

            return(blockData.CopyToManagedArray(blockSize));
        }
Beispiel #4
0
 /// <summary>
 /// Amount of signature operations in the block.
 /// </summary>
 /// <param name="bip16Active"> If and only if true, count bip16 active operations. </param>
 /// <returns> The amount of signature operations in this block </returns>
 public UInt64 GetSignatureOperationsCount(bool bip16Active)
 {
     return(BlockNative.chain_block_signature_operations_bip16_active
            (
                nativeInstance_, bip16Active ? 1 : 0
            ));
 }
Beispiel #5
0
 public Block(UInt32 version, string hexString)
 {
     //the raw block is already reversed
     byte[] array = Binary.HexStringToByteArray(hexString, false);
     nativeInstance_   = BlockNative.kth_chain_block_factory_from_data(version, array, (UInt64)array.Length);
     header_           = new Header(BlockNative.kth_chain_block_header(nativeInstance_), false);
     ownsNativeObject_ = true;
 }
Beispiel #6
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         //Release managed resources and call Dispose for member variables
         Header.Dispose();
     }
     //Release unmanaged resources
     if (ownsNativeObject_)
     {
         BlockNative.kth_chain_block_destruct(nativeInstance_);
     }
 }
Beispiel #7
0
 internal Block(IntPtr nativeInstance, bool ownsNativeObject = true)
 {
     nativeInstance_   = nativeInstance;
     ownsNativeObject_ = ownsNativeObject;
     header_           = new Header(BlockNative.kth_chain_block_header(nativeInstance_), false);
 }
Beispiel #8
0
 /// <summary>
 /// The sum of all inputs of all transactions in the block.
 /// </summary>
 /// <param name="withCoinbase">If and only if true, consider coinbase transactions. </param>
 /// <returns> UInt64 representation of the sum </returns>
 public UInt64 GetTotalInputs(bool withCoinbase)
 {
     return(BlockNative.kth_chain_block_total_inputs(nativeInstance_, Helper.BoolToC(withCoinbase)));
 }
Beispiel #9
0
 /// <summary>
 /// Amount of signature operations in the block.
 /// </summary>
 /// <param name="bip16Active"> If and only if true, count bip16 active operations. </param>
 /// <returns> The amount of signature operations in this block </returns>
 public UInt64 GetSignatureOperations(bool bip16Active)
 {
     return(BlockNative.kth_chain_block_signature_operations_bip16_active(nativeInstance_, Helper.BoolToC(bip16Active)));
 }
Beispiel #10
0
 /// <summary>
 /// Block size in bytes.
 /// </summary>
 /// <param name="version"> Protocol version. </param>
 /// <returns> UInt64 representation of the block size in bytes. </returns>
 public UInt64 GetSerializedSize(UInt32 version)
 {
     return(BlockNative.kth_chain_block_serialized_size(nativeInstance_, version));
 }
Beispiel #11
0
 /// <summary>
 /// Reward = Subsidy + Fees, for the block at the given height.
 /// </summary>
 /// <param name="height"> Block height in the chain; identifies it univocally. </param>
 /// <returns> UInt64 representation of the block's reward. </returns>
 public UInt64 GetBlockReward(UInt64 height)
 {
     return(BlockNative.kth_chain_block_reward(nativeInstance_, (UIntPtr)height));
 }
Beispiel #12
0
 /// <summary>
 /// The block subsidy. It's the same value for all blocks.
 /// </summary>
 /// <param name="height"> The block's height. It identifies it univocally. </param>
 /// <returns> UInt64 representation of the block subsidy </returns>
 public static UInt64 GetSubsidy(UInt64 height)
 {
     return(BlockNative.kth_chain_block_subsidy((UIntPtr)height));
 }
Beispiel #13
0
 /// <summary>
 /// Returns true if and only if the block's coinbase script is valid.
 /// </summary>
 /// <param name="height"> The block's height. Identifies it univocally. </param>
 /// <returns>True if and only if the block's coinbase script is valid.</returns>
 public bool IsValidCoinbaseScript(UInt64 height)
 {
     return(BlockNative.kth_chain_block_is_valid_coinbase_script(nativeInstance_, (UIntPtr)height) != 0);
 }
Beispiel #14
0
 /// <summary>
 /// Returns true if and only if every transaction in the block is final or not.
 /// </summary>
 /// <param name="height"></param>
 /// <returns></returns>
 public bool IsFinal(UInt64 height)
 {
     return(BlockNative.kth_chain_block_is_final(nativeInstance_, (UIntPtr)height) != 0);
 }
Beispiel #15
0
 /// <summary>
 /// Given a position in the block, returns the corresponding transaction.
 /// </summary>
 /// <param name="n"> Zero-based index </param>
 /// <returns> Full transaction object </returns>
 public ITransaction GetNthTransaction(UInt64 n)
 {
     return(new Transaction(BlockNative.chain_block_transaction_nth(nativeInstance_, (UIntPtr)n), false));
 }
Beispiel #16
0
 /// <summary>
 /// Given a block height, return true if and only if its coinbase claim is not higher than the deserved reward.
 /// </summary>
 /// <param name="height">The height which identifies the block to examine</param>
 /// <returns> True if and only if 1 if coinbase claim is not higher than the deserved reward. </returns>
 public bool IsValidCoinbaseClaim(UInt64 height)
 {
     return(BlockNative.chain_block_is_valid_coinbase_claim(nativeInstance_, (UIntPtr)height) != 0);
 }