예제 #1
0
 public NodeAnnouncementMessage(byte[] signature, byte[] features, DateTime timestamp, ECKeyPair nodeId,
                                String color, String alias, List <NetworkAddress> addresses) : base(MessageDefinition)
 {
     Signature         = signature;
     Features          = features;
     Timestamp         = timestamp;
     NodeId            = nodeId;
     Color             = color;
     Alias             = alias;
     _networkAddresses = NetworkAddress.Encode(addresses);
     NodeIdHex         = nodeId.PublicKeyCompressed.ToHex();
 }
예제 #2
0
        public void EncodeDecode_ReturnsInputDataExactly()
        {
            var netAddr = new NetworkAddress(true);

            netAddr.Decode(baseNetAddrEncoded);

            var unixTs    = BitConverter.ToInt32(new byte[] { 0x29, 0xab, 0x5f, 0x49 }, 0);
            var timestamp = DateTimeExtensions.FromUnixTime(unixTs);

            Assert.Equal(timestamp.Date, new DateTime(2009, 1, 3));
            Assert.Equal(timestamp, netAddr.Timestamp);

            Assert.Equal(netAddr.Services, ServiceFlag.NodeNetwork);
            Assert.Equal(netAddr.Port, 8333);

            var bytes = netAddr.Encode();

            Assert.True(bytes.SequenceEqual(baseNetAddrEncoded));
        }