async Task <Transaction?> InternalFetch(string transactionId)
        {
            var response = await httpClient.GetAsync($"tx/{transactionId}/hex");

            if (response.StatusCode == HttpStatusCode.NotFound)
            {
                cache.Remove(transactionId);
                return(null);
            }

            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw new FetchException($"Received {response.StatusCode} fetching transaction");
            }

            var hex = await response.Content.ReadAsStringAsync();

            hex = hex.Trim();

            var transaction = new TransactionReader(hex).ReadTransaction();

            if (transaction.Id != transactionId)
            {
                throw new FetchException("Got wrong transaction ID");
            }

            cache.Set(transactionId, transaction);
            return(transaction.Clone());
        }
示例#2
0
        Script DecodeRedeemScript(byte[] scriptBytes)
        {
            var reader = new TransactionReader(new MemoryStream(scriptBytes));

            return(reader.ReadScript(scriptBytes.Length));
        }