Example #1
0
    public void ParseVerboseBlockInfo()
    {
        var blockInfo = RpcParser.ParseVerboseBlockResponse(RpcOutput);

        Assert.Equal(2, blockInfo.Transactions.Count());
        Assert.Single(blockInfo.Transactions.ElementAt(0).Inputs);
        Assert.Equal(2, blockInfo.Transactions.ElementAt(0).Outputs.Count());
        Assert.Single(blockInfo.Transactions.ElementAt(1).Inputs);
        Assert.Equal(2, blockInfo.Transactions.ElementAt(1).Outputs.Count());

        Assert.Equal("01660101", blockInfo.Transactions.ElementAt(0).Inputs.ElementAt(0).Coinbase);
        Assert.Equal(RpcPubkeyType.TxPubkeyhash, blockInfo.Transactions.ElementAt(0).Outputs.ElementAt(0).PubkeyType);
        Assert.Equal(RpcPubkeyType.TxNullData, blockInfo.Transactions.ElementAt(0).Outputs.ElementAt(1).PubkeyType);

        var in0 = blockInfo.Transactions.ElementAt(1).Inputs.ElementAt(0);

        Assert.False(in0.IsCoinbase);
        var prevOut0 = in0.PrevOutput;

        Assert.Equal(Money.Coins(50), prevOut0?.Value);
        Assert.Equal(RpcPubkeyType.TxPubkeyhash, prevOut0?.PubkeyType);

        Assert.Equal(Money.Coins((decimal)48.99995500), blockInfo.Transactions.ElementAt(1).Outputs.ElementAt(0).Value);
        Assert.Equal(Money.Coins((decimal)1.00000000), blockInfo.Transactions.ElementAt(1).Outputs.ElementAt(1).Value);
        Assert.Equal(RpcPubkeyType.TxPubkeyhash, blockInfo.Transactions.ElementAt(1).Outputs.ElementAt(0).PubkeyType);
        Assert.Equal(RpcPubkeyType.TxPubkeyhash, blockInfo.Transactions.ElementAt(1).Outputs.ElementAt(1).PubkeyType);
    }
Example #2
0
        public async Task ParseVerboseBlockInfoAsync()
        {
            var blockInfo = RpcParser.ParseVerboseBlockResponse(RpcOutput);

            Assert.Equal(2, blockInfo.Transactions.Count());
            Assert.Equal(1, blockInfo.Transactions.ElementAt(0).Inputs.Count());
            Assert.Equal(2, blockInfo.Transactions.ElementAt(0).Outputs.Count());
            Assert.Equal(1, blockInfo.Transactions.ElementAt(1).Inputs.Count());
            Assert.Equal(2, blockInfo.Transactions.ElementAt(1).Outputs.Count());

            Assert.Equal("01660101", blockInfo.Transactions.ElementAt(0).Inputs.ElementAt(0).Coinbase);
            Assert.Equal(RpcPubkeyType.TxPubkeyhash, blockInfo.Transactions.ElementAt(0).Outputs.ElementAt(0).PubkeyType);
            Assert.Equal(RpcPubkeyType.TxNullData, blockInfo.Transactions.ElementAt(0).Outputs.ElementAt(1).PubkeyType);

            Assert.Equal(Money.Coins(50), blockInfo.Transactions.ElementAt(1).Inputs.ElementAt(0).PrevOutput.Value);
            Assert.Equal(Money.Coins((decimal)48.99995500), blockInfo.Transactions.ElementAt(1).Outputs.ElementAt(0).Value);
            Assert.Equal(Money.Coins((decimal)1.00000000), blockInfo.Transactions.ElementAt(1).Outputs.ElementAt(1).Value);
            Assert.Equal(RpcPubkeyType.TxPubkeyhash, blockInfo.Transactions.ElementAt(1).Inputs.ElementAt(0).PrevOutput.PubkeyType);
            Assert.Equal(RpcPubkeyType.TxPubkeyhash, blockInfo.Transactions.ElementAt(1).Outputs.ElementAt(0).PubkeyType);
            Assert.Equal(RpcPubkeyType.TxPubkeyhash, blockInfo.Transactions.ElementAt(1).Outputs.ElementAt(1).PubkeyType);
        }