Пример #1
0
        async public Task <string> SendManyAsync(string fromAccount, IDictionary <string, decimal> toAccounts, int minConfirmations = 1, string comment = "")
        {
            WalletRequest walletRequest = new WalletRequest("sendmany",
                                                            new object[] { fromAccount, toAccounts, minConfirmations, comment });

            return(await RpcRequestAsync <string>(walletRequest));
        }
Пример #2
0
        async public Task <IEnumerable <AccountInfo> > ListAccountsAsync(int minConfirmations = 1)
        {
            WalletRequest walletRequest = new WalletRequest("listaccounts", new List <object>()
            {
                minConfirmations
            });

            List <AccountInfo> accounts = null;
            var response = await MakeRequestAsync(walletRequest.ToJsonString());

            var accountObj = JObject.Parse(response).SelectToken("result");

            if (accountObj is JContainer)
            {
                JContainer container = (JContainer)accountObj;
                accounts = new List <AccountInfo>();
                foreach (JToken token in container.Children())
                {
                    if (!(token is JProperty))
                    {
                        continue;
                    }
                    JProperty   child   = (JProperty)token;
                    AccountInfo account = new AccountInfo();
                    account.Name    = child.Name;
                    account.Balance = child.Value.ToObject <decimal>();
                    accounts.Add(account);
                }
            }
            return(accounts);
        }
Пример #3
0
        async public Task <string> SendFromAsync(string fromAccount, string toAddress, decimal amount, int minConfirmations = 1, string comment = "", string toComment = "")
        {
            WalletRequest walletRequest = new WalletRequest("sendfrom",
                                                            new object[] { fromAccount, toAddress, Math.Round(amount, 8), minConfirmations, comment, toComment });

            return(await RpcRequestAsync <string>(walletRequest));
        }
Пример #4
0
        public void Stop()
        {
            WalletRequest walletRequest = new WalletRequest("stop");

            RpcRequest <string>(walletRequest);
            //{"result":"Bitcoin server stopping","error":null,"id":"1"}
        }
Пример #5
0
        public async Task <JsonResult> SaveRequest(string phoneNo, double requestAmount, string transactionId, string remarks)
        {
            WalletRequest walletRequest = new WalletRequest();

            walletRequest.Phone         = phoneNo;
            walletRequest.RequestAmount = requestAmount;
            walletRequest.TransactionId = transactionId;
            walletRequest.Remarks       = remarks;

            if (HttpContext.User.Identity.Name != null)
            {
                var loggedInUser = await _userManager.FindByNameAsync(HttpContext.User.Identity.Name);

                walletRequest.ApplicationUserId = loggedInUser.Id;
            }
            walletRequest.Status = 0;
            _context.Add(walletRequest);
            int result = await _context.SaveChangesAsync();


            if (result == 1)
            {
                return(Json(true));
            }
            else
            {
                return(Json(false));
            }
        }
Пример #6
0
        async public Task StopAsync()
        {
            WalletRequest walletRequest = new WalletRequest("stop");

            await RpcRequestAsync <string>(walletRequest);

            //{"result":"Bitcoin server stopping","error":null,"id":"1"}
        }
Пример #7
0
        public RawTransaction DecodeRawTransaction(string transactionHex)
        {
            WalletRequest walletRequest = new WalletRequest("decoderawtransaction", new List <object>()
            {
                transactionHex
            });

            return(RpcRequest <RawTransaction>(walletRequest));
        }
Пример #8
0
        async public Task ImportPrivateKeyAsync(string privateKey, string label = "", bool rescanTransactions = true)
        {
            WalletRequest walletRequest = new WalletRequest("importprivkey ", new List <object>()
            {
                privateKey, label, rescanTransactions
            });

            await RpcRequestAsync <object>(walletRequest);
        }
Пример #9
0
 public async Task SendOrderToWalletAsync(Guid userId, string symbol, decimal value, int amount, bool isCloseOrder, string orderType)
 {
     using (var client = new WalletClient())
     {
         var assetsRequestDto = new AssetRequestDto(symbol, value);
         var walletRequest    = new WalletRequest(userId, assetsRequestDto, amount, isCloseOrder, orderType);
         await client.SendOrderAsync(walletRequest);
     }
 }
Пример #10
0
        public string GetBlockHash(int index)
        {
            WalletRequest walletRequest = new WalletRequest("getblockcount", new List <object>()
            {
                index
            });

            return(RpcRequest <string>(walletRequest));
        }
Пример #11
0
        async public Task <string> GetBlockHashAsync(int index)
        {
            WalletRequest walletRequest = new WalletRequest("getblockcount", new List <object>()
            {
                index
            });

            return(await RpcRequestAsync <string>(walletRequest));
        }
Пример #12
0
        public string GetRawTransactionHex(string transactionId)
        {
            WalletRequest walletRequest = new WalletRequest("getrawtransaction", new List <object>()
            {
                transactionId, 0
            });

            return(RpcRequest <string>(walletRequest));
        }
Пример #13
0
        public void BackupWallet(string destination)
        {
            WalletRequest walletRequest = new WalletRequest("backupwallet", new List <object>()
            {
                destination
            });

            RpcRequest <string>(walletRequest);
        }
Пример #14
0
        async public Task <bool> MoveAsync(string fromAddress, string toAddress, decimal amount, int minConfirmations = 1, string comment = "")
        {
            WalletRequest walletRequest = new WalletRequest("move", new List <object>()
            {
                fromAddress, toAddress, Math.Round(amount, 8), minConfirmations, comment
            });

            return(await RpcRequestAsync <bool>(walletRequest));
        }
Пример #15
0
        public string GetAccountAddress(string account)
        {
            WalletRequest walletRequest = new WalletRequest("getaccountaddress", new List <object>()
            {
                account
            });

            return(RpcRequest <string>(walletRequest));
        }
Пример #16
0
        async public Task <AddressValidation> ValidateAddressAsync(string address)
        {
            WalletRequest walletRequest = new WalletRequest("validateaddress", new List <object>()
            {
                address
            });

            return(await RpcRequestAsync <AddressValidation>(walletRequest));
        }
Пример #17
0
        async public Task <IEnumerable <WalletTransaction> > ListTransactionsAsync(string account = "*", int count = 10, int startingIndex = 0)
        {
            WalletRequest walletRequest = new WalletRequest("listtransactions", new List <object>()
            {
                account, count, startingIndex
            });

            return(await RpcRequestAsync <IEnumerable <WalletTransaction> >(walletRequest));
        }
Пример #18
0
        public AddressValidation ValidateAddress(string address)
        {
            WalletRequest walletRequest = new WalletRequest("validateaddress", new List <object>()
            {
                address
            });

            return(RpcRequest <AddressValidation>(walletRequest));
        }
Пример #19
0
        async public Task SetWalletPassphraseAsync(string passPhrase, TimeSpan timeSpan)
        {
            WalletRequest walletRequest = new WalletRequest("walletpassphrase", new List <object>()
            {
                passPhrase, Convert.ToInt32(timeSpan.TotalSeconds)
            });

            await RpcRequestAsync <string>(walletRequest);
        }
Пример #20
0
        public void SetWalletPassphrase(string passPhrase, TimeSpan timeSpan)
        {
            WalletRequest walletRequest = new WalletRequest("walletpassphrase", new List <object>()
            {
                passPhrase, Convert.ToInt32(timeSpan.TotalSeconds)
            });

            RpcRequest <string>(walletRequest);
        }
Пример #21
0
        async public Task <RawTransaction> DecodeRawTransactionAsync(string transactionHex)
        {
            WalletRequest walletRequest = new WalletRequest("decoderawtransaction", new List <object>()
            {
                transactionHex
            });

            return(await RpcRequestAsync <RawTransaction>(walletRequest));
        }
Пример #22
0
        async public Task <Block> GetBlockAsync(string hash)
        {
            WalletRequest walletRequest = new WalletRequest("getblock", new List <object>()
            {
                hash
            });

            return(await RpcRequestAsync <Block>(walletRequest));
        }
Пример #23
0
        public RawTransactionInfo GetRawTransaction(string transactionId)
        {
            WalletRequest walletRequest = new WalletRequest("getrawtransaction", new List <object>()
            {
                transactionId, 1
            });

            return(RpcRequest <RawTransactionInfo>(walletRequest));
        }
Пример #24
0
        public IEnumerable <string> GetAddressesByAccount(string account)
        {
            WalletRequest walletRequest = new WalletRequest("getaddressesbyaccount", new List <object>()
            {
                account
            });

            return(RpcRequest <IEnumerable <string> >(walletRequest));
        }
Пример #25
0
        async public Task <string> GetRawTransactionHexAsync(string transactionId)
        {
            WalletRequest walletRequest = new WalletRequest("getrawtransaction", new List <object>()
            {
                transactionId, 0
            });

            return(await RpcRequestAsync <string>(walletRequest));
        }
Пример #26
0
        async public Task <IEnumerable <string> > GetAddressesByAccountAsync(string account)
        {
            WalletRequest walletRequest = new WalletRequest("getaddressesbyaccount", new List <object>()
            {
                account
            });

            return(await RpcRequestAsync <IEnumerable <string> >(walletRequest));
        }
Пример #27
0
        async public Task BackupWalletAsync(string destination)
        {
            WalletRequest walletRequest = new WalletRequest("backupwallet", new List <object>()
            {
                destination
            });

            await RpcRequestAsync <string>(walletRequest);
        }
Пример #28
0
        public void ImportPrivateKey(string privateKey, string label = "", bool rescanTransactions = true)
        {
            WalletRequest walletRequest = new WalletRequest("importprivkey ", new List <object>()
            {
                privateKey, label, rescanTransactions
            });

            RpcRequest <object>(walletRequest);
        }
Пример #29
0
        async public Task <string> GetAccountAddressAsync(string account)
        {
            WalletRequest walletRequest = new WalletRequest("getaccountaddress", new List <object>()
            {
                account
            });

            return(await RpcRequestAsync <string>(walletRequest));
        }
Пример #30
0
        async public Task <string> SendToAddressAsync(string address, decimal amount, string comment = "", string visibleComment = "")
        {
            WalletRequest walletRequest = new WalletRequest("sendtoaddress", new List <object>()
            {
                address, Math.Round(amount, 8), comment, visibleComment
            });

            return(await RpcRequestAsync <string>(walletRequest));
        }