コード例 #1
0
        public async Task <BlockchainTx> GetAddressTransactions(string walletAddress)
        {
            HttpUtilities         httpUtilities         = new HttpUtilities();
            BlockchainApiSettings blockchainApiSettings = GetSettings();
            HttpResponseBO        _res = await httpUtilities.GetAsync(blockchainApiSettings.BlockCypherApiUri,
                                                                      "v1/btc/main/addrs/" + walletAddress, new object { });

            BlockchainTx blockchainTx = JsonConvert.DeserializeObject <BlockchainTx>(_res.ResponseResult);

            CoinCap      coinCap      = new CoinCap();
            CoinProperty coinProperty = coinCap.GetCoinProperty("bitcoin");

            foreach (var item in blockchainTx.Txrefs)
            {
                item.ValueFiat = (long)decimal.Parse(coinProperty.Data.PriceUsd) * item.Value;
            }

            return(blockchainTx);
        }
コード例 #2
0
        public async Task <BlockchainResponse> NewPaymentAddress(string callBackUrl)
        {
            HttpUtilities         httpUtilities         = new HttpUtilities();
            BlockchainApiSettings blockchainApiSettings = GetSettings();
            HttpResponseBO        res = await httpUtilities.GetAsync(blockchainApiSettings.ApiUri, "v2/receive",
                                                                     new
            {
                xpub = blockchainApiSettings.XpubKey, callback = blockchainApiSettings.CallbackURL,
                key  = blockchainApiSettings.ApiKey
            });

            ReceivePaymentResponse receivePayment =
                JsonConvert.DeserializeObject <ReceivePaymentResponse>(res.ResponseResult);

            BlockchainResponse blockchainResponse = new BlockchainResponse();

            blockchainResponse.Address = receivePayment.Address;
            blockchainResponse.XpubKey = blockchainApiSettings.XpubKey;

            return(blockchainResponse);
            //return "123";
        }