@@ -243,6 +243,7 @@ status_t ta_send_transfer_req_deserialize(const char* const obj,
243
243
cJSON * json_result = NULL ;
244
244
flex_trit_t tag_trits [NUM_TRITS_TAG ], address_trits [NUM_TRITS_HASH ];
245
245
int msg_len = 0 , tag_len = 0 ;
246
+ bool raw_message = true;
246
247
status_t ret = SC_OK ;
247
248
248
249
if (json_obj == NULL ) {
@@ -288,13 +289,29 @@ status_t ta_send_transfer_req_deserialize(const char* const obj,
288
289
goto done ;
289
290
}
290
291
292
+ json_result = cJSON_GetObjectItemCaseSensitive (json_obj , "message_format" );
293
+ if (json_result != NULL ) {
294
+ strncmp ("trytes" , json_result -> valuestring , 6 );
295
+ raw_message = false;
296
+ }
297
+
291
298
json_result = cJSON_GetObjectItemCaseSensitive (json_obj , "message" );
292
299
if (json_result != NULL ) {
293
- msg_len = strlen (json_result -> valuestring );
294
- req -> msg_len = msg_len * 3 ;
295
- flex_trits_from_trytes (req -> message , req -> msg_len ,
296
- (const tryte_t * )json_result -> valuestring , msg_len ,
297
- msg_len );
300
+ if (raw_message ) {
301
+ msg_len = strlen (json_result -> valuestring ) * 2 ;
302
+ req -> msg_len = msg_len * 3 ;
303
+ tryte_t trytes_buffer [msg_len ];
304
+
305
+ ascii_to_trytes (json_result -> valuestring , trytes_buffer );
306
+ flex_trits_from_trytes (req -> message , req -> msg_len , trytes_buffer , msg_len ,
307
+ msg_len );
308
+ } else {
309
+ msg_len = strlen (json_result -> valuestring );
310
+ req -> msg_len = msg_len * 3 ;
311
+ flex_trits_from_trytes (req -> message , req -> msg_len ,
312
+ (const tryte_t * )json_result -> valuestring , msg_len ,
313
+ msg_len );
314
+ }
298
315
} else {
299
316
// 'message' does not exists, set to DEFAULT_MSG
300
317
req -> msg_len = DEFAULT_MSG_LEN * 3 ;
0 commit comments