Beispiel #1
0
 public static GetBlocksPayload DecodeGetBlocksPayload(BinaryReader reader)
 {
     return new GetBlocksPayload
     (
         Version: reader.ReadUInt32(),
         BlockLocatorHashes: reader.ReadList(() => reader.ReadUInt256()),
         HashStop: reader.ReadUInt256()
     );
 }
Beispiel #2
0
 public static BlockHeader DecodeBlockHeader(BinaryReader reader, UInt256 blockHash = null)
 {
     return new BlockHeader
     (
         version: reader.ReadUInt32(),
         previousBlock: reader.ReadUInt256(),
         merkleRoot: reader.ReadUInt256(),
         time: reader.ReadUInt32(),
         bits: reader.ReadUInt32(),
         nonce: reader.ReadUInt32(),
         hash: blockHash
     );
 }
Beispiel #3
0
        public static BlockTx DecodeBlockTx(BinaryReader reader, bool skipTx = false)
        {
            var index = reader.ReadInt32();
            var depth = reader.ReadInt32();
            var hash = reader.ReadUInt256();
            var pruned = reader.ReadBool();

            if (!pruned && !skipTx)
            {
                var tx = DecodeTransaction(reader, hash);
                return new BlockTx(index, depth, hash, pruned, tx);
            }
            else
                return new BlockTx(index, depth, hash, pruned, null);
        }
Beispiel #4
0
 public static InventoryVector DecodeInventoryVector(BinaryReader reader)
 {
     return new InventoryVector
     (
         Type: reader.ReadUInt32(),
         Hash: reader.ReadUInt256()
     );
 }
Beispiel #5
0
 public static ChainedHeader DecodeChainedHeader(BinaryReader reader)
 {
     var blockHash = reader.ReadUInt256();
     return new ChainedHeader
     (
         blockHeader: DecodeBlockHeader(reader, blockHash),
         height: reader.ReadInt32(),
         totalWork: new BigInteger(reader.ReadVarBytes())
     );
 }
Beispiel #6
0
 public static UnmintedTx DecodeUnmintedTx(BinaryReader reader)
 {
     return new UnmintedTx(
         txHash: reader.ReadUInt256(),
         prevOutputTxKeys: reader.ReadList(() => DecodeTxLookupKey(reader))
     );
 }
Beispiel #7
0
 public static UnspentTx DecodeUnspentTx(BinaryReader reader)
 {
     return new UnspentTx(
         txHash: reader.ReadUInt256(),
         blockIndex: reader.ReadInt32(),
         txIndex: reader.ReadInt32(),
         outputStates: new OutputStates(
             bytes: reader.ReadVarBytes(),
             length: reader.ReadInt32())
     );
 }
Beispiel #8
0
 public static UInt256 DecodeUInt256(BinaryReader reader)
 {
     return reader.ReadUInt256();
 }
Beispiel #9
0
 public static TxOutputKey DecodeTxOutputKey(BinaryReader reader)
 {
     return new TxOutputKey
     (
         txHash: reader.ReadUInt256(),
         txOutputIndex: reader.ReadUInt32()
     );
 }
Beispiel #10
0
 public static TxLookupKey DecodeTxLookupKey(BinaryReader reader)
 {
     return new TxLookupKey(
         blockHash: reader.ReadUInt256(),
         txIndex: reader.ReadInt32()
     );
 }
Beispiel #11
0
 public static TxInput DecodeTxInput(BinaryReader reader)
 {
     return new TxInput
     (
         previousTxOutputKey: new TxOutputKey
         (
             txHash: reader.ReadUInt256(),
             txOutputIndex: reader.ReadUInt32()
         ),
         scriptSignature: reader.ReadVarBytes().ToImmutableArray(),
         sequence: reader.ReadUInt32()
     );
 }
Beispiel #12
0
 public static SpentTx DecodeSpentTx(BinaryReader reader)
 {
     return new SpentTx(
         txHash: reader.ReadUInt256(),
         confirmedBlockIndex: reader.ReadInt32(),
         txIndex: reader.ReadInt32()
     );
 }