Beispiel #1
0
        public void PushEntry(WalletEntry entry, BlockType? blockType)
        {
            if(blockType == null && entry.Block != null)
                throw new ArgumentException("An entry coming from a block should have a blocktype");

            Unconfirmed.PushEntry(entry);
            if(entry.Type == WalletEntryType.Outcome)
                Available.PushEntry(entry);
            if(entry.Block != null && blockType == BlockType.Main)
            {
                Available.PushEntry(entry);
                Confirmed.PushEntry(entry);
            }
        }
Beispiel #2
0
 internal void PushEntry(WalletEntry entry)
 {
     if (entry.Type == WalletEntryType.Income)
     {
         var spendable = entry.GetSpendable();
         PushAccountEntry(entry.Block, spendable, spendable.TxOut.Value);
     }
     else if (entry.Type == WalletEntryType.Outcome)
     {
         if (_Unspent.ContainsKey(entry.OutPoint))
         {
             var spendable = _Unspent[entry.OutPoint];
             PushAccountEntry(entry.Block, spendable, -spendable.TxOut.Value);
         }
     }
 }
Beispiel #3
0
        public void PushEntry(WalletEntry entry, BlockType?blockType)
        {
            if (blockType == null && entry.Block != null)
            {
                throw new ArgumentException("An entry coming from a block should have a blocktype");
            }

            Unconfirmed.PushEntry(entry);
            if (entry.Type == WalletEntryType.Outcome)
            {
                Available.PushEntry(entry);
            }
            if (entry.Block != null && blockType == BlockType.Main)
            {
                Available.PushEntry(entry);
                Confirmed.PushEntry(entry);
            }
        }
Beispiel #4
0
        private void ReceiveTransaction(uint256 block, BlockType?blockType, Transaction tx)
        {
            var oldBalance = Balance;

            var txHash = tx.GetHash();

            for (int i = 0; i < tx.Outputs.Count; i++)
            {
                foreach (var key in _Keys)
                {
                    if (tx.Outputs[i].IsTo(key.PubKey))
                    {
                        var entry = new WalletEntry();
                        entry.Block        = block;
                        entry.ScriptPubKey = tx.Outputs[i].ScriptPubKey;
                        entry.OutPoint     = new OutPoint(tx, i);
                        entry.Value        = tx.Outputs[i].Value;
                        _Accounts.PushEntry(entry, blockType);
                    }
                }
            }

            foreach (var txin in tx.Inputs)
            {
                foreach (var key in _Keys)
                {
                    if (txin.IsFrom(key.PubKey))
                    {
                        var entry = new WalletEntry();
                        entry.Block    = block;
                        entry.OutPoint = txin.PrevOut;
                        _Accounts.PushEntry(entry, blockType);
                    }
                }
            }

            OnBalanceChanged(tx, oldBalance, Balance);
        }
Beispiel #5
0
        private void ReceiveTransaction(uint256 block, BlockType? blockType, Transaction tx)
        {
            var oldBalance = Balance;

            var txHash = tx.GetHash();
            for(int i = 0 ; i < tx.Outputs.Count ; i++)
            {
                foreach(var key in _Keys)
                {
                    if(tx.Outputs[i].IsTo(key.PubKey))
                    {
                        var entry = new WalletEntry();
                        entry.Block = block;
                        entry.ScriptPubKey = tx.Outputs[i].ScriptPubKey;
                        entry.OutPoint = new OutPoint(tx, i);
                        entry.Value = tx.Outputs[i].Value;
                        _Accounts.PushEntry(entry, blockType);
                    }
                }
            }

            foreach(var txin in tx.Inputs)
            {
                foreach(var key in _Keys)
                {
                    if(txin.IsFrom(key.PubKey))
                    {
                        var entry = new WalletEntry();
                        entry.Block = block;
                        entry.OutPoint = txin.PrevOut;
                        _Accounts.PushEntry(entry, blockType);
                    }
                }
            }

            OnBalanceChanged(tx, oldBalance, Balance);
        }
Beispiel #6
0
 internal void PushEntry(WalletEntry entry)
 {
     if(entry.Type == WalletEntryType.Income)
     {
         var spendable = entry.GetSpendable();
         PushAccountEntry(entry.Block, spendable, spendable.TxOut.Value);
     }
     else if(entry.Type == WalletEntryType.Outcome)
     {
         if(_Unspent.ContainsKey(entry.OutPoint))
         {
             var spendable = _Unspent[entry.OutPoint];
             PushAccountEntry(entry.Block, spendable, -spendable.TxOut.Value);
         }
     }
 }