Beispiel #1
0
        public bool TryReadBlock(ref SequenceReader <byte> r)
        {
            if (!TryReadBlockHeader(ref r))
            {
                goto fail;
            }

            if (!r.TryReadVarint(out long count))
            {
                goto fail;
            }

            _txs = new KzTransaction[count];

            for (var i = 0L; i < count; i++)
            {
                var t = new KzTransaction();
                _txs[i] = t;
                if (!t.TryReadTransaction(ref r))
                {
                    goto fail;
                }
            }

            if (!VerifyMerkleRoot())
            {
                goto fail;
            }

            return(true);

fail:
            return(false);
        }
Beispiel #2
0
        async public Task <KzTransaction> GetTransactionsByHash(KzUInt256 txId)
        {
            var url = $"https://api.whatsonchain.com/v1/bsv/{Kz.Params.strNetworkID}/tx/hash/{txId}";

            var json = await _HttpClient.GetStringAsync(url);

            var woctx = JsonConvert.DeserializeObject <Transaction>(json);

            var tx  = new KzTransaction();
            var ros = new ReadOnlySequence <byte>(woctx.hex.HexToBytes());

            if (!tx.TryReadTransaction(ref ros))
            {
                tx = null;
            }
            return(tx);
        }