Exemplo n.º 1
0
        public 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;
        }
Exemplo n.º 2
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;
        }