summaryrefslogtreecommitdiff
path: root/testing/toxic
diff options
context:
space:
mode:
Diffstat (limited to 'testing/toxic')
-rw-r--r--testing/toxic/chat.c8
-rw-r--r--testing/toxic/prompt.c14
2 files changed, 13 insertions, 9 deletions
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c
index 35be3bd3..1b5e743d 100644
--- a/testing/toxic/chat.c
+++ b/testing/toxic/chat.c
@@ -307,11 +307,13 @@ void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd)
307 } 307 }
308 308
309 else if (!strcmp(cmd, "/myid")) { 309 else if (!strcmp(cmd, "/myid")) {
310 char id[KEY_SIZE_BYTES*2+1] = {0}; 310 char id[FRIEND_ADDRESS_SIZE*2+1] = {0};
311 int i; 311 int i;
312 for (i = 0; i < KEY_SIZE_BYTES; i++) { 312 uint8_t address[FRIEND_ADDRESS_SIZE];
313 getaddress(m, address);
314 for (i = 0; i < FRIEND_ADDRESS_SIZE; i++) {
313 char xx[3]; 315 char xx[3];
314 snprintf(xx, sizeof(xx), "%02x", self_public_key[i] & 0xff); 316 snprintf(xx, sizeof(xx), "%02X", address[i] & 0xff);
315 strcat(id, xx); 317 strcat(id, xx);
316 } 318 }
317 wprintw(ctx->history, "Your ID: %s\n", id); 319 wprintw(ctx->history, "Your ID: %s\n", id);
diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c
index 67f80fef..e1a7d75c 100644
--- a/testing/toxic/prompt.c
+++ b/testing/toxic/prompt.c
@@ -93,7 +93,7 @@ void cmd_accept(ToxWindow *self, Messenger *m, char **args)
93 93
94void cmd_add(ToxWindow *self, Messenger *m, char **args) 94void cmd_add(ToxWindow *self, Messenger *m, char **args)
95{ 95{
96 uint8_t id_bin[KEY_SIZE_BYTES]; 96 uint8_t id_bin[FRIEND_ADDRESS_SIZE];
97 char xx[3]; 97 char xx[3];
98 uint32_t x; 98 uint32_t x;
99 char *id = args[1]; 99 char *id = args[1];
@@ -106,12 +106,12 @@ void cmd_add(ToxWindow *self, Messenger *m, char **args)
106 if (!msg) 106 if (!msg)
107 msg = ""; 107 msg = "";
108 108
109 if (strlen(id) != 2*KEY_SIZE_BYTES) { 109 if (strlen(id) != 2*FRIEND_ADDRESS_SIZE) {
110 wprintw(self->window, "Invalid ID length.\n"); 110 wprintw(self->window, "Invalid ID length.\n");
111 return; 111 return;
112 } 112 }
113 int i; 113 int i;
114 for (i = 0; i < KEY_SIZE_BYTES; ++i) { 114 for (i = 0; i < FRIEND_ADDRESS_SIZE; ++i) {
115 xx[0] = id[2*i]; 115 xx[0] = id[2*i];
116 xx[1] = id[2*i+1]; 116 xx[1] = id[2*i+1];
117 xx[2] = '\0'; 117 xx[2] = '\0';
@@ -217,11 +217,13 @@ void cmd_msg(ToxWindow *self, Messenger *m, char **args)
217 217
218void cmd_myid(ToxWindow *self, Messenger *m, char **args) 218void cmd_myid(ToxWindow *self, Messenger *m, char **args)
219{ 219{
220 char id[KEY_SIZE_BYTES*2 + 1] = {0}; 220 char id[FRIEND_ADDRESS_SIZE*2 + 1] = {0};
221 size_t i; 221 size_t i;
222 for (i = 0; i < KEY_SIZE_BYTES; ++i) { 222 uint8_t address[FRIEND_ADDRESS_SIZE];
223 getaddress(m, address);
224 for (i = 0; i < FRIEND_ADDRESS_SIZE; ++i) {
223 char xx[3]; 225 char xx[3];
224 snprintf(xx, sizeof(xx), "%02x", self_public_key[i] & 0xff); 226 snprintf(xx, sizeof(xx), "%02X", address[i] & 0xff);
225 strcat(id, xx); 227 strcat(id, xx);
226 } 228 }
227 wprintw(self->window, "Your ID: %s\n", id); 229 wprintw(self->window, "Your ID: %s\n", id);