Example #1
0
        private async Task <Wallet> GetWalletFromBitcoinDaemon()
        {
            var rpcRequest  = RpcRequestFactory.CreateRpcRequest(1, BitcoinMethods.GetWalletInfo);
            var rpcResponse = await rpcService.SendRequest <GetWalletInfoRpcResponse>(rpcRequest);

            return(mapper.Map <GetWalletInfoRpcResponse, Wallet>(rpcResponse.Result));
        }
Example #2
0
        public async Task <Transaction> GetTransaction(string txId)
        {
            var rpcRequest  = RpcRequestFactory.CreateRpcRequest(1, BitcoinMethods.GetTransaction, txId);
            var rpcResponse = await rpcService.SendRequest <TransactionRpcResponse>(rpcRequest);

            return(mapper.Map <TransactionRpcResponse, Transaction>(rpcResponse.Result));
        }
Example #3
0
        public async Task <IEnumerable <Transaction> > GetTransactionsSinceBlock(string blockHash)
        {
            var rpcRequest  = RpcRequestFactory.CreateRpcRequest(1, BitcoinMethods.ListSinceBlock, blockHash);
            var rpcResponse = await rpcService.SendRequest <ListSinceBlockRpcResponse>(rpcRequest);

            return(mapper.Map <List <ListSinceBlockTransaction>, List <Transaction> >(rpcResponse.Result.Transactions.ToList()));
        }
        public async Task <string> SendBitcoins(SendBitcoinModel sendBitcoinModel)
        {
            var rpcRequest  = RpcRequestFactory.CreateRpcRequest(1, BitcoinMethods.SendToAddress, sendBitcoinModel.Address, sendBitcoinModel.Amount);
            var rpcResponse = await rpcService.SendRequest <string>(rpcRequest);

            return(rpcResponse.Result);
        }
Example #5
0
        private async Task <string> GetRecentBlockHash(string lastBlockHash, int depth = 5)
        {
            string currentBlockHash = lastBlockHash;

            for (int i = 0; i < depth; i++)
            {
                var rpcRequest  = RpcRequestFactory.CreateRpcRequest(1, BitcoinMethods.GetBlock, currentBlockHash);
                var rpcResponse = await rpcService.SendRequest <Block>(rpcRequest);

                currentBlockHash = rpcResponse.Result.PreviousBlockHash;
            }

            return(currentBlockHash);
        }