Esempio n. 1
0
        public RecentAccountViewModel(Account account, AccountProperties properties) : base()
        {
            if (properties == null)
                throw new ArgumentNullException(nameof(properties));

            Account = account;
            AccountName = properties.AccountName;
            Balance = properties.TotalBalance;
        }
Esempio n. 2
0
        public AccountViewModel(Account account, AccountProperties properties, Balances balances) : base()
        {
            Account = account;
            _accountProperties = properties;
            _balances = balances;

            OpenRenameAccountDialogCommand = new DelegateCommand(OpenRenameAccountDialogAction);
            OpenImportKeyDialogCommand = new DelegateCommand(OpenImportKeyDialogAction);
            HideAccountCommand = new DelegateCommand(HideAccountAction);
        }
Esempio n. 3
0
        private const uint ImportedAccountNumber = 2147483647; // 2**31 - 1 

        public Wallet(BlockChainIdentity activeChain, TransactionSet txSet, List<AccountProperties> bip0032Accounts,
            AccountProperties importedAccount, BlockIdentity chainTip)
        {
            if (activeChain == null)
                throw new ArgumentNullException(nameof(activeChain));
            if (bip0032Accounts == null)
                throw new ArgumentNullException(nameof(bip0032Accounts));
            if (importedAccount == null)
                throw new ArgumentNullException(nameof(importedAccount));
            if (chainTip == null)
                throw new ArgumentNullException(nameof(chainTip));

            _transactionCount = txSet.MinedTransactions.Aggregate(0, (acc, b) => acc + b.Transactions.Count) +
                txSet.UnminedTransactions.Count;
            _bip0032Accounts = bip0032Accounts;
            _importedAccount = importedAccount;

            var totalBalance = EnumerateAccounts().Aggregate((Amount)0, (acc, a) => acc + a.Item2.TotalBalance);

            ActiveChain = activeChain;
            RecentTransactions = txSet;
            TotalBalance = totalBalance;
            ChainTip = chainTip;
        }
Esempio n. 4
0
        public void UpdateAccountProperties(Account account, string name, uint externalKeyCount, uint internalKeyCount, uint importedKeyCount)
        {
            AccountProperties props;
            if (account.AccountNumber == ImportedAccountNumber)
            {
                props = _importedAccount;
            }
            else
            {
                var accountNumber = checked((int)account.AccountNumber);
                if (accountNumber < _bip0032Accounts.Count)
                {
                    props = _bip0032Accounts[accountNumber];
                }
                else if (accountNumber == _bip0032Accounts.Count)
                {
                    props = new AccountProperties();
                    _bip0032Accounts.Add(props);
                }
                else
                {
                    throw new Exception($"Account {accountNumber} is not the next BIP0032 account.");
                }
            }

            props.AccountName = name;
            props.ExternalKeyCount = externalKeyCount;
            props.InternalKeyCount = internalKeyCount;
            props.ImportedKeyCount = importedKeyCount;

            var eventArgs = new ChangesProcessedEventArgs();
            eventArgs.ModifiedAccountProperties[account] = props;
            OnChangesProcessed(eventArgs);
        }