コード例 #1
0
ファイル: Accounts.cs プロジェクト: nikropht/NBitcoin
        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);
            }
        }
コード例 #2
0
ファイル: Account.cs プロジェクト: royosherove/NBitcoin
 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);
         }
     }
 }
コード例 #3
0
ファイル: Accounts.cs プロジェクト: royosherove/NBitcoin
        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);
            }
        }
コード例 #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);
        }
コード例 #5
0
ファイル: Wallet.cs プロジェクト: nikropht/NBitcoin
        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);
        }
コード例 #6
0
ファイル: Account.cs プロジェクト: royosherove/NBitcoin
 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);
         }
     }
 }