• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# BitCoinSharp.NetworkParameters类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中BitCoinSharp.NetworkParameters的典型用法代码示例。如果您正苦于以下问题:C# NetworkParameters类的具体用法?C# NetworkParameters怎么用?C# NetworkParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NetworkParameters类属于BitCoinSharp命名空间,在下文中一共展示了NetworkParameters类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Address

 /// <summary>
 /// Construct an address from parameters and the standard "human readable" form.
 /// </summary>
 /// <remarks>
 /// Example:<p/>
 /// <pre>new Address(NetworkParameters.prodNet(), "17kzeh4N8g49GFvdDzSf8PjaPfyoD1MndL");</pre>
 /// </remarks>
 /// <exception cref="AddressFormatException"/>
 public Address(NetworkParameters @params, string address)
     : base(address)
 {
     if (Version != @params.AddressHeader)
         throw new AddressFormatException("Mismatched version number, trying to cross networks? " + Version +
                                          " vs " + @params.AddressHeader);
 }
开发者ID:bitspill,项目名称:Gridcoin-master,代码行数:15,代码来源:Address.cs


示例2: TransactionOutput

 /// <summary>
 /// Used only in creation of the genesis blocks and in unit tests.
 /// </summary>
 internal TransactionOutput(NetworkParameters @params, byte[] scriptBytes)
     : base(@params)
 {
     _scriptBytes = scriptBytes;
     _value = Utils.ToNanoCoins(50, 0);
     _availableForSpending = true;
 }
开发者ID:Tsunami-ide,项目名称:Bitcoin,代码行数:10,代码来源:TransactionOutput.cs


示例3: DumpedPrivateKey

 /// <summary>
 /// Parses the given private key as created by the "dumpprivkey" BitCoin C++ RPC.
 /// </summary>
 /// <param name="params">The expected network parameters of the key. If you don't care, provide null.</param>
 /// <param name="encoded">The base58 encoded string.</param>
 /// <exception cref="BitCoinSharp.AddressFormatException">If the string is invalid or the header byte doesn't match the network params.</exception>
 public DumpedPrivateKey(NetworkParameters @params, string encoded)
     : base(encoded)
 {
     if (@params != null && Version != @params.DumpedPrivateKeyHeader)
         throw new AddressFormatException("Mismatched version number, trying to cross networks? " + Version +
                                          " vs " + @params.DumpedPrivateKeyHeader);
 }
开发者ID:aklein53,项目名称:bitcoinsharp,代码行数:13,代码来源:DumpedPrivateKey.cs


示例4: TransactionOutput

 internal TransactionOutput(NetworkParameters @params, Transaction parent, ulong value, Address to)
     : base(@params)
 {
     _value = value;
     _scriptBytes = Script.CreateOutputScript(to);
     ParentTransaction = parent;
     _availableForSpending = true;
 }
开发者ID:aklein53,项目名称:bitcoinsharp,代码行数:8,代码来源:TransactionOutput.cs


示例5: Transaction

 internal Transaction(NetworkParameters @params)
     : base(@params)
 {
     _version = 1;
     _inputs = new List<TransactionInput>();
     _outputs = new List<TransactionOutput>();
     // We don't initialize appearsIn deliberately as it's only useful for transactions stored in the wallet.
 }
开发者ID:aklein53,项目名称:bitcoinsharp,代码行数:8,代码来源:Transaction.cs


示例6: TransactionInput

 /// <summary>
 /// Used only in creation of the genesis block.
 /// </summary>
 internal TransactionInput(NetworkParameters @params, Transaction parentTransaction, byte[] scriptBytes)
     : base(@params)
 {
     ScriptBytes = scriptBytes;
     Outpoint = new TransactionOutPoint(@params, -1, null);
     _sequence = uint.MaxValue;
     ParentTransaction = parentTransaction;
 }
开发者ID:aklein53,项目名称:bitcoinsharp,代码行数:11,代码来源:TransactionInput.cs


示例7: NetworkConnection

        /// <summary>
        /// Connect to the given IP address using the port specified as part of the network parameters. Once construction
        /// is complete a functioning network channel is set up and running.
        /// </summary>
        /// <param name="peerAddress">IP address to connect to. IPv6 is not currently supported by BitCoin. If port is not positive the default port from params is used.</param>
        /// <param name="params">Defines which network to connect to and details of the protocol.</param>
        /// <param name="bestHeight">How many blocks are in our best chain</param>
        /// <param name="connectTimeout">Timeout in milliseconds when initially connecting to peer</param>
        /// <exception cref="IOException">If there is a network related failure.</exception>
        /// <exception cref="ProtocolException">If the version negotiation failed.</exception>
        public NetworkConnection(PeerAddress peerAddress, NetworkParameters @params, uint bestHeight, int connectTimeout)
        {
            _params = @params;
            _remoteIp = peerAddress.Addr;

            var port = (peerAddress.Port > 0) ? peerAddress.Port : @params.Port;

            var address = new IPEndPoint(_remoteIp, port);
            _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _socket.Connect(address);
            _socket.SendTimeout = _socket.ReceiveTimeout = connectTimeout;

            _out = new NetworkStream(_socket, FileAccess.Write);
            _in = new NetworkStream(_socket, FileAccess.Read);

            // the version message never uses check-summing. Update check-summing property after version is read.
            _serializer = new BitcoinSerializer(@params, false);

            // Announce ourselves. This has to come first to connect to clients beyond v0.30.20.2 which wait to hear
            // from us until they send their version message back.
            WriteMessage(new VersionMessage(@params, bestHeight));
            // When connecting, the remote peer sends us a version message with various bits of
            // useful data in it. We need to know the peer protocol version before we can talk to it.
            _versionMessage = (VersionMessage) ReadMessage();
            // Now it's our turn ...
            // Send an ACK message stating we accept the peers protocol version.
            WriteMessage(new VersionAck());
            // And get one back ...
            ReadMessage();
            // Switch to the new protocol version.
            var peerVersion = _versionMessage.ClientVersion;
            _log.InfoFormat("Connected to peer: version={0}, subVer='{1}', services=0x{2:X}, time={3}, blocks={4}",
                            peerVersion,
                            _versionMessage.SubVer,
                            _versionMessage.LocalServices,
                            UnixTime.FromUnixTime(_versionMessage.Time),
                            _versionMessage.BestHeight
                );
            // BitCoinSharp is a client mode implementation. That means there's not much point in us talking to other client
            // mode nodes because we can't download the data from them we need to find/verify transactions.
            if (!_versionMessage.HasBlockChain())
            {
                // Shut down the socket
                try
                {
                    Shutdown();
                }
                catch (IOException)
                {
                    // ignore exceptions while aborting
                }
                throw new ProtocolException("Peer does not have a copy of the block chain.");
            }
            // newer clients use check-summing
            _serializer.UseChecksumming(peerVersion >= 209);
            // Handshake is done!
        }
开发者ID:aklein53,项目名称:bitcoinsharp,代码行数:67,代码来源:NetworkConnection.cs


示例8: MemoryBlockStore

 public MemoryBlockStore(NetworkParameters @params)
 {
     _blockMap = new Dictionary<ByteBuffer, byte[]>();
     // Insert the genesis block.
     var genesisHeader = @params.GenesisBlock.CloneAsHeader();
     var storedGenesis = new StoredBlock(genesisHeader, genesisHeader.GetWork(), 0);
     Put(storedGenesis);
     SetChainHead(storedGenesis);
 }
开发者ID:aklein53,项目名称:bitcoinsharp,代码行数:9,代码来源:MemoryBlockStore.cs


示例9: Wallet

 /// <summary>
 /// Creates a new, empty wallet with no keys and no transactions. If you want to restore a wallet from disk instead,
 /// see loadFromFile.
 /// </summary>
 public Wallet(NetworkParameters @params)
 {
     _params = @params;
     Keychain = new List<EcKey>();
     Unspent = new Dictionary<Sha256Hash, Transaction>();
     Spent = new Dictionary<Sha256Hash, Transaction>();
     _inactive = new Dictionary<Sha256Hash, Transaction>();
     Pending = new Dictionary<Sha256Hash, Transaction>();
     _dead = new Dictionary<Sha256Hash, Transaction>();
 }
开发者ID:bitspill,项目名称:Gridcoin-master,代码行数:14,代码来源:Wallet.cs


示例10: VersionMessage

 public VersionMessage(NetworkParameters @params, uint newBestHeight)
     : base(@params)
 {
     ClientVersion = NetworkParameters.ProtocolVersion;
     LocalServices = 0;
     Time = UnixTime.ToUnixTime(DateTime.UtcNow);
     // Note that the official client doesn't do anything with these, and finding out your own external IP address
     // is kind of tricky anyway, so we just put nonsense here for now.
     MyAddr = new PeerAddress(IPAddress.Loopback, @params.Port, 0);
     TheirAddr = new PeerAddress(IPAddress.Loopback, @params.Port, 0);
     SubVer = "BitCoinSharp 0.1";
     BestHeight = newBestHeight;
 }
开发者ID:Tsunami-ide,项目名称:Bitcoin,代码行数:13,代码来源:VersionMessage.cs


示例11: BoundedOverheadBlockStore

 /// <exception cref="BitCoinSharp.BlockStoreException" />
 public BoundedOverheadBlockStore(NetworkParameters @params, FileInfo file)
 {
     _params = @params;
     _notFoundMarker = new StoredBlock(null, null, uint.MaxValue);
     try
     {
         Load(file);
     }
     catch (IOException e)
     {
         _log.Error("failed to load block store from file", e);
         CreateNewStore(@params, file);
     }
 }
开发者ID:aklein53,项目名称:bitcoinsharp,代码行数:15,代码来源:BoundedOverheadBlockStore.cs


示例12: TransactionOutPoint

 internal TransactionOutPoint(NetworkParameters @params, int index, Transaction fromTx)
     : base(@params)
 {
     Index = index;
     if (fromTx != null)
     {
         Hash = fromTx.Hash;
         FromTx = fromTx;
     }
     else
     {
         // This happens when constructing the genesis block.
         Hash = Sha256Hash.ZeroHash;
     }
 }
开发者ID:aklein53,项目名称:bitcoinsharp,代码行数:15,代码来源:TransactionOutPoint.cs


示例13: DiskBlockStore

 /// <exception cref="BitCoinSharp.BlockStoreException" />
 public DiskBlockStore(NetworkParameters @params, FileInfo file)
 {
     _params = @params;
     _blockMap = new Dictionary<Sha256Hash, StoredBlock>();
     try
     {
         Load(file);
         if (_stream != null)
         {
             _stream.Dispose();
         }
         _stream = file.Open(FileMode.Append, FileAccess.Write); // Do append.
     }
     catch (IOException e)
     {
         _log.Error("failed to load block store from file", e);
         CreateNewStore(@params, file);
     }
 }
开发者ID:aklein53,项目名称:bitcoinsharp,代码行数:20,代码来源:DiskBlockStore.cs


示例14: Message

 /// <exception cref="ProtocolException"/>
 internal Message(NetworkParameters @params, byte[] msg, int offset, uint protocolVersion = NetworkParameters.ProtocolVersion)
 {
     ProtocolVersion = protocolVersion;
     Params = @params;
     Bytes = msg;
     Cursor = Offset = offset;
     Parse();
     #if SELF_CHECK
     // Useful to ensure serialize/deserialize are consistent with each other.
     if (GetType() != typeof (VersionMessage))
     {
         var msgbytes = new byte[Cursor - offset];
         Array.Copy(msg, offset, msgbytes, 0, Cursor - offset);
         var reserialized = BitcoinSerialize();
         if (!reserialized.SequenceEqual(msgbytes))
             throw new Exception("Serialization is wrong: " + Environment.NewLine +
                                 Utils.BytesToHexString(reserialized) + " vs " + Environment.NewLine +
                                 Utils.BytesToHexString(msgbytes));
     }
     #endif
     Bytes = null;
 }
开发者ID:aklein53,项目名称:bitcoinsharp,代码行数:23,代码来源:Message.cs


示例15: ListMessage

 public ListMessage(NetworkParameters @params)
     : base(@params)
 {
     _items = new List<InventoryItem>();
 }
开发者ID:Tsunami-ide,项目名称:Bitcoin,代码行数:5,代码来源:ListMessage.cs


示例16: CreateGenesis

 private static Block CreateGenesis(NetworkParameters n)
 {
     var genesisBlock = new Block(n);
     var t = new Transaction(n);
     try
     {
         // A script containing the difficulty bits and the following message:
         //
         //   "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"
         var bytes = Hex.Decode("04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73");
         t.AddInput(new TransactionInput(n, t, bytes));
         using (var scriptPubKeyBytes = new MemoryStream())
         {
             Script.WriteBytes(scriptPubKeyBytes, Hex.Decode("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f"));
             scriptPubKeyBytes.Write(Script.OpCheckSig);
             t.AddOutput(new TransactionOutput(n, scriptPubKeyBytes.ToArray()));
         }
     }
     catch (Exception)
     {
     }
     genesisBlock.AddTransaction(t);
     return genesisBlock;
 }
开发者ID:Tsunami-ide,项目名称:Bitcoin,代码行数:24,代码来源:NetworkParameters.cs


示例17: SeedPeers

 public SeedPeers(NetworkParameters @params)
 {
     _params = @params;
 }
开发者ID:Tsunami-ide,项目名称:Bitcoin,代码行数:4,代码来源:SeedPeers.cs


示例18: Script

        private byte[] _programCopy; // TODO: remove this

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Construct a Script using the given network parameters and a range of the programBytes array.
        /// </summary>
        /// <param name="params">Network parameters.</param>
        /// <param name="programBytes">Array of program bytes from a transaction.</param>
        /// <param name="offset">How many bytes into programBytes to start reading from.</param>
        /// <param name="length">How many bytes to read.</param>
        /// <exception cref="ScriptException"/>
        public Script(NetworkParameters @params, byte[] programBytes, int offset, int length)
        {
            _params = @params;
            Parse(programBytes, offset, length);
        }
开发者ID:bitspill,项目名称:Gridcoin-master,代码行数:19,代码来源:Script.cs


示例19: UnitTests

 /// <summary>
 /// Returns a testnet params modified to allow any difficulty target.
 /// </summary>
 internal static NetworkParameters UnitTests()
 {
     var n = new NetworkParameters();
     n = CreateTestNet(n);
     n.ProofOfWorkLimit = new BigInteger("00ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16);
     n.GenesisBlock.DifficultyTarget = Block.EasiestDifficultyTarget;
     n.Interval = 10;
     n.TargetTimespan = 200000000; // 6 years. Just a very big number.
     return n;
 }
开发者ID:Tsunami-ide,项目名称:Bitcoin,代码行数:13,代码来源:NetworkParameters.cs


示例20: TestNet

 /// <summary>
 /// The test chain created by Gavin.
 /// </summary>
 public static NetworkParameters TestNet()
 {
     var n = new NetworkParameters();
     return CreateTestNet(n);
 }
开发者ID:Tsunami-ide,项目名称:Bitcoin,代码行数:8,代码来源:NetworkParameters.cs



注:本文中的BitCoinSharp.NetworkParameters类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Internal.ComponentBuffer类代码示例发布时间:2022-05-24
下一篇:
C# FastA.FastAParser类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap