Exemplo n.º 1
0
        // Adds a friend based on a wallet address
        // Returns false if the wallet address could not be found in the Presence List
        static public bool addFriend(byte[] wallet)
        {
            Presence presence = PresenceList.getPresenceByAddress(wallet);

            if (presence == null)
            {
                return(false);
            }

            TestFriend friend = new TestFriend();

            friend.walletAddress = presence.wallet;
            friend.publicKey     = presence.pubkey;

            friends.Add(friend);

            // For testing purposes, we also initiate a key exchange by sending a message
            // In a normal client, we'd wait for an accept friend request-type message first
            return(sendTestMessage(friend));
        }
Exemplo n.º 2
0
        // Sends a test message to a specified friend
        static public bool sendTestMessage(TestFriend friend)
        {
            return(false);

            /*// Search for the relay ip
             * string relayip = friend.searchForRelay();
             *
             * if (relayip == null)
             * {
             *  Logging.error("No relay ip found.");
             *  return false;
             * }
             *
             * Logging.info(String.Format("Relay: {0}", relayip));
             *
             * // Check if we're connected to the relay node
             * TestStreamClient stream_client = TestStreamClientManager.isConnectedTo(relayip);
             * if (stream_client == null)
             * {
             *  // In a normal client, this should be done in a different thread and wait for the
             *  // connection to be established
             *  stream_client = TestStreamClientManager.connectTo(relayip);
             *
             *  if (stream_client == null)
             *  {
             *      Logging.error(string.Format("Error sending message. Could not connect to stream node: {0}", relayip));
             *  }
             * }
             *
             * // Generate encryption keys
             * byte[] keys_data = friend.generateKeys();
             *
             * // Generate the transaction
             * Transaction transaction = new Transaction((int)Transaction.Type.Normal);
             * transaction.amount = ConsensusConfig.relayPriceInitial;
             * transaction.toList.Add(friend.relayWallet, transaction.amount);
             * transaction.fee = ConsensusConfig.transactionPrice;
             * transaction.fromList.Add(new byte[1] { 0 }, transaction.amount + transaction.fee);
             * transaction.blockHeight = Node.blockHeight;
             * transaction.pubKey = Node.walletStorage.getPrimaryPublicKey(); // TODO: check if it's in the walletstate already
             * transaction.checksum = Transaction.calculateChecksum(transaction);
             *
             * // Prepare the stream message
             * StreamMessage message = new StreamMessage();
             * message.recipient = friend.walletAddress;
             * message.sender = Node.walletStorage.getPrimaryAddress();
             * message.transaction = transaction.getBytes();
             *
             *
             * // Encrypt the message
             * byte[] text_message = Encoding.UTF8.GetBytes("Hello Ixian World!");
             * message.encrypt(friend.publicKey, friend.aesKey, friend.chachaKey);
             *
             * // Encrypt the transaction signature
             * byte[] tx_signature = transaction.getSignature(transaction.checksum);
             * message.encryptSignature(tx_signature, friend.aesKey, friend.chachaKey);
             *
             * stream_client.sendData(ProtocolMessageCode.s2data, message.getBytes());
             *
             * return true; */
        }