コード例 #1
0
 public WalletEntry(IImmutableList <MonitoredWalletAddress> addresses, EnumWalletEntryType type, ChainPosition chainPosition, UInt64 value)
 {
     this.addresses     = addresses;
     this.type          = type;
     this.chainPosition = chainPosition;
     this.value         = value;
 }
コード例 #2
0
ファイル: WalletEntry.cs プロジェクト: cole2295/BitSharp
 public WalletEntry(IImmutableList<MonitoredWalletAddress> addresses, EnumWalletEntryType type, ChainPosition chainPosition, UInt64 value)
 {
     Addresses = addresses;
     Type = type;
     ChainPosition = chainPosition;
     Value = value;
 }
コード例 #3
0
        private void ScanForEntry(ChainPosition chainPosition, EnumWalletEntryType walletEntryType, TxOutput txOutput, UInt256 outputScriptHash)
        {
            var matchingAddresses = ImmutableList.CreateBuilder <MonitoredWalletAddress>();

            // test hash addresses
            List <MonitoredWalletAddress> addresses;

            if (this.addressesByOutputScriptHash.TryGetValue(outputScriptHash, out addresses))
            {
                matchingAddresses.AddRange(addresses);
            }

            // test matcher addresses
            foreach (var address in this.matcherAddresses)
            {
                if (address.Address.MatchesTxOutput(txOutput, outputScriptHash))
                {
                    matchingAddresses.Add(address);
                }
            }

            if (matchingAddresses.Count > 0)
            {
                var entry = new WalletEntry
                            (
                    addresses: matchingAddresses.ToImmutable(),
                    type: walletEntryType,
                    chainPosition: chainPosition,
                    value: txOutput.Value
                            );

                this.entriesLock.DoWrite(() =>
                {
                    this.logger.Debug("{0,-10}   {1,20:#,##0.000_000_00} BTC, Entries: {2:#,##0}".Format2(walletEntryType.ToString() + ":", txOutput.Value / (decimal)(100.MILLION()), this.entries.Count));

                    this.entries.Add(entry);
                    if (walletEntryType == EnumWalletEntryType.Spend)
                    {
                        this.bitBalance -= entry.BitValue;
                    }
                    else
                    {
                        this.bitBalance += entry.BitValue;
                    }
                });

                var handler = this.OnEntryAdded;
                if (handler != null)
                {
                    handler(entry);
                }
            }
        }
コード例 #4
0
        public static int Direction(this EnumWalletEntryType value)
        {
            switch (value)
            {
            case EnumWalletEntryType.Receive:
            case EnumWalletEntryType.Mine:
            case EnumWalletEntryType.UnSpend:
                return(+1);

            default:
                return(-1);
            }
        }
コード例 #5
0
ファイル: WalletMonitor.cs プロジェクト: yonglehou/BitSharp
        private void ScanForEntry(ChainPosition chainPosition, EnumWalletEntryType walletEntryType, TxOutput txOutput, UInt256 outputScriptHash)
        {
            var matchingAddresses = ImmutableList.CreateBuilder <MonitoredWalletAddress>();

            // test hash addresses
            List <MonitoredWalletAddress> addresses;

            if (this.addressesByOutputScriptHash.TryGetValue(outputScriptHash, out addresses))
            {
                matchingAddresses.AddRange(addresses);
            }

            // test matcher addresses
            foreach (var address in this.matcherAddresses)
            {
                if (address.Address.MatchesTxOutput(txOutput, outputScriptHash))
                {
                    matchingAddresses.Add(address);
                }
            }

            if (matchingAddresses.Count > 0)
            {
                var entry = new WalletEntry
                            (
                    addresses: matchingAddresses.ToImmutable(),
                    type: walletEntryType,
                    chainPosition: chainPosition,
                    value: txOutput.Value
                            );

                lock (this.entries)
                {
                    if (keepEntries)
                    {
                        this.entries.Add(entry);
                    }

                    this.entriesCount++;
                }
                this.bitBalance += entry.BitValue * walletEntryType.Direction();

                logger.Debug($"{walletEntryType + ":",-10}   {txOutput.Value / (decimal)(100.MILLION()),20:#,##0.000_000_00} BTC, Entries: {this.entriesCount:#,##0}");

                this.OnEntryAdded?.Invoke(entry);
            }
        }
コード例 #6
0
ファイル: WalletMonitor.cs プロジェクト: cole2295/BitSharp
        private void ScanForEntry(ChainPosition chainPosition, EnumWalletEntryType walletEntryType, TxOutput txOutput, UInt256 outputScriptHash)
        {
            var matchingAddresses = ImmutableList.CreateBuilder<MonitoredWalletAddress>();

            // test hash addresses
            List<MonitoredWalletAddress> addresses;
            if (this.addressesByOutputScriptHash.TryGetValue(outputScriptHash, out addresses))
            {
                matchingAddresses.AddRange(addresses);
            }

            // test matcher addresses
            foreach (var address in this.matcherAddresses)
            {
                if (address.Address.MatchesTxOutput(txOutput, outputScriptHash))
                    matchingAddresses.Add(address);
            }

            if (matchingAddresses.Count > 0)
            {
                var entry = new WalletEntry
                (
                    addresses: matchingAddresses.ToImmutable(),
                    type: walletEntryType,
                    chainPosition: chainPosition,
                    value: txOutput.Value
                );

                lock (this.entries)
                {
                    if (keepEntries)
                        this.entries.Add(entry);

                    this.entriesCount++;
                }
                this.bitBalance += entry.BitValue * walletEntryType.Direction();

                logger.Debug($"{walletEntryType + ":",-10}   {txOutput.Value / (decimal)(100.MILLION()),20:#,##0.000_000_00} BTC, Entries: {this.entriesCount:#,##0}");

                this.OnEntryAdded?.Invoke(entry);
            }
        }