diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..b4abfa06 --- /dev/null +++ b/.clang-format @@ -0,0 +1,20 @@ +--- +BasedOnStyle: Google +IndentWidth: 4 +--- +Language: Cpp +ColumnLimit: 100 +PointerAlignment: Right +AlignAfterOpenBracket: Align +AlignConsecutiveMacros: true +AllowAllParametersOfDeclarationOnNextLine: false +SortIncludes: false +SpaceAfterCStyleCast: true +AllowShortCaseLabelsOnASingleLine: false +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Never +AllowShortFunctionsOnASingleLine: None +BinPackArguments: false +BinPackParameters: false +--- diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml new file mode 100644 index 00000000..128c4fb4 --- /dev/null +++ b/.github/workflows/ci-workflow.yml @@ -0,0 +1,26 @@ +name: Compilation & tests + +on: [push, pull_request] + +jobs: + job_build_debug: + name: Build debug + runs-on: ubuntu-latest + + container: + image: docker://ledgerhq/ledger-app-builder:1.6.1-2 + + steps: + - name: Clone + uses: actions/checkout@v2 + + - name: Build Stellar + run: | + make clean + make DEBUG=1 + + - name: Upload app binary + uses: actions/upload-artifact@v2 + with: + name: stellar-app-debug + path: bin diff --git a/.github/workflows/lint-workflow.yml b/.github/workflows/lint-workflow.yml new file mode 100644 index 00000000..6d07bc91 --- /dev/null +++ b/.github/workflows/lint-workflow.yml @@ -0,0 +1,19 @@ +name: Code style check + +on: [push, pull_request] + +jobs: + job_lint: + name: Lint + runs-on: ubuntu-latest + + steps: + - name: Clone + uses: actions/checkout@v2 + + - name: Lint + uses: DoozyX/clang-format-lint-action@v0.11 + with: + source: "./" + extensions: "h,c" + clangFormatVersion: 10 diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..7fdbf7f3 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,49 @@ +{ + "env": { + "BOLOS_SDK": "/opt/nanos-secure-sdk", + "BOLOS_ENV": "/opt/bolos-devenv" + }, + "configurations": [ + { + "name": "Nano S", + "includePath": [ + "/usr/include", + "${workspaceFolder}/src", + "${env:BOLOS_SDK}/include/*", + "${env:BOLOS_SDK}/lib_ux/include/*" + ], + "defines": [ + "TARGET_NANOS", + "OS_IO_SEPROXYHAL", + "HAVE_BAGL", + "HAVE_SPRINTF", + "HAVE_IO_USB", + "HAVE_L4_USBLIB", + "IO_USB_MAX_ENDPOINTS=6", + "IO_HID_EP_LENGTH=64", + "HAVE_USB_APDU", + "USB_SEGMENT_SIZE=64", + "UNUSED(x)=(void)x", + "APPVERSION=\"1.0.0\"", + "APPNAME=\"Boilerplate\"", + "MAJOR_VERSION=1", + "MINOR_VERSION=0", + "PATCH_VERSION=0", + "IO_SEPROXYHAL_BUFFER_SIZE_B=128", + "HAVE_UX_FLOW", + "DEBUG=1", + "HAVE_PRINTF", + "PRINTF=screen_printf" + ], + "compilerPath": "${env:BOLOS_ENV}/gcc-arm-none-eabi-5_3-2016q1/bin/arm-none-eabi-gcc", + "cStandard": "c11", + "cppStandard": "c++17", + "intelliSenseMode": "gcc-arm", + "browse": { + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..6b6ceecb --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "gdb", + "request": "attach", + "name": "Attach to gdbserver", + "executable": "${workspaceFolder}/bin/app.elf", + "target": ":1234", + "remote": true, + "cwd": "${workspaceFolder}", + "valuesFormatting": "parseText", + "gdbpath": "gdb-multiarch", + "autorun": [ + "set architecture arm", + "handle SIGILL nostop pass noprint", + "add-symbol-file ${workspaceFolder}/bin/app.elf 0x40000000", + "b *0x40000000", + "c" + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..34f721f3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "files.associations": { + "*.h": "c", + "vector": "c", + "memory": "c", + "thread": "c", + "string": "c" + }, + "C_Cpp.clang_format_path": "/usr/bin/clang-format", + "editor.formatOnSave": true +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..167e70c4 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,111 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "make", + "type": "shell", + "command": "make clean && make", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [ + "$gcc" + ] + }, + { + "label": "[debug] make", + "type": "shell", + "command": "make clean && make DEBUG=1", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [ + "$gcc" + ] + }, + { + "label": "make clean", + "type": "shell", + "command": "make clean", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [ + "$gcc" + ] + }, + { + "label": "make load", + "type": "shell", + "command": "make load", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [ + "$gcc" + ] + }, + { + "label": "run unit tests", + "type": "shell", + "command": "cd unit-tests && rm -rf build && cmake -Bbuild -H. && make -C build && CTEST_OUTPUT_ON_FAILURE=1 make -C build test", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [ + "$gcc" + ] + }, + { + "label": "run Speculos", + "type": "shell", + "command": "python /path/to/speculos/speculos.py ${workspaceFolder}/bin/app.elf --ontop --sdk 1.6 --apdu-port 9999 --button-port 42000 --automation-port 43000", + "group": { + "kind": "build", + "isDefault": true + }, + "dependsOn": [ + "make debug" + ], + "problemMatcher": [] + }, + { + "label": "[debug] run Speculos", + "type": "shell", + "command": "python /path/to/speculos/speculos.py -d ${workspaceFolder}/bin/app.elf --ontop --sdk 1.6 --apdu-port 9999 --button-port 42000 --automation-port 43000", + "group": { + "kind": "build", + "isDefault": true + }, + "dependsOn": [ + "make debug" + ], + "problemMatcher": [] + }, + { + "label": "run tests", + "type": "shell", + "command": "cd tests && pytest", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "label": "kill Speculos", + "type": "shell", + "command": "pkill -f speculos.py", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + } + ] +} \ No newline at end of file diff --git a/src/main.c b/src/main.c index 2e668282..c3307e97 100644 --- a/src/main.c +++ b/src/main.c @@ -1,19 +1,19 @@ /******************************************************************************* -* Ledger Stellar App -* (c) 2017-2018 Ledger -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -********************************************************************************/ + * Ledger Stellar App + * (c) 2017-2018 Ledger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ********************************************************************************/ #include "os.h" #include "cx.h" @@ -29,26 +29,29 @@ unsigned short io_exchange_al(unsigned char channel, unsigned short tx_len) { switch (channel & ~(IO_FLAGS)) { - case CHANNEL_KEYBOARD: - break; - case CHANNEL_SPI: - if (tx_len) { - io_seproxyhal_spi_send(G_io_apdu_buffer, tx_len); - - if (channel & IO_RESET_AFTER_REPLIED) { - reset(); + case CHANNEL_KEYBOARD: + break; + case CHANNEL_SPI: + if (tx_len) { + io_seproxyhal_spi_send(G_io_apdu_buffer, tx_len); + + if (channel & IO_RESET_AFTER_REPLIED) { + reset(); + } + return 0; + } else { + return io_seproxyhal_spi_recv(G_io_apdu_buffer, sizeof(G_io_apdu_buffer), 0); } - return 0; - } else { - return io_seproxyhal_spi_recv(G_io_apdu_buffer, sizeof(G_io_apdu_buffer), 0); - } - default: - THROW(INVALID_PARAMETER); + default: + THROW(INVALID_PARAMETER); } return 0; } -static void handle_apdu(uint8_t *buffer, size_t size, volatile unsigned int *flags, volatile unsigned int *tx) { +static void handle_apdu(uint8_t *buffer, + size_t size, + volatile unsigned int *flags, + volatile unsigned int *tx) { unsigned short sw = 0; BEGIN_TRY { @@ -67,53 +70,53 @@ static void handle_apdu(uint8_t *buffer, size_t size, volatile unsigned int *fla THROW(0x6e00); } - PRINTF("New APDU:\n%.*H\n", dataLength+4, G_io_apdu_buffer); + PRINTF("New APDU:\n%.*H\n", dataLength + 4, G_io_apdu_buffer); // reset keep-alive for u2f just short of 30sec ctx.u2fTimer = U2F_REQUEST_TIMEOUT; switch (ins) { - case INS_GET_PUBLIC_KEY: - handle_get_public_key(p1, p2, dataBuffer, dataLength, flags, tx); - break; + case INS_GET_PUBLIC_KEY: + handle_get_public_key(p1, p2, dataBuffer, dataLength, flags, tx); + break; - case INS_SIGN_TX: - handle_sign_tx(p1, p2, dataBuffer, dataLength, flags); - break; + case INS_SIGN_TX: + handle_sign_tx(p1, p2, dataBuffer, dataLength, flags); + break; - case INS_SIGN_TX_HASH: - handle_sign_tx_hash(dataBuffer, dataLength, flags); - break; + case INS_SIGN_TX_HASH: + handle_sign_tx_hash(dataBuffer, dataLength, flags); + break; - case INS_GET_APP_CONFIGURATION: - handle_get_app_configuration(tx); - break; + case INS_GET_APP_CONFIGURATION: + handle_get_app_configuration(tx); + break; - case INS_KEEP_ALIVE: - handle_keep_alive(flags); - break; - default: - THROW(0x6D00); - break; + case INS_KEEP_ALIVE: + handle_keep_alive(flags); + break; + default: + THROW(0x6D00); + break; } } CATCH(EXCEPTION_IO_RESET) { THROW(EXCEPTION_IO_RESET); - } + } CATCH_OTHER(e) { switch (e & 0xF000) { - case 0x6000: - // Wipe the transaction context and report the exception - sw = e; - break; - case 0x9000: - // All is well - sw = e; - break; - default: - // Internal error - sw = 0x6800 | (e & 0x7FF); - break; + case 0x6000: + // Wipe the transaction context and report the exception + sw = e; + break; + case 0x9000: + // All is well + sw = e; + break; + default: + // Internal error + sw = 0x6800 | (e & 0x7FF); + break; } // Unexpected exception => report G_io_apdu_buffer[*tx] = sw >> 8; @@ -129,9 +132,9 @@ static void handle_apdu(uint8_t *buffer, size_t size, volatile unsigned int *fla static void stellar_nv_state_init() { if (N_stellar_pstate.initialized != 0x01) { uint8_t initialized = 0x01; - nvm_write((void*)&N_stellar_pstate.initialized, &initialized, 1); + nvm_write((void *) &N_stellar_pstate.initialized, &initialized, 1); uint8_t hashSigning = 0x00; - nvm_write((void*)&N_stellar_pstate.hashSigning, &hashSigning, 1); + nvm_write((void *) &N_stellar_pstate.hashSigning, &hashSigning, 1); } } @@ -174,23 +177,23 @@ static void stellar_main(void) { } CATCH_OTHER(e) { switch (e & 0xF000) { - case 0x6000: - // Wipe the transaction context and report the exception - sw = e; - break; - case 0x9000: - // All is well - sw = e; - break; - default: - // Internal error - sw = 0x6800 | (e & 0x7FF); - /* Ensure further io_exchange() calls aren't done with an - * unexpected flag, since it can trigger infinite loops if - * this flag trigger again an exception. */ - flags = 0; - ui_idle(); - break; + case 0x6000: + // Wipe the transaction context and report the exception + sw = e; + break; + case 0x9000: + // All is well + sw = e; + break; + default: + // Internal error + sw = 0x6800 | (e & 0x7FF); + /* Ensure further io_exchange() calls aren't done with an + * unexpected flag, since it can trigger infinite loops if + * this flag trigger again an exception. */ + flags = 0; + ui_idle(); + break; } // Unexpected exception => report G_io_apdu_buffer[tx] = sw >> 8; @@ -209,7 +212,7 @@ static void stellar_main(void) { // override point, but nothing more to do void io_seproxyhal_display(const bagl_element_t *element) { - io_seproxyhal_display_default((bagl_element_t *)element); + io_seproxyhal_display_default((bagl_element_t *) element); } void u2f_send_keep_alive() { @@ -220,52 +223,51 @@ void u2f_send_keep_alive() { } unsigned char io_event(unsigned char channel) { - // can't have more than one tag in the reply, not supported yet. switch (G_io_seproxyhal_spi_buffer[0]) { - case SEPROXYHAL_TAG_FINGER_EVENT: - UX_FINGER_EVENT(G_io_seproxyhal_spi_buffer); - break; - - case SEPROXYHAL_TAG_BUTTON_PUSH_EVENT: - UX_BUTTON_PUSH_EVENT(G_io_seproxyhal_spi_buffer); - break; - - case SEPROXYHAL_TAG_STATUS_EVENT: - if (G_io_apdu_media == IO_APDU_MEDIA_USB_HID && - !(U4BE(G_io_seproxyhal_spi_buffer, 3) & - SEPROXYHAL_TAG_STATUS_EVENT_FLAG_USB_POWERED)) { - THROW(EXCEPTION_IO_RESET); - } - // no break is intentional - default: - UX_DEFAULT_EVENT(); - break; + case SEPROXYHAL_TAG_FINGER_EVENT: + UX_FINGER_EVENT(G_io_seproxyhal_spi_buffer); + break; + + case SEPROXYHAL_TAG_BUTTON_PUSH_EVENT: + UX_BUTTON_PUSH_EVENT(G_io_seproxyhal_spi_buffer); + break; + + case SEPROXYHAL_TAG_STATUS_EVENT: + if (G_io_apdu_media == IO_APDU_MEDIA_USB_HID && + !(U4BE(G_io_seproxyhal_spi_buffer, 3) & + SEPROXYHAL_TAG_STATUS_EVENT_FLAG_USB_POWERED)) { + THROW(EXCEPTION_IO_RESET); + } + // no break is intentional + default: + UX_DEFAULT_EVENT(); + break; - case SEPROXYHAL_TAG_DISPLAY_PROCESSED_EVENT: - UX_DISPLAYED_EVENT({}); - break; + case SEPROXYHAL_TAG_DISPLAY_PROCESSED_EVENT: + UX_DISPLAYED_EVENT({}); + break; - case SEPROXYHAL_TAG_TICKER_EVENT: + case SEPROXYHAL_TAG_TICKER_EVENT: - if (G_io_apdu_media == IO_APDU_MEDIA_U2F && ctx.u2fTimer > 0) { - ctx.u2fTimer -= 100; - if (ctx.u2fTimer <= 0) { - u2f_send_keep_alive(); + if (G_io_apdu_media == IO_APDU_MEDIA_U2F && ctx.u2fTimer > 0) { + ctx.u2fTimer -= 100; + if (ctx.u2fTimer <= 0) { + u2f_send_keep_alive(); + } } - } - UX_TICKER_EVENT(G_io_seproxyhal_spi_buffer, { -#if defined(TARGET_NANOS) && !defined(HAVE_UX_FLOW) // S legacy only - if (UX_ALLOWED) { - if (ctx.reqType == CONFIRM_TRANSACTION) { - ui_approve_tx_next_screen(&ctx.req.tx); + UX_TICKER_EVENT(G_io_seproxyhal_spi_buffer, { +#if defined(TARGET_NANOS) && !defined(HAVE_UX_FLOW) // S legacy only + if (UX_ALLOWED) { + if (ctx.reqType == CONFIRM_TRANSACTION) { + ui_approve_tx_next_screen(&ctx.req.tx); + } + UX_REDISPLAY(); } - UX_REDISPLAY(); - } #endif - }); - break; + }); + break; } // close the event if not done previously (by a display or whatever) @@ -301,12 +303,12 @@ __attribute__((section(".boot"))) int main(void) { TRY { io_seproxyhal_init(); -#ifdef TARGET_NANOX - // grab the current plane mode setting - G_io_app.plane_mode = os_setting_get(OS_SETTING_PLANEMODE, NULL, 0); -#endif // TARGET_NANOX +#ifdef TARGET_NANOX + // grab the current plane mode setting + G_io_app.plane_mode = os_setting_get(OS_SETTING_PLANEMODE, NULL, 0); +#endif // TARGET_NANOX - stellar_nv_state_init(); + stellar_nv_state_init(); // deactivate usb before activating USB_power(0); @@ -317,7 +319,7 @@ __attribute__((section(".boot"))) int main(void) { #ifdef HAVE_BLE BLE_power(0, NULL); BLE_power(1, "Nano X"); -#endif // HAVE_BLE +#endif // HAVE_BLE stellar_main(); } diff --git a/src/stellar.c b/src/stellar.c index f8c2ae51..a187bc44 100644 --- a/src/stellar.c +++ b/src/stellar.c @@ -24,10 +24,12 @@ #include "stellar_ux.h" static void app_set_state(enum app_state_t state) { - ctx.state = state; + ctx.state = state; } -static enum app_state_t app_get_state() { return ctx.state; } +static enum app_state_t app_get_state() { + return ctx.state; +} static int read_bip32(const uint8_t *dataBuffer, size_t size, uint32_t *bip32) { size_t bip32Len = dataBuffer[0]; @@ -36,11 +38,12 @@ static int read_bip32(const uint8_t *dataBuffer, size_t size, uint32_t *bip32) { THROW(0x6a80); } if (1 + 4 * bip32Len > size) { - THROW(0x6a80); + THROW(0x6a80); } for (unsigned int i = 0; i < bip32Len; i++) { - bip32[i] = (dataBuffer[0] << 24u) | (dataBuffer[1] << 16u) | (dataBuffer[2] << 8u) | (dataBuffer[3]); + bip32[i] = (dataBuffer[0] << 24u) | (dataBuffer[1] << 16u) | (dataBuffer[2] << 8u) | + (dataBuffer[3]); dataBuffer += 4; } return bip32Len; @@ -49,13 +52,22 @@ static int read_bip32(const uint8_t *dataBuffer, size_t size, uint32_t *bip32) { void derive_private_key(cx_ecfp_private_key_t *privateKey, uint32_t *bip32, uint8_t bip32Len) { uint8_t privateKeyData[32]; io_seproxyhal_io_heartbeat(); - os_perso_derive_node_bip32_seed_key(HDW_ED25519_SLIP10, CX_CURVE_Ed25519, bip32, bip32Len, privateKeyData, NULL, (unsigned char*) "ed25519 seed", 12); + os_perso_derive_node_bip32_seed_key(HDW_ED25519_SLIP10, + CX_CURVE_Ed25519, + bip32, + bip32Len, + privateKeyData, + NULL, + (unsigned char *) "ed25519 seed", + 12); io_seproxyhal_io_heartbeat(); cx_ecfp_init_private_key(CX_CURVE_Ed25519, privateKeyData, 32, privateKey); MEMCLEAR(privateKeyData); } -void init_public_key(cx_ecfp_private_key_t *privateKey, cx_ecfp_public_key_t *publicKey, uint8_t *buffer) { +void init_public_key(cx_ecfp_private_key_t *privateKey, + cx_ecfp_public_key_t *publicKey, + uint8_t *buffer) { cx_ecfp_generate_pair(CX_CURVE_Ed25519, publicKey, privateKey, 1); // copy public key little endian to big endian @@ -89,7 +101,12 @@ static uint32_t set_result_get_public_key(void) { return tx; } -void handle_get_public_key(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uint16_t dataLength, volatile unsigned int *flags, volatile unsigned int *tx) { +void handle_get_public_key(uint8_t p1, + uint8_t p2, + uint8_t *dataBuffer, + uint16_t dataLength, + volatile unsigned int *flags, + volatile unsigned int *tx) { app_set_state(STATE_NONE); if ((p1 != P1_SIGNATURE) && (p1 != P1_NO_SIGNATURE)) { @@ -116,7 +133,7 @@ void handle_get_public_key(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uint16_t if (msgLength >= 32) { THROW(0x6a80); } - for (i=0; i 0x7e)) { THROW(0x6a80); } @@ -132,7 +149,16 @@ void handle_get_public_key(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uint16_t if (ctx.req.pk.returnSignature) { #if CX_APILEVEL >= 8 io_seproxyhal_io_heartbeat(); - cx_eddsa_sign(&privateKey, CX_LAST, CX_SHA512, msg, msgLength, NULL, 0, ctx.req.pk.signature, 64, NULL); + cx_eddsa_sign(&privateKey, + CX_LAST, + CX_SHA512, + msg, + msgLength, + NULL, + 0, + ctx.req.pk.signature, + 64, + NULL); io_seproxyhal_io_heartbeat(); #else cx_eddsa_sign(&privateKey, NULL, CX_LAST, CX_SHA512, msg, msgLength, ctx.req.pk.signature); @@ -152,8 +178,11 @@ void handle_get_public_key(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uint16_t } } -void handle_sign_tx(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uint16_t dataLength, volatile unsigned int *flags) { - +void handle_sign_tx(uint8_t p1, + uint8_t p2, + uint8_t *dataBuffer, + uint16_t dataLength, + volatile unsigned int *flags) { if ((p1 != P1_FIRST) && (p1 != P1_MORE)) { THROW(0x6B00); } @@ -185,7 +214,7 @@ void handle_sign_tx(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uint16_t dataLe if (ctx.req.tx.rawLength > MAX_RAW_TX) { THROW(0x6700); } - os_memmove(ctx.req.tx.raw+offset, dataBuffer, dataLength); + os_memmove(ctx.req.tx.raw + offset, dataBuffer, dataLength); } if (p2 == P2_MORE) { @@ -209,10 +238,20 @@ void handle_sign_tx(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uint16_t dataLe // sign hash #if CX_APILEVEL >= 8 io_seproxyhal_io_heartbeat(); - ctx.req.tx.tx = cx_eddsa_sign(&privateKey, CX_LAST, CX_SHA512, ctx.req.tx.hash, 32, NULL, 0, G_io_apdu_buffer, 64, NULL); + ctx.req.tx.tx = cx_eddsa_sign(&privateKey, + CX_LAST, + CX_SHA512, + ctx.req.tx.hash, + 32, + NULL, + 0, + G_io_apdu_buffer, + 64, + NULL); io_seproxyhal_io_heartbeat(); #else - ctx.req.tx.tx = cx_eddsa_sign(&privateKey, NULL, CX_LAST, CX_SHA512, ctx.req.tx.hash, 32, G_io_apdu_buffer); + ctx.req.tx.tx = + cx_eddsa_sign(&privateKey, NULL, CX_LAST, CX_SHA512, ctx.req.tx.hash, 32, G_io_apdu_buffer); #endif MEMCLEAR(privateKey); diff --git a/src/stellar_api.h b/src/stellar_api.h index 65762f74..502a185d 100644 --- a/src/stellar_api.h +++ b/src/stellar_api.h @@ -30,10 +30,19 @@ void handle_get_app_configuration(volatile unsigned int *tx); /** handles get public key request */ -void handle_get_public_key(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uint16_t dataLength, volatile unsigned int *flags, volatile unsigned int *tx); +void handle_get_public_key(uint8_t p1, + uint8_t p2, + uint8_t *dataBuffer, + uint16_t dataLength, + volatile unsigned int *flags, + volatile unsigned int *tx); /** handles sign transaction request (displays transaction details) */ -void handle_sign_tx(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uint16_t dataLength, volatile unsigned int *flags); +void handle_sign_tx(uint8_t p1, + uint8_t p2, + uint8_t *dataBuffer, + uint16_t dataLength, + volatile unsigned int *flags); /** handles sign transaction hash request (displays only transaction hash) */ void handle_sign_tx_hash(uint8_t *dataBuffer, uint16_t dataLength, volatile unsigned int *flags); @@ -41,7 +50,6 @@ void handle_sign_tx_hash(uint8_t *dataBuffer, uint16_t dataLength, volatile unsi /** u2f keep alive */ void handle_keep_alive(volatile unsigned int *flags); - // ------------------------------------------------------------------------- // // TRANSACTION PARSING // // ------------------------------------------------------------------------- // @@ -75,11 +83,11 @@ void print_public_key(const uint8_t *in, char *out, uint8_t numCharsL, uint8_t n void print_summary(char *in, char *out, uint8_t numCharsL, uint8_t numCharsR); /** raw byte buffer to hexadecimal string representation. - * len is length of input, provided output must be twice that size */ + * len is length of input, provided output must be twice that size */ void print_binary(const uint8_t *in, char *out, uint8_t len); /** raw byte buffer to summarized hexadecimal string representation - * len is length of input, provided output must be at least length 19 */ + * len is length of input, provided output must be at least length 19 */ void print_binary_summary(const uint8_t *in, char *out, uint8_t len); /** raw amount integer to asset-qualified string representation */ diff --git a/src/stellar_format_common.c b/src/stellar_format_common.c index 86285305..5f48187d 100644 --- a/src/stellar_format_common.c +++ b/src/stellar_format_common.c @@ -5,12 +5,11 @@ uint8_t current_data_index; format_function_t get_formatter(tx_context_t *txCtx, bool forward) { - - switch(ctx.state){ - case STATE_APPROVE_TX: - { // classic tx - if(!forward){ - if(current_data_index == 0){ // if we're already at the beginning of the buffer, return NULL + switch (ctx.state) { + case STATE_APPROVE_TX: { // classic tx + if (!forward) { + if (current_data_index == + 0) { // if we're already at the beginning of the buffer, return NULL return NULL; } // rewind to tx beginning if we're requesting a previous operation @@ -18,16 +17,15 @@ format_function_t get_formatter(tx_context_t *txCtx, bool forward) { txCtx->opIdx = 0; } - while(current_data_index > txCtx->opIdx){ + while (current_data_index > txCtx->opIdx) { if (!parse_tx_xdr(txCtx->raw, txCtx->rawLength, txCtx)) { return NULL; } - } + } return &format_confirm_operation; } - case STATE_APPROVE_TX_HASH: - { - if(!forward){ + case STATE_APPROVE_TX_HASH: { + if (!forward) { return NULL; } return &format_confirm_hash_warning; @@ -37,12 +35,11 @@ format_function_t get_formatter(tx_context_t *txCtx, bool forward) { } } - void ui_approve_tx_next_screen(tx_context_t *txCtx) { if (!formatter_stack[formatter_index]) { MEMCLEAR(formatter_stack); formatter_index = 0; - current_data_index ++; + current_data_index++; formatter_stack[0] = get_formatter(txCtx, true); } } @@ -51,19 +48,18 @@ void ui_approve_tx_prev_screen(tx_context_t *txCtx) { if (formatter_index == -1) { MEMCLEAR(formatter_stack); formatter_index = 0; - current_data_index --; + current_data_index--; formatter_stack[0] = get_formatter(txCtx, false); } } -void set_state_data(bool forward){ - if(forward){ +void set_state_data(bool forward) { + if (forward) { ui_approve_tx_next_screen(&ctx.req.tx); - } - else{ + } else { ui_approve_tx_prev_screen(&ctx.req.tx); } - + // Apply last formatter to fill the screen's buffer if (formatter_stack[formatter_index]) { MEMCLEAR(detailCaption); @@ -71,12 +67,11 @@ void set_state_data(bool forward){ MEMCLEAR(opCaption); formatter_stack[formatter_index](&ctx.req.tx); - if(opCaption[0] != '\0'){ + if (opCaption[0] != '\0') { strncpy(detailCaption, opCaption, sizeof(detailCaption)); detailValue[0] = ' '; PRINTF("caption: %s %u\n", detailCaption); - } - else if(detailCaption[0] != '\0' && detailValue[0] != '\0'){ + } else if (detailCaption[0] != '\0' && detailValue[0] != '\0') { PRINTF("caption: %s\n", detailCaption); PRINTF("details: %s\n", detailValue); } diff --git a/src/stellar_format_nanos.c b/src/stellar_format_nanos.c index bc471367..7caa22a5 100644 --- a/src/stellar_format_nanos.c +++ b/src/stellar_format_nanos.c @@ -1,19 +1,19 @@ /******************************************************************************* -* Ledger Stellar App -* (c) 2017-2018 Ledger -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -********************************************************************************/ + * Ledger Stellar App + * (c) 2017-2018 Ledger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ********************************************************************************/ #ifndef TEST #include "bolos_target.h" #include "os.h" @@ -34,11 +34,11 @@ char detailValue[89]; format_function_t formatter_stack[MAX_FORMATTERS_PER_OPERATION]; int8_t formatter_index; -void push_to_formatter_stack(format_function_t formatter){ - if(formatter_index + 1 >= MAX_FORMATTERS_PER_OPERATION){ +void push_to_formatter_stack(format_function_t formatter) { + if (formatter_index + 1 >= MAX_FORMATTERS_PER_OPERATION) { THROW(0x6124); } - formatter_stack[formatter_index+1] = formatter; + formatter_stack[formatter_index + 1] = formatter; } void format_sequence_number(tx_context_t *txCtx) { @@ -77,7 +77,7 @@ void format_time_bounds(tx_context_t *txCtx) { void format_network(tx_context_t *txCtx) { strcpy(detailCaption, "Network"); - strcpy(detailValue, ((char *)PIC(NETWORK_NAMES[txCtx->txDetails.network]))); + strcpy(detailValue, ((char *) PIC(NETWORK_NAMES[txCtx->txDetails.network]))); push_to_formatter_stack(&format_time_bounds); } @@ -170,7 +170,9 @@ void format_account_merge(tx_context_t *txCtx) { void format_manage_data_value(tx_context_t *txCtx) { strcpy(detailCaption, "Data Value"); char tmp[89]; - base64_encode(txCtx->opDetails.op.manageData.dataValue, txCtx->opDetails.op.manageData.dataValueSize, tmp); + base64_encode(txCtx->opDetails.op.manageData.dataValue, + txCtx->opDetails.op.manageData.dataValueSize, + tmp); print_summary(tmp, detailValue, 12, 12); push_to_formatter_stack(&format_operation_source); } @@ -184,7 +186,9 @@ void format_manage_data(tx_context_t *txCtx) { push_to_formatter_stack(&format_operation_source); } char tmp[65]; - memcpy(tmp, txCtx->opDetails.op.manageData.dataName, txCtx->opDetails.op.manageData.dataNameSize); + memcpy(tmp, + txCtx->opDetails.op.manageData.dataName, + txCtx->opDetails.op.manageData.dataNameSize); tmp[txCtx->opDetails.op.manageData.dataNameSize] = '\0'; print_summary(tmp, detailValue, 12, 12); } @@ -218,24 +222,23 @@ void format_set_option_signer_weight(tx_context_t *txCtx) { void format_set_option_signer_detail(tx_context_t *txCtx) { strcpy(detailCaption, "Signer Key"); switch (txCtx->opDetails.op.setOptions.signer.type) { - case SIGNER_KEY_TYPE_ED25519: { - print_public_key(txCtx->opDetails.op.setOptions.signer.data, detailValue, 0, 0); - break; - } - case SIGNER_KEY_TYPE_HASH_X: { - char tmp[57]; - encode_hash_x_key(txCtx->opDetails.op.setOptions.signer.data, tmp); - print_summary(tmp, detailValue, 12, 12); - break; - } - - case SIGNER_KEY_TYPE_PRE_AUTH_TX: { - char tmp[57]; - encode_pre_auth_key(txCtx->opDetails.op.setOptions.signer.data, tmp); - print_summary(tmp, detailValue, 12, 12); - break; + case SIGNER_KEY_TYPE_ED25519: { + print_public_key(txCtx->opDetails.op.setOptions.signer.data, detailValue, 0, 0); + break; + } + case SIGNER_KEY_TYPE_HASH_X: { + char tmp[57]; + encode_hash_x_key(txCtx->opDetails.op.setOptions.signer.data, tmp); + print_summary(tmp, detailValue, 12, 12); + break; + } - } + case SIGNER_KEY_TYPE_PRE_AUTH_TX: { + char tmp[57]; + encode_pre_auth_key(txCtx->opDetails.op.setOptions.signer.data, tmp); + print_summary(tmp, detailValue, 12, 12); + break; + } } push_to_formatter_stack(&format_set_option_signer_weight); } @@ -248,18 +251,18 @@ void format_set_option_signer(tx_context_t *txCtx) { strcpy(detailCaption, "Remove Signer"); } switch (txCtx->opDetails.op.setOptions.signer.type) { - case SIGNER_KEY_TYPE_ED25519: { - strcpy(detailValue, "Type Public Key"); - break; - } - case SIGNER_KEY_TYPE_HASH_X: { - strcpy(detailValue, "Type Hash(x)"); - break; - } - case SIGNER_KEY_TYPE_PRE_AUTH_TX: { - strcpy(detailValue, "Type Pre-Auth"); - break; - } + case SIGNER_KEY_TYPE_ED25519: { + strcpy(detailValue, "Type Public Key"); + break; + } + case SIGNER_KEY_TYPE_HASH_X: { + strcpy(detailValue, "Type Hash(x)"); + break; + } + case SIGNER_KEY_TYPE_PRE_AUTH_TX: { + strcpy(detailValue, "Type Pre-Auth"); + break; + } } push_to_formatter_stack(&format_set_option_signer_detail); } else { @@ -270,7 +273,9 @@ void format_set_option_signer(tx_context_t *txCtx) { void format_set_option_home_domain(tx_context_t *txCtx) { if (txCtx->opDetails.op.setOptions.homeDomainSize) { strcpy(detailCaption, "Home Domain"); - memcpy(detailValue, txCtx->opDetails.op.setOptions.homeDomain, txCtx->opDetails.op.setOptions.homeDomainSize); + memcpy(detailValue, + txCtx->opDetails.op.setOptions.homeDomain, + txCtx->opDetails.op.setOptions.homeDomainSize); detailValue[txCtx->opDetails.op.setOptions.homeDomainSize] = '\0'; push_to_formatter_stack(&format_set_option_signer); } else { @@ -376,18 +381,22 @@ void format_change_trust(tx_context_t *txCtx) { void format_manage_offer_sell(tx_context_t *txCtx) { if (txCtx->opDetails.op.manageOffer.buy) { strcpy(detailCaption, "Buy"); - print_amount(txCtx->opDetails.op.manageOffer.amount, txCtx->opDetails.op.manageOffer.buying.code, detailValue); + print_amount(txCtx->opDetails.op.manageOffer.amount, + txCtx->opDetails.op.manageOffer.buying.code, + detailValue); } else { strcpy(detailCaption, "Sell"); - print_amount(txCtx->opDetails.op.manageOffer.amount, txCtx->opDetails.op.manageOffer.selling.code, detailValue); + print_amount(txCtx->opDetails.op.manageOffer.amount, + txCtx->opDetails.op.manageOffer.selling.code, + detailValue); } push_to_formatter_stack(&format_operation_source); } void format_manage_offer_price(tx_context_t *txCtx) { strcpy(detailCaption, "Price"); - uint64_t price = ((uint64_t)txCtx->opDetails.op.manageOffer.price.numerator * 10000000) / - txCtx->opDetails.op.manageOffer.price.denominator; + uint64_t price = ((uint64_t) txCtx->opDetails.op.manageOffer.price.numerator * 10000000) / + txCtx->opDetails.op.manageOffer.price.denominator; if (txCtx->opDetails.op.manageOffer.buy) { print_amount(price, txCtx->opDetails.op.manageOffer.selling.code, detailValue); } else { @@ -444,10 +453,10 @@ void format_path_via(tx_context_t *txCtx) { asset_t asset = txCtx->opDetails.op.pathPayment.path[i]; uint8_t len = strlen(detailValue); if (len) { - strcpy(detailValue+len, ", "); + strcpy(detailValue + len, ", "); len += 2; } - strcpy(detailValue+len, asset.code); + strcpy(detailValue + len, asset.code); } push_to_formatter_stack(&format_operation_source); } else { @@ -457,7 +466,9 @@ void format_path_via(tx_context_t *txCtx) { void format_path_receive(tx_context_t *txCtx) { strcpy(detailCaption, "Receive"); - print_amount(txCtx->opDetails.op.pathPayment.destAmount, txCtx->opDetails.op.pathPayment.destAsset.code, detailValue); + print_amount(txCtx->opDetails.op.pathPayment.destAmount, + txCtx->opDetails.op.pathPayment.destAsset.code, + detailValue); push_to_formatter_stack(&format_path_via); } @@ -469,7 +480,9 @@ void format_path_destination(tx_context_t *txCtx) { void format_path_payment(tx_context_t *txCtx) { strcpy(detailCaption, "Send Max"); - print_amount(txCtx->opDetails.op.pathPayment.sendMax, txCtx->opDetails.op.pathPayment.sourceAsset.code, detailValue); + print_amount(txCtx->opDetails.op.pathPayment.sendMax, + txCtx->opDetails.op.pathPayment.sourceAsset.code, + detailValue); push_to_formatter_stack(&format_path_destination); } @@ -481,7 +494,9 @@ void format_payment_destination(tx_context_t *txCtx) { void format_payment(tx_context_t *txCtx) { strcpy(detailCaption, "Send"); - print_amount(txCtx->opDetails.op.payment.amount, txCtx->opDetails.op.payment.asset.code, detailValue); + print_amount(txCtx->opDetails.op.payment.amount, + txCtx->opDetails.op.payment.asset.code, + detailValue); push_to_formatter_stack(&format_payment_destination); } @@ -499,31 +514,29 @@ void format_create_account(tx_context_t *txCtx) { push_to_formatter_stack(&format_create_account_amount); } -const format_function_t formatters[13] = { - &format_create_account, - &format_payment, - &format_path_payment, - &format_manage_offer, - &format_manage_offer, - &format_set_options, - &format_change_trust, - &format_allow_trust, - &format_account_merge, - &format_inflation, - &format_manage_data, - &format_bump_sequence, - &format_manage_offer -}; +const format_function_t formatters[13] = {&format_create_account, + &format_payment, + &format_path_payment, + &format_manage_offer, + &format_manage_offer, + &format_set_options, + &format_change_trust, + &format_allow_trust, + &format_account_merge, + &format_inflation, + &format_manage_data, + &format_bump_sequence, + &format_manage_offer}; void format_confirm_operation(tx_context_t *txCtx) { if (txCtx->opCount > 1) { strcpy(opCaption, "Operation "); - print_uint(txCtx->opIdx, opCaption+strlen(opCaption)); - strcpy(opCaption+strlen(opCaption), " of "); - print_uint(txCtx->opCount, opCaption+strlen(opCaption)); - push_to_formatter_stack(((format_function_t)PIC(formatters[txCtx->opDetails.type]))); + print_uint(txCtx->opIdx, opCaption + strlen(opCaption)); + strcpy(opCaption + strlen(opCaption), " of "); + print_uint(txCtx->opCount, opCaption + strlen(opCaption)); + push_to_formatter_stack(((format_function_t) PIC(formatters[txCtx->opDetails.type]))); } else { - ((format_function_t)PIC(formatters[txCtx->opDetails.type]))(txCtx); + ((format_function_t) PIC(formatters[txCtx->opDetails.type]))(txCtx); } } diff --git a/src/stellar_format_nanox.c b/src/stellar_format_nanox.c index cd9c2dcd..ab58c0b6 100644 --- a/src/stellar_format_nanox.c +++ b/src/stellar_format_nanox.c @@ -33,11 +33,11 @@ char detailValue[89]; format_function_t formatter_stack[MAX_FORMATTERS_PER_OPERATION]; int8_t formatter_index; -void push_to_formatter_stack(format_function_t formatter){ - if(formatter_index + 1 >= MAX_FORMATTERS_PER_OPERATION){ +void push_to_formatter_stack(format_function_t formatter) { + if (formatter_index + 1 >= MAX_FORMATTERS_PER_OPERATION) { THROW(0x6124); } - formatter_stack[formatter_index+1] = formatter; + formatter_stack[formatter_index + 1] = formatter; } void format_sequence_number(tx_context_t *txCtx) { @@ -76,7 +76,7 @@ void format_time_bounds(tx_context_t *txCtx) { void format_network(tx_context_t *txCtx) { strcpy(detailCaption, "Network"); - strcpy(detailValue, ((char *)PIC(NETWORK_NAMES[txCtx->txDetails.network]))); + strcpy(detailValue, ((char *) PIC(NETWORK_NAMES[txCtx->txDetails.network]))); push_to_formatter_stack(&format_time_bounds); } @@ -169,7 +169,9 @@ void format_account_merge(tx_context_t *txCtx) { void format_manage_data_value(tx_context_t *txCtx) { strcpy(detailCaption, "Data Value"); char tmp[89]; - base64_encode(txCtx->opDetails.op.manageData.dataValue, txCtx->opDetails.op.manageData.dataValueSize, tmp); + base64_encode(txCtx->opDetails.op.manageData.dataValue, + txCtx->opDetails.op.manageData.dataValueSize, + tmp); print_summary(tmp, detailValue, 12, 12); push_to_formatter_stack(&format_operation_source); } @@ -183,7 +185,9 @@ void format_manage_data(tx_context_t *txCtx) { push_to_formatter_stack(&format_operation_source); } char tmp[65]; - memcpy(tmp, txCtx->opDetails.op.manageData.dataName, txCtx->opDetails.op.manageData.dataNameSize); + memcpy(tmp, + txCtx->opDetails.op.manageData.dataName, + txCtx->opDetails.op.manageData.dataNameSize); tmp[txCtx->opDetails.op.manageData.dataNameSize] = '\0'; print_summary(tmp, detailValue, 12, 12); } @@ -217,24 +221,23 @@ void format_set_option_signer_weight(tx_context_t *txCtx) { void format_set_option_signer_detail(tx_context_t *txCtx) { strcpy(detailCaption, "Signer Key"); switch (txCtx->opDetails.op.setOptions.signer.type) { - case SIGNER_KEY_TYPE_ED25519: { - print_public_key(txCtx->opDetails.op.setOptions.signer.data, detailValue, 0, 0); - break; - } - case SIGNER_KEY_TYPE_HASH_X: { - char tmp[57]; - encode_hash_x_key(txCtx->opDetails.op.setOptions.signer.data, tmp); - print_summary(tmp, detailValue, 12, 12); - break; - } - - case SIGNER_KEY_TYPE_PRE_AUTH_TX: { - char tmp[57]; - encode_pre_auth_key(txCtx->opDetails.op.setOptions.signer.data, tmp); - print_summary(tmp, detailValue, 12, 12); - break; + case SIGNER_KEY_TYPE_ED25519: { + print_public_key(txCtx->opDetails.op.setOptions.signer.data, detailValue, 0, 0); + break; + } + case SIGNER_KEY_TYPE_HASH_X: { + char tmp[57]; + encode_hash_x_key(txCtx->opDetails.op.setOptions.signer.data, tmp); + print_summary(tmp, detailValue, 12, 12); + break; + } - } + case SIGNER_KEY_TYPE_PRE_AUTH_TX: { + char tmp[57]; + encode_pre_auth_key(txCtx->opDetails.op.setOptions.signer.data, tmp); + print_summary(tmp, detailValue, 12, 12); + break; + } } push_to_formatter_stack(&format_set_option_signer_weight); } @@ -247,18 +250,18 @@ void format_set_option_signer(tx_context_t *txCtx) { strcpy(detailCaption, "Remove Signer"); } switch (txCtx->opDetails.op.setOptions.signer.type) { - case SIGNER_KEY_TYPE_ED25519: { - strcpy(detailValue, "Type Public Key"); - break; - } - case SIGNER_KEY_TYPE_HASH_X: { - strcpy(detailValue, "Type Hash(x)"); - break; - } - case SIGNER_KEY_TYPE_PRE_AUTH_TX: { - strcpy(detailValue, "Type Pre-Auth"); - break; - } + case SIGNER_KEY_TYPE_ED25519: { + strcpy(detailValue, "Type Public Key"); + break; + } + case SIGNER_KEY_TYPE_HASH_X: { + strcpy(detailValue, "Type Hash(x)"); + break; + } + case SIGNER_KEY_TYPE_PRE_AUTH_TX: { + strcpy(detailValue, "Type Pre-Auth"); + break; + } } push_to_formatter_stack(&format_set_option_signer_detail); } else { @@ -269,7 +272,9 @@ void format_set_option_signer(tx_context_t *txCtx) { void format_set_option_home_domain(tx_context_t *txCtx) { if (txCtx->opDetails.op.setOptions.homeDomainSize) { strcpy(detailCaption, "Home Domain"); - memcpy(detailValue, txCtx->opDetails.op.setOptions.homeDomain, txCtx->opDetails.op.setOptions.homeDomainSize); + memcpy(detailValue, + txCtx->opDetails.op.setOptions.homeDomain, + txCtx->opDetails.op.setOptions.homeDomainSize); detailValue[txCtx->opDetails.op.setOptions.homeDomainSize] = '\0'; push_to_formatter_stack(&format_set_option_signer); } else { @@ -374,14 +379,16 @@ void format_change_trust(tx_context_t *txCtx) { void format_manage_offer_sell(tx_context_t *txCtx) { strcpy(detailCaption, "Sell"); - print_amount(txCtx->opDetails.op.manageOffer.amount, txCtx->opDetails.op.manageOffer.selling.code, detailValue); + print_amount(txCtx->opDetails.op.manageOffer.amount, + txCtx->opDetails.op.manageOffer.selling.code, + detailValue); push_to_formatter_stack(&format_operation_source); } void format_manage_offer_price(tx_context_t *txCtx) { strcpy(detailCaption, "Price"); - uint64_t price = ((uint64_t)txCtx->opDetails.op.manageOffer.price.numerator * 10000000) / - txCtx->opDetails.op.manageOffer.price.denominator; + uint64_t price = ((uint64_t) txCtx->opDetails.op.manageOffer.price.numerator * 10000000) / + txCtx->opDetails.op.manageOffer.price.denominator; print_amount(price, txCtx->opDetails.op.manageOffer.buying.code, detailValue); push_to_formatter_stack(&format_manage_offer_sell); } @@ -425,10 +432,10 @@ void format_path_via(tx_context_t *txCtx) { asset_t asset = txCtx->opDetails.op.pathPayment.path[i]; uint8_t len = strlen(detailValue); if (len) { - strcpy(detailValue+len, ", "); + strcpy(detailValue + len, ", "); len += 2; } - strcpy(detailValue+len, asset.code); + strcpy(detailValue + len, asset.code); } push_to_formatter_stack(&format_operation_source); } else { @@ -438,7 +445,9 @@ void format_path_via(tx_context_t *txCtx) { void format_path_receive(tx_context_t *txCtx) { strcpy(detailCaption, "Receive"); - print_amount(txCtx->opDetails.op.pathPayment.destAmount, txCtx->opDetails.op.pathPayment.destAsset.code, detailValue); + print_amount(txCtx->opDetails.op.pathPayment.destAmount, + txCtx->opDetails.op.pathPayment.destAsset.code, + detailValue); push_to_formatter_stack(&format_path_via); } @@ -450,7 +459,9 @@ void format_path_destination(tx_context_t *txCtx) { void format_path_payment(tx_context_t *txCtx) { strcpy(detailCaption, "Send Max"); - print_amount(txCtx->opDetails.op.pathPayment.sendMax, txCtx->opDetails.op.pathPayment.sourceAsset.code, detailValue); + print_amount(txCtx->opDetails.op.pathPayment.sendMax, + txCtx->opDetails.op.pathPayment.sourceAsset.code, + detailValue); push_to_formatter_stack(&format_path_destination); } @@ -462,7 +473,9 @@ void format_payment_destination(tx_context_t *txCtx) { void format_payment(tx_context_t *txCtx) { strcpy(detailCaption, "Send"); - print_amount(txCtx->opDetails.op.payment.amount, txCtx->opDetails.op.payment.asset.code, detailValue); + print_amount(txCtx->opDetails.op.payment.amount, + txCtx->opDetails.op.payment.asset.code, + detailValue); push_to_formatter_stack(&format_payment_destination); } @@ -480,30 +493,28 @@ void format_create_account(tx_context_t *txCtx) { push_to_formatter_stack(&format_create_account_amount); } -const format_function_t formatters[12] = { - &format_create_account, - &format_payment, - &format_path_payment, - &format_manage_offer, - &format_manage_offer, - &format_set_options, - &format_change_trust, - &format_allow_trust, - &format_account_merge, - &format_inflation, - &format_manage_data, - &format_bump_sequence -}; +const format_function_t formatters[12] = {&format_create_account, + &format_payment, + &format_path_payment, + &format_manage_offer, + &format_manage_offer, + &format_set_options, + &format_change_trust, + &format_allow_trust, + &format_account_merge, + &format_inflation, + &format_manage_data, + &format_bump_sequence}; void format_confirm_operation(tx_context_t *txCtx) { if (txCtx->opCount > 1) { strcpy(opCaption, "Operation "); - print_uint(txCtx->opIdx, opCaption+strlen(opCaption)); - strcpy(opCaption+strlen(opCaption), " of "); - print_uint(txCtx->opCount, opCaption+strlen(opCaption)); - push_to_formatter_stack(((format_function_t)PIC(formatters[txCtx->opDetails.type]))); + print_uint(txCtx->opIdx, opCaption + strlen(opCaption)); + strcpy(opCaption + strlen(opCaption), " of "); + print_uint(txCtx->opCount, opCaption + strlen(opCaption)); + push_to_formatter_stack(((format_function_t) PIC(formatters[txCtx->opDetails.type]))); } else { - ((format_function_t)PIC(formatters[txCtx->opDetails.type]))(txCtx); + ((format_function_t) PIC(formatters[txCtx->opDetails.type]))(txCtx); } } diff --git a/src/stellar_parser.c b/src/stellar_parser.c index d2eed6f6..5a0fd9fe 100644 --- a/src/stellar_parser.c +++ b/src/stellar_parser.c @@ -26,649 +26,655 @@ #endif typedef struct { - const uint8_t *ptr; - size_t size; - off_t offset; + const uint8_t *ptr; + size_t size; + off_t offset; } buffer_t; /* SHA256("Public Global Stellar Network ; September 2015") */ static const uint8_t NETWORK_ID_PUBLIC_HASH[64] = { - 0x7a, 0xc3, 0x39, 0x97, 0x54, 0x4e, 0x31, 0x75, 0xd2, 0x66, 0xbd, - 0x02, 0x24, 0x39, 0xb2, 0x2c, 0xdb, 0x16, 0x50, 0x8c, 0x01, 0x16, - 0x3f, 0x26, 0xe5, 0xcb, 0x2a, 0x3e, 0x10, 0x45, 0xa9, 0x79}; + 0x7a, 0xc3, 0x39, 0x97, 0x54, 0x4e, 0x31, 0x75, 0xd2, 0x66, 0xbd, 0x02, 0x24, 0x39, 0xb2, 0x2c, + 0xdb, 0x16, 0x50, 0x8c, 0x01, 0x16, 0x3f, 0x26, 0xe5, 0xcb, 0x2a, 0x3e, 0x10, 0x45, 0xa9, 0x79}; /* SHA256("Test SDF Network ; September 2015") */ static const uint8_t NETWORK_ID_TEST_HASH[64] = { - 0xce, 0xe0, 0x30, 0x2d, 0x59, 0x84, 0x4d, 0x32, 0xbd, 0xca, 0x91, - 0x5c, 0x82, 0x03, 0xdd, 0x44, 0xb3, 0x3f, 0xbb, 0x7e, 0xdc, 0x19, - 0x05, 0x1e, 0xa3, 0x7a, 0xbe, 0xdf, 0x28, 0xec, 0xd4, 0x72}; + 0xce, 0xe0, 0x30, 0x2d, 0x59, 0x84, 0x4d, 0x32, 0xbd, 0xca, 0x91, 0x5c, 0x82, 0x03, 0xdd, 0x44, + 0xb3, 0x3f, 0xbb, 0x7e, 0xdc, 0x19, 0x05, 0x1e, 0xa3, 0x7a, 0xbe, 0xdf, 0x28, 0xec, 0xd4, 0x72}; uint8_t network_id; static bool buffer_can_read(const buffer_t *buffer, size_t num_bytes) { - return buffer->size - buffer->offset >= num_bytes; + return buffer->size - buffer->offset >= num_bytes; } static void buffer_advance(buffer_t *buffer, size_t num_bytes) { - buffer->offset += num_bytes; + buffer->offset += num_bytes; } static bool buffer_read32(buffer_t *buffer, uint32_t *n) { - if (!buffer_can_read(buffer, 4)) { - *n = 0; - return false; - } + if (!buffer_can_read(buffer, 4)) { + *n = 0; + return false; + } - const uint8_t *ptr = buffer->ptr + buffer->offset; - *n = ptr[3] + (ptr[2] << 8u) + (ptr[1] << 16u) + (ptr[0] << 24u); - buffer_advance(buffer, 4); - return true; + const uint8_t *ptr = buffer->ptr + buffer->offset; + *n = ptr[3] + (ptr[2] << 8u) + (ptr[1] << 16u) + (ptr[0] << 24u); + buffer_advance(buffer, 4); + return true; } static bool buffer_read64(buffer_t *buffer, uint64_t *n) { - if (buffer->size - buffer->offset < 8) { - *n = 0; - return false; - } + if (buffer->size - buffer->offset < 8) { + *n = 0; + return false; + } - const uint8_t *ptr = buffer->ptr + buffer->offset; - uint64_t i1 = ptr[3] + (ptr[2] << 8u) + (ptr[1] << 16u) + (ptr[0] << 24u); - uint32_t i2 = ptr[7] + (ptr[6] << 8u) + (ptr[5] << 16u) + (ptr[4] << 24u); - *n = i2 | (i1 << 32u); - buffer->offset += 8; - return true; + const uint8_t *ptr = buffer->ptr + buffer->offset; + uint64_t i1 = ptr[3] + (ptr[2] << 8u) + (ptr[1] << 16u) + (ptr[0] << 24u); + uint32_t i2 = ptr[7] + (ptr[6] << 8u) + (ptr[5] << 16u) + (ptr[4] << 24u); + *n = i2 | (i1 << 32u); + buffer->offset += 8; + return true; } static bool buffer_read_bool(buffer_t *buffer, bool *b) { - uint32_t val; + uint32_t val; - if (!buffer_read32(buffer, &val)) { - return false; - } - if (val != 0 && val != 1) { - return false; - } - *b = val == 1 ? true : false; - return true; + if (!buffer_read32(buffer, &val)) { + return false; + } + if (val != 0 && val != 1) { + return false; + } + *b = val == 1 ? true : false; + return true; } static bool buffer_read_bytes(buffer_t *buffer, uint8_t *out, size_t size) { - if (buffer->size - buffer->offset < size) { - return false; - } - memcpy(out, buffer->ptr + buffer->offset, size); - buffer->offset += size; - return true; + if (buffer->size - buffer->offset < size) { + return false; + } + memcpy(out, buffer->ptr + buffer->offset, size); + buffer->offset += size; + return true; } static size_t num_bytes(size_t size) { - size_t remainder = size % 4; - if (remainder == 0) { - return size; - } - return size + 4 - remainder; + size_t remainder = size % 4; + if (remainder == 0) { + return size; + } + return size + 4 - remainder; } static bool check_padding(const uint8_t *buffer, size_t offset, size_t length) { - unsigned int i; - for (i = 0; i < length - offset; i++) { - if (buffer[offset + i] != 0x00) { - return false; + unsigned int i; + for (i = 0; i < length - offset; i++) { + if (buffer[offset + i] != 0x00) { + return false; + } } - } - return true; + return true; } bool parse_account_id(buffer_t *buffer, const uint8_t **account_id) { - uint32_t accountType; + uint32_t accountType; - if (!buffer_read32(buffer, &accountType) || - accountType != PUBLIC_KEY_TYPE_ED25519) { - return false; - } - if (!buffer_can_read(buffer, 32)) { - return false; - } - *account_id = buffer->ptr + buffer->offset; - buffer_advance(buffer, 32); - return true; + if (!buffer_read32(buffer, &accountType) || accountType != PUBLIC_KEY_TYPE_ED25519) { + return false; + } + if (!buffer_can_read(buffer, 32)) { + return false; + } + *account_id = buffer->ptr + buffer->offset; + buffer_advance(buffer, 32); + return true; } static bool parse_network(buffer_t *buffer, tx_details_t *txDetails) { - if (!buffer_can_read(buffer, 32)) { - return false; - } - if (memcmp(buffer->ptr, NETWORK_ID_PUBLIC_HASH, 32) == 0) { - network_id = txDetails->network = NETWORK_TYPE_PUBLIC; - } else if (memcmp(buffer->ptr, NETWORK_ID_TEST_HASH, 32) == 0) { - network_id = txDetails->network = NETWORK_TYPE_TEST; - } else { - network_id = txDetails->network = NETWORK_TYPE_UNKNOWN; - } - buffer_advance(buffer, 32); - return true; + if (!buffer_can_read(buffer, 32)) { + return false; + } + if (memcmp(buffer->ptr, NETWORK_ID_PUBLIC_HASH, 32) == 0) { + network_id = txDetails->network = NETWORK_TYPE_PUBLIC; + } else if (memcmp(buffer->ptr, NETWORK_ID_TEST_HASH, 32) == 0) { + network_id = txDetails->network = NETWORK_TYPE_TEST; + } else { + network_id = txDetails->network = NETWORK_TYPE_UNKNOWN; + } + buffer_advance(buffer, 32); + return true; } static bool parse_time_bounds(buffer_t *buffer, time_bounds_t *bounds) { - if (!buffer_read64(buffer, &bounds->minTime)) { - return false; - } - return buffer_read64(buffer, &bounds->maxTime); + if (!buffer_read64(buffer, &bounds->minTime)) { + return false; + } + return buffer_read64(buffer, &bounds->maxTime); } /* TODO: max_length does not include terminal null character */ static bool parse_string(buffer_t *buffer, char *string, size_t max_length) { - uint32_t size; - - if (!buffer_read32(buffer, &size)) { - return false; - } - if (size > max_length || !buffer_can_read(buffer, num_bytes(size))) { - return false; - } - if (!check_padding(buffer->ptr + buffer->offset, size, - num_bytes(size))) { // security check - return false; - } - memcpy(string, buffer->ptr + buffer->offset, size); - string[size] = '\0'; - buffer_advance(buffer, num_bytes(size)); - return true; + uint32_t size; + + if (!buffer_read32(buffer, &size)) { + return false; + } + if (size > max_length || !buffer_can_read(buffer, num_bytes(size))) { + return false; + } + if (!check_padding(buffer->ptr + buffer->offset, size, + num_bytes(size))) { // security check + return false; + } + memcpy(string, buffer->ptr + buffer->offset, size); + string[size] = '\0'; + buffer_advance(buffer, num_bytes(size)); + return true; } /* TODO: max_length does not include terminal null character */ -static bool parse_string_ptr(buffer_t *buffer, const char **string, - size_t *out_len, size_t max_length) { - uint32_t size; - - if (!buffer_read32(buffer, &size)) { - return false; - } - if (size > max_length || !buffer_can_read(buffer, num_bytes(size))) { - return false; - } - if (!check_padding(buffer->ptr + buffer->offset, size, - num_bytes(size))) { // security check - return false; - } - *string = (char *)buffer->ptr + buffer->offset; - if (out_len) { - *out_len = size; - } - buffer_advance(buffer, num_bytes(size)); - return true; +static bool parse_string_ptr(buffer_t *buffer, + const char **string, + size_t *out_len, + size_t max_length) { + uint32_t size; + + if (!buffer_read32(buffer, &size)) { + return false; + } + if (size > max_length || !buffer_can_read(buffer, num_bytes(size))) { + return false; + } + if (!check_padding(buffer->ptr + buffer->offset, size, + num_bytes(size))) { // security check + return false; + } + *string = (char *) buffer->ptr + buffer->offset; + if (out_len) { + *out_len = size; + } + buffer_advance(buffer, num_bytes(size)); + return true; } static bool parse_memo(buffer_t *buffer, tx_details_t *txDetails) { - uint32_t type; - uint64_t memo_id; - - if (!buffer_read32(buffer, &type)) { - return 0; - } - txDetails->memo.type = type; - switch (txDetails->memo.type) { - case MEMO_TYPE_NONE: - strcpy(txDetails->memo.data, "[none]"); - return true; - case MEMO_TYPE_ID: - if (!buffer_read64(buffer, &memo_id)) { - return false; + uint32_t type; + uint64_t memo_id; + + if (!buffer_read32(buffer, &type)) { + return 0; } - print_uint(memo_id, txDetails->memo.data); - return true; - case MEMO_TYPE_TEXT: { - return parse_string(buffer, txDetails->memo.data, MEMO_TEXT_MAX_SIZE); - } - case MEMO_TYPE_HASH: - case MEMO_TYPE_RETURN: - if (buffer->size - buffer->offset < 32) { - return false; + txDetails->memo.type = type; + switch (txDetails->memo.type) { + case MEMO_TYPE_NONE: + strcpy(txDetails->memo.data, "[none]"); + return true; + case MEMO_TYPE_ID: + if (!buffer_read64(buffer, &memo_id)) { + return false; + } + print_uint(memo_id, txDetails->memo.data); + return true; + case MEMO_TYPE_TEXT: { + return parse_string(buffer, txDetails->memo.data, MEMO_TEXT_MAX_SIZE); + } + case MEMO_TYPE_HASH: + case MEMO_TYPE_RETURN: + if (buffer->size - buffer->offset < 32) { + return false; + } + print_binary(buffer->ptr + buffer->offset, txDetails->memo.data, 32); + buffer->offset += 32; + return true; + default: + return false; // unknown memo type } - print_binary(buffer->ptr + buffer->offset, txDetails->memo.data, 32); - buffer->offset += 32; - return true; - default: - return false; // unknown memo type - } } static bool parse_asset(buffer_t *buffer, asset_t *asset) { - uint32_t assetType; - - if (!buffer_read32(buffer, &assetType)) { - return false; - } - asset->type = assetType; - switch (asset->type) { - case ASSET_TYPE_NATIVE: { - print_native_asset_code(network_id, asset->code); - return true; - } - case ASSET_TYPE_CREDIT_ALPHANUM4: { - if (!buffer_read_bytes(buffer, (uint8_t *)asset->code, 4)) { - return false; - } - asset->code[4] = '\0'; - return parse_account_id(buffer, &asset->issuer); - } - case ASSET_TYPE_CREDIT_ALPHANUM12: { - if (!buffer_read_bytes(buffer, (uint8_t *)asset->code, 12)) { - return false; - } - asset->code[12] = '\0'; - return parse_account_id(buffer, &asset->issuer); - } - default: - return false; // unknown asset type - } -} - -static bool parse_create_account(buffer_t *buffer, - create_account_op_t *createAccount) { - if (!parse_account_id(buffer, &createAccount->accountId)) { - return false; - } - return buffer_read64(buffer, &createAccount->amount); + uint32_t assetType; + + if (!buffer_read32(buffer, &assetType)) { + return false; + } + asset->type = assetType; + switch (asset->type) { + case ASSET_TYPE_NATIVE: { + print_native_asset_code(network_id, asset->code); + return true; + } + case ASSET_TYPE_CREDIT_ALPHANUM4: { + if (!buffer_read_bytes(buffer, (uint8_t *) asset->code, 4)) { + return false; + } + asset->code[4] = '\0'; + return parse_account_id(buffer, &asset->issuer); + } + case ASSET_TYPE_CREDIT_ALPHANUM12: { + if (!buffer_read_bytes(buffer, (uint8_t *) asset->code, 12)) { + return false; + } + asset->code[12] = '\0'; + return parse_account_id(buffer, &asset->issuer); + } + default: + return false; // unknown asset type + } } -static bool parse_payment(buffer_t *buffer, payment_op_t *payment) { - if (!parse_account_id(buffer, &payment->destination)) { - return false; - } - - if (!parse_asset(buffer, &payment->asset)) { - return false; - } - - return buffer_read64(buffer, &payment->amount); -} - -static bool parse_path_payment(buffer_t *buffer, - path_payment_op_t *pathPayment) { - uint32_t pathLen; - - if (!parse_asset(buffer, &pathPayment->sourceAsset)) { - return false; - } - if (!buffer_read64(buffer, &pathPayment->sendMax)) { - return false; - } - if (!parse_account_id(buffer, &pathPayment->destination)) { - return false; - } - - if (!parse_asset(buffer, &pathPayment->destAsset)) { - return false; - } - - if (!buffer_read64(buffer, &pathPayment->destAmount)) { - return false; - } - - if (!buffer_read32(buffer, &pathLen)) { - return false; - } - pathPayment->pathLen = pathLen; - if (pathPayment->pathLen > 5) { - return false; - } - for (int i = 0; i < pathPayment->pathLen; i++) { - if (!parse_asset(buffer, &pathPayment->path[i])) { - return false; - } - } - return true; +static bool parse_create_account(buffer_t *buffer, create_account_op_t *createAccount) { + if (!parse_account_id(buffer, &createAccount->accountId)) { + return false; + } + return buffer_read64(buffer, &createAccount->amount); } -static bool parse_allow_trust(buffer_t *buffer, allow_trust_op_t *allowTrust) { - uint32_t assetType; +static bool parse_payment(buffer_t *buffer, payment_op_t *payment) { + if (!parse_account_id(buffer, &payment->destination)) { + return false; + } - if (!parse_account_id(buffer, &allowTrust->trustee)) { - return false; - } + if (!parse_asset(buffer, &payment->asset)) { + return false; + } - if (!buffer_read32(buffer, &assetType)) { - return false; - } + return buffer_read64(buffer, &payment->amount); +} - switch (assetType) { - case ASSET_TYPE_CREDIT_ALPHANUM4: { - if (!buffer_read_bytes(buffer, (uint8_t *)allowTrust->assetCode, 4)) { - return false; +static bool parse_path_payment(buffer_t *buffer, path_payment_op_t *pathPayment) { + uint32_t pathLen; + + if (!parse_asset(buffer, &pathPayment->sourceAsset)) { + return false; + } + if (!buffer_read64(buffer, &pathPayment->sendMax)) { + return false; } - allowTrust->assetCode[4] = '\0'; - break; - } - case ASSET_TYPE_CREDIT_ALPHANUM12: { - if (!buffer_read_bytes(buffer, (uint8_t *)allowTrust->assetCode, 12)) { - return false; + if (!parse_account_id(buffer, &pathPayment->destination)) { + return false; } - allowTrust->assetCode[12] = '\0'; - break; - } - default: - return false; // unknown asset type - } - return buffer_read_bool(buffer, &allowTrust->authorize); -} + if (!parse_asset(buffer, &pathPayment->destAsset)) { + return false; + } -static bool parse_account_merge(buffer_t *buffer, - account_merge_op_t *accountMerge) { - return parse_account_id(buffer, &accountMerge->destination); + if (!buffer_read64(buffer, &pathPayment->destAmount)) { + return false; + } + + if (!buffer_read32(buffer, &pathLen)) { + return false; + } + pathPayment->pathLen = pathLen; + if (pathPayment->pathLen > 5) { + return false; + } + for (int i = 0; i < pathPayment->pathLen; i++) { + if (!parse_asset(buffer, &pathPayment->path[i])) { + return false; + } + } + return true; } -static bool parse_manage_data(buffer_t *buffer, manage_data_op_t *manageData) { - size_t size; - - if (!parse_string_ptr(buffer, (const char **)&manageData->dataName, &size, - DATA_NAME_MAX_SIZE)) { - return false; - } - manageData->dataNameSize = size; - - // DataValue* dataValue; - bool hasValue; - if (!buffer_read_bool(buffer, &hasValue)) { - return false; - } - if (hasValue) { - if (!parse_string_ptr(buffer, (const char **)&manageData->dataValue, &size, - DATA_VALUE_MAX_SIZE)) { - return false; - } - manageData->dataValueSize = size; - } else { - manageData->dataValueSize = 0; - } - return true; +static bool parse_allow_trust(buffer_t *buffer, allow_trust_op_t *allowTrust) { + uint32_t assetType; + + if (!parse_account_id(buffer, &allowTrust->trustee)) { + return false; + } + + if (!buffer_read32(buffer, &assetType)) { + return false; + } + + switch (assetType) { + case ASSET_TYPE_CREDIT_ALPHANUM4: { + if (!buffer_read_bytes(buffer, (uint8_t *) allowTrust->assetCode, 4)) { + return false; + } + allowTrust->assetCode[4] = '\0'; + break; + } + case ASSET_TYPE_CREDIT_ALPHANUM12: { + if (!buffer_read_bytes(buffer, (uint8_t *) allowTrust->assetCode, 12)) { + return false; + } + allowTrust->assetCode[12] = '\0'; + break; + } + default: + return false; // unknown asset type + } + + return buffer_read_bool(buffer, &allowTrust->authorize); } -static bool parse_offer(buffer_t *buffer, manage_offer_op_t *manageOffer) { - if (!parse_asset(buffer, &manageOffer->selling)) { - return false; - } - if (!parse_asset(buffer, &manageOffer->buying)) { - return false; - } - if (!buffer_read64(buffer, &manageOffer->amount)) { - return false; - } - if (!buffer_read32(buffer, &manageOffer->price.numerator)) { - return false; - } - if (!buffer_read32(buffer, &manageOffer->price.denominator)) { - return false; - } - // Denominator cannot be null, as it would lead to a division by zero. - return manageOffer->price.denominator != 0; -} - -static bool parse_active_offer(buffer_t *buffer, - manage_offer_op_t *manageOffer) { - manageOffer->active = true; - if (!parse_offer(buffer, manageOffer)) { - return false; - } - return buffer_read64(buffer, &manageOffer->offerId); -} - -static bool parse_active_sell_offer(buffer_t *buffer, - manage_offer_op_t *manageOffer) { - manageOffer->buy = false; - return parse_active_offer(buffer, manageOffer); -} - -static bool parse_active_buy_offer(buffer_t *buffer, - manage_offer_op_t *manageOffer) { - manageOffer->buy = true; - return parse_active_offer(buffer, manageOffer); -} - -static bool parse_passive_offer(buffer_t *buffer, - manage_offer_op_t *manageOffer) { - manageOffer->active = false; - manageOffer->offerId = 0; - return parse_offer(buffer, manageOffer); -} - -static bool parse_change_trust(buffer_t *buffer, - change_trust_op_t *changeTrust) { - if (!parse_asset(buffer, &changeTrust->asset)) { - return false; - } - return buffer_read64(buffer, &changeTrust->limit); +static bool parse_account_merge(buffer_t *buffer, account_merge_op_t *accountMerge) { + return parse_account_id(buffer, &accountMerge->destination); } -typedef bool (*xdr_type_parser)(buffer_t *, void *); +static bool parse_manage_data(buffer_t *buffer, manage_data_op_t *manageData) { + size_t size; -static bool parse_optional_type(buffer_t *buffer, xdr_type_parser parser, - void *dst, bool *opted) { - bool isPresent; + if (!parse_string_ptr(buffer, + (const char **) &manageData->dataName, + &size, + DATA_NAME_MAX_SIZE)) { + return false; + } + manageData->dataNameSize = size; - if (!buffer_read_bool(buffer, &isPresent)) { - return false; - } - if (isPresent) { - if (opted) { - *opted = true; + // DataValue* dataValue; + bool hasValue; + if (!buffer_read_bool(buffer, &hasValue)) { + return false; } - return parser(buffer, dst); - } else { - if (opted) { - *opted = false; + if (hasValue) { + if (!parse_string_ptr(buffer, + (const char **) &manageData->dataValue, + &size, + DATA_VALUE_MAX_SIZE)) { + return false; + } + manageData->dataValueSize = size; + } else { + manageData->dataValueSize = 0; } return true; - } } -static bool parse_signer(buffer_t *buffer, signer_t *signer) { - uint32_t signerType; - - if (!buffer_read32(buffer, &signerType)) { - return false; - } - signer->type = signerType; - - if (buffer->size - buffer->offset < 32) { - return false; - } - signer->data = buffer->ptr + buffer->offset; - buffer_advance(buffer, 32); +static bool parse_offer(buffer_t *buffer, manage_offer_op_t *manageOffer) { + if (!parse_asset(buffer, &manageOffer->selling)) { + return false; + } + if (!parse_asset(buffer, &manageOffer->buying)) { + return false; + } + if (!buffer_read64(buffer, &manageOffer->amount)) { + return false; + } + if (!buffer_read32(buffer, &manageOffer->price.numerator)) { + return false; + } + if (!buffer_read32(buffer, &manageOffer->price.denominator)) { + return false; + } + // Denominator cannot be null, as it would lead to a division by zero. + return manageOffer->price.denominator != 0; +} - return buffer_read32(buffer, &signer->weight); +static bool parse_active_offer(buffer_t *buffer, manage_offer_op_t *manageOffer) { + manageOffer->active = true; + if (!parse_offer(buffer, manageOffer)) { + return false; + } + return buffer_read64(buffer, &manageOffer->offerId); } -static bool parse_set_options(buffer_t *buffer, set_options_op_t *setOptions) { - uint32_t tmp; - - if (!parse_optional_type(buffer, (xdr_type_parser)parse_account_id, - &setOptions->inflationDestination, - &setOptions->inflationDestinationPresent)) { - return false; - } - - if (!parse_optional_type(buffer, (xdr_type_parser)buffer_read32, - &setOptions->clearFlags, NULL)) { - return false; - } - if (!parse_optional_type(buffer, (xdr_type_parser)buffer_read32, - &setOptions->setFlags, NULL)) { - return false; - } - if (!parse_optional_type(buffer, (xdr_type_parser)buffer_read32, - &setOptions->masterWeight, - &setOptions->masterWeightPresent)) { - return false; - } - if (!parse_optional_type(buffer, (xdr_type_parser)buffer_read32, - &setOptions->lowThreshold, - &setOptions->lowThresholdPresent)) { - return false; - } - if (!parse_optional_type(buffer, (xdr_type_parser)buffer_read32, - &setOptions->mediumThreshold, - &setOptions->mediumThresholdPresent)) { - return false; - } - if (!parse_optional_type(buffer, (xdr_type_parser)buffer_read32, - &setOptions->highThreshold, - &setOptions->highThresholdPresent)) { - return false; - } - if (!buffer_read32(buffer, &tmp)) { - return false; - } - bool homeDomainPresent = tmp ? true : false; - if (homeDomainPresent) { - if (!buffer_read32(buffer, &setOptions->homeDomainSize) || - setOptions->homeDomainSize > HOME_DOMAIN_MAX_SIZE) { - return false; - } - if (buffer->size - buffer->offset < num_bytes(setOptions->homeDomainSize)) { - return false; - } - setOptions->homeDomain = buffer->ptr + buffer->offset; - if (!check_padding( - setOptions->homeDomain, setOptions->homeDomainSize, - num_bytes(setOptions->homeDomainSize))) { // security check - return false; - } - buffer->offset += num_bytes(setOptions->homeDomainSize); - } else { - setOptions->homeDomainSize = 0; - } - - return parse_optional_type(buffer, (xdr_type_parser)parse_signer, - &setOptions->signer, &setOptions->signerPresent); -} - -static bool parse_bump_sequence(buffer_t *buffer, - bump_sequence_op_t *bumpSequence) { - return buffer_read64(buffer, (uint64_t *)&bumpSequence->bumpTo); +static bool parse_active_sell_offer(buffer_t *buffer, manage_offer_op_t *manageOffer) { + manageOffer->buy = false; + return parse_active_offer(buffer, manageOffer); } -static bool parse_op_xdr(buffer_t *buffer, operation_details_t *opDetails) { - uint32_t opType; - - if (!parse_optional_type(buffer, (xdr_type_parser)parse_account_id, - &opDetails->source, &opDetails->sourcePresent)) { - return false; - } - - if (!buffer_read32(buffer, &opType)) { - return false; - } - opDetails->type = opType; - switch (opDetails->type) { - case XDR_OPERATION_TYPE_CREATE_ACCOUNT: { - return parse_create_account(buffer, &opDetails->op.createAccount); - } - case XDR_OPERATION_TYPE_PAYMENT: { - return parse_payment(buffer, &opDetails->op.payment); - } - case XDR_OPERATION_TYPE_PATH_PAYMENT: { - return parse_path_payment(buffer, &opDetails->op.pathPayment); - } - case XDR_OPERATION_TYPE_CREATE_PASSIVE_OFFER: { - return parse_passive_offer(buffer, &opDetails->op.manageOffer); - } - case XDR_OPERATION_TYPE_MANAGE_SELL_OFFER: { - return parse_active_sell_offer(buffer, &opDetails->op.manageOffer); - } - case XDR_OPERATION_TYPE_SET_OPTIONS: { - return parse_set_options(buffer, &opDetails->op.setOptions); - } - case XDR_OPERATION_TYPE_CHANGE_TRUST: { - return parse_change_trust(buffer, &opDetails->op.changeTrust); - } - case XDR_OPERATION_TYPE_ALLOW_TRUST: { - return parse_allow_trust(buffer, &opDetails->op.allowTrust); - } - case XDR_OPERATION_TYPE_ACCOUNT_MERGE: { - return parse_account_merge(buffer, &opDetails->op.accountMerge); - } - case XDR_OPERATION_TYPE_INFLATION: { - return true; - } - case XDR_OPERATION_TYPE_MANAGE_DATA: { - return parse_manage_data(buffer, &opDetails->op.manageData); - } - case XDR_OPERATION_TYPE_BUMP_SEQUENCE: { - return parse_bump_sequence(buffer, &opDetails->op.bumpSequence); - } - case XDR_OPERATION_TYPE_MANAGE_BUY_OFFER: { - return parse_active_buy_offer(buffer, &opDetails->op.manageOffer); - } - default: - return false; // Unknown operation - } +static bool parse_active_buy_offer(buffer_t *buffer, manage_offer_op_t *manageOffer) { + manageOffer->buy = true; + return parse_active_offer(buffer, manageOffer); } -#define ENVELOPE_TYPE_TX 2 +static bool parse_passive_offer(buffer_t *buffer, manage_offer_op_t *manageOffer) { + manageOffer->active = false; + manageOffer->offerId = 0; + return parse_offer(buffer, manageOffer); +} -bool parse_tx_xdr(const uint8_t *data, size_t size, tx_context_t *txCtx) { - buffer_t buffer = {data, size, 0}; - uint32_t envelopeType; +static bool parse_change_trust(buffer_t *buffer, change_trust_op_t *changeTrust) { + if (!parse_asset(buffer, &changeTrust->asset)) { + return false; + } + return buffer_read64(buffer, &changeTrust->limit); +} - uint16_t offset = txCtx->offset; - buffer.offset = txCtx->offset; +typedef bool (*xdr_type_parser)(buffer_t *, void *); - if (offset == 0) { - MEMCLEAR(txCtx->txDetails); +static bool parse_optional_type(buffer_t *buffer, xdr_type_parser parser, void *dst, bool *opted) { + bool isPresent; - if (!parse_network(&buffer, &txCtx->txDetails)) { - return false; + if (!buffer_read_bool(buffer, &isPresent)) { + return false; } - if (!buffer_read32(&buffer, &envelopeType) || - envelopeType != ENVELOPE_TYPE_TX) { - return false; + if (isPresent) { + if (opted) { + *opted = true; + } + return parser(buffer, dst); + } else { + if (opted) { + *opted = false; + } + return true; } +} + +static bool parse_signer(buffer_t *buffer, signer_t *signer) { + uint32_t signerType; - // account used to run the transaction - if (!parse_account_id(&buffer, &txCtx->txDetails.source)) { - return false; + if (!buffer_read32(buffer, &signerType)) { + return false; } + signer->type = signerType; - // the fee the sourceAccount will pay - uint32_t fees; - if (!buffer_read32(&buffer, &fees)) { - return false; + if (buffer->size - buffer->offset < 32) { + return false; } - txCtx->txDetails.fee = fees; + signer->data = buffer->ptr + buffer->offset; + buffer_advance(buffer, 32); + + return buffer_read32(buffer, &signer->weight); +} + +static bool parse_set_options(buffer_t *buffer, set_options_op_t *setOptions) { + uint32_t tmp; - // sequence number to consume in the account - if (!buffer_read64(&buffer, (uint64_t *)&txCtx->txDetails.sequenceNumber)) { - return false; + if (!parse_optional_type(buffer, + (xdr_type_parser) parse_account_id, + &setOptions->inflationDestination, + &setOptions->inflationDestinationPresent)) { + return false; } - // validity range (inclusive) for the last ledger close time - if (!parse_optional_type(&buffer, (xdr_type_parser)parse_time_bounds, - &txCtx->txDetails.timeBounds, - &txCtx->txDetails.hasTimeBounds)) { - return false; + if (!parse_optional_type(buffer, + (xdr_type_parser) buffer_read32, + &setOptions->clearFlags, + NULL)) { + return false; + } + if (!parse_optional_type(buffer, + (xdr_type_parser) buffer_read32, + &setOptions->setFlags, + NULL)) { + return false; + } + if (!parse_optional_type(buffer, + (xdr_type_parser) buffer_read32, + &setOptions->masterWeight, + &setOptions->masterWeightPresent)) { + return false; + } + if (!parse_optional_type(buffer, + (xdr_type_parser) buffer_read32, + &setOptions->lowThreshold, + &setOptions->lowThresholdPresent)) { + return false; + } + if (!parse_optional_type(buffer, + (xdr_type_parser) buffer_read32, + &setOptions->mediumThreshold, + &setOptions->mediumThresholdPresent)) { + return false; + } + if (!parse_optional_type(buffer, + (xdr_type_parser) buffer_read32, + &setOptions->highThreshold, + &setOptions->highThresholdPresent)) { + return false; + } + if (!buffer_read32(buffer, &tmp)) { + return false; + } + bool homeDomainPresent = tmp ? true : false; + if (homeDomainPresent) { + if (!buffer_read32(buffer, &setOptions->homeDomainSize) || + setOptions->homeDomainSize > HOME_DOMAIN_MAX_SIZE) { + return false; + } + if (buffer->size - buffer->offset < num_bytes(setOptions->homeDomainSize)) { + return false; + } + setOptions->homeDomain = buffer->ptr + buffer->offset; + if (!check_padding(setOptions->homeDomain, + setOptions->homeDomainSize, + num_bytes(setOptions->homeDomainSize))) { // security check + return false; + } + buffer->offset += num_bytes(setOptions->homeDomainSize); + } else { + setOptions->homeDomainSize = 0; } - if (!parse_memo(&buffer, &txCtx->txDetails)) { - return false; + return parse_optional_type(buffer, + (xdr_type_parser) parse_signer, + &setOptions->signer, + &setOptions->signerPresent); +} + +static bool parse_bump_sequence(buffer_t *buffer, bump_sequence_op_t *bumpSequence) { + return buffer_read64(buffer, (uint64_t *) &bumpSequence->bumpTo); +} + +static bool parse_op_xdr(buffer_t *buffer, operation_details_t *opDetails) { + uint32_t opType; + + if (!parse_optional_type(buffer, + (xdr_type_parser) parse_account_id, + &opDetails->source, + &opDetails->sourcePresent)) { + return false; } - uint32_t opCount; - if (!buffer_read32(&buffer, &opCount)) { - return false; + if (!buffer_read32(buffer, &opType)) { + return false; + } + opDetails->type = opType; + switch (opDetails->type) { + case XDR_OPERATION_TYPE_CREATE_ACCOUNT: { + return parse_create_account(buffer, &opDetails->op.createAccount); + } + case XDR_OPERATION_TYPE_PAYMENT: { + return parse_payment(buffer, &opDetails->op.payment); + } + case XDR_OPERATION_TYPE_PATH_PAYMENT: { + return parse_path_payment(buffer, &opDetails->op.pathPayment); + } + case XDR_OPERATION_TYPE_CREATE_PASSIVE_OFFER: { + return parse_passive_offer(buffer, &opDetails->op.manageOffer); + } + case XDR_OPERATION_TYPE_MANAGE_SELL_OFFER: { + return parse_active_sell_offer(buffer, &opDetails->op.manageOffer); + } + case XDR_OPERATION_TYPE_SET_OPTIONS: { + return parse_set_options(buffer, &opDetails->op.setOptions); + } + case XDR_OPERATION_TYPE_CHANGE_TRUST: { + return parse_change_trust(buffer, &opDetails->op.changeTrust); + } + case XDR_OPERATION_TYPE_ALLOW_TRUST: { + return parse_allow_trust(buffer, &opDetails->op.allowTrust); + } + case XDR_OPERATION_TYPE_ACCOUNT_MERGE: { + return parse_account_merge(buffer, &opDetails->op.accountMerge); + } + case XDR_OPERATION_TYPE_INFLATION: { + return true; + } + case XDR_OPERATION_TYPE_MANAGE_DATA: { + return parse_manage_data(buffer, &opDetails->op.manageData); + } + case XDR_OPERATION_TYPE_BUMP_SEQUENCE: { + return parse_bump_sequence(buffer, &opDetails->op.bumpSequence); + } + case XDR_OPERATION_TYPE_MANAGE_BUY_OFFER: { + return parse_active_buy_offer(buffer, &opDetails->op.manageOffer); + } + default: + return false; // Unknown operation } - txCtx->opCount = opCount; - if (txCtx->opCount > MAX_OPS) { - return false; +} + +#define ENVELOPE_TYPE_TX 2 + +bool parse_tx_xdr(const uint8_t *data, size_t size, tx_context_t *txCtx) { + buffer_t buffer = {data, size, 0}; + uint32_t envelopeType; + + uint16_t offset = txCtx->offset; + buffer.offset = txCtx->offset; + + if (offset == 0) { + MEMCLEAR(txCtx->txDetails); + + if (!parse_network(&buffer, &txCtx->txDetails)) { + return false; + } + if (!buffer_read32(&buffer, &envelopeType) || envelopeType != ENVELOPE_TYPE_TX) { + return false; + } + + // account used to run the transaction + if (!parse_account_id(&buffer, &txCtx->txDetails.source)) { + return false; + } + + // the fee the sourceAccount will pay + uint32_t fees; + if (!buffer_read32(&buffer, &fees)) { + return false; + } + txCtx->txDetails.fee = fees; + + // sequence number to consume in the account + if (!buffer_read64(&buffer, (uint64_t *) &txCtx->txDetails.sequenceNumber)) { + return false; + } + + // validity range (inclusive) for the last ledger close time + if (!parse_optional_type(&buffer, + (xdr_type_parser) parse_time_bounds, + &txCtx->txDetails.timeBounds, + &txCtx->txDetails.hasTimeBounds)) { + return false; + } + + if (!parse_memo(&buffer, &txCtx->txDetails)) { + return false; + } + + uint32_t opCount; + if (!buffer_read32(&buffer, &opCount)) { + return false; + } + txCtx->opCount = opCount; + if (txCtx->opCount > MAX_OPS) { + return false; + } + txCtx->opIdx = 0; } - txCtx->opIdx = 0; - } - if (!parse_op_xdr(&buffer, &txCtx->opDetails)) { - return false; - } - offset = buffer.offset; + if (!parse_op_xdr(&buffer, &txCtx->opDetails)) { + return false; + } + offset = buffer.offset; - txCtx->opIdx += 1; - txCtx->offset = offset; - return true; + txCtx->opIdx += 1; + txCtx->offset = offset; + return true; } diff --git a/src/stellar_ram.c b/src/stellar_ram.c index c435d2d2..e3a3f0e8 100644 --- a/src/stellar_ram.c +++ b/src/stellar_ram.c @@ -23,8 +23,6 @@ #include "os_io_seproxyhal.h" - stellar_context_t ctx; ux_state_t ux; unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B]; - diff --git a/src/stellar_types.h b/src/stellar_types.h index 3eb357d3..d6213457 100644 --- a/src/stellar_types.h +++ b/src/stellar_types.h @@ -24,28 +24,28 @@ // REQUEST PARSING CONSTANTS // // ------------------------------------------------------------------------- // -#define CLA 0xe0 -#define INS_GET_PUBLIC_KEY 0x02 -#define INS_SIGN_TX 0x04 +#define CLA 0xe0 +#define INS_GET_PUBLIC_KEY 0x02 +#define INS_SIGN_TX 0x04 #define INS_GET_APP_CONFIGURATION 0x06 -#define INS_SIGN_TX_HASH 0x08 -#define INS_KEEP_ALIVE 0x10 -#define P1_NO_SIGNATURE 0x00 -#define P1_SIGNATURE 0x01 -#define P2_NO_CONFIRM 0x00 -#define P2_CONFIRM 0x01 -#define P1_FIRST 0x00 -#define P1_MORE 0x80 -#define P2_LAST 0x00 -#define P2_MORE 0x80 +#define INS_SIGN_TX_HASH 0x08 +#define INS_KEEP_ALIVE 0x10 +#define P1_NO_SIGNATURE 0x00 +#define P1_SIGNATURE 0x01 +#define P2_NO_CONFIRM 0x00 +#define P2_CONFIRM 0x01 +#define P1_FIRST 0x00 +#define P1_MORE 0x80 +#define P2_LAST 0x00 +#define P2_MORE 0x80 #define MIN_APDU_SIZE 5 -#define OFFSET_CLA 0 -#define OFFSET_INS 1 -#define OFFSET_P1 2 -#define OFFSET_P2 3 -#define OFFSET_LC 4 +#define OFFSET_CLA 0 +#define OFFSET_INS 1 +#define OFFSET_P1 2 +#define OFFSET_P2 3 +#define OFFSET_LC 4 #define OFFSET_CDATA 5 /* Max transaction size is 1.4Kb */ @@ -58,48 +58,47 @@ /* max amount is max int64 scaled down: "922337203685.4775807" */ #define AMOUNT_MAX_SIZE 21 - // ------------------------------------------------------------------------- // // TRANSACTION PARSING CONSTANTS // // ------------------------------------------------------------------------- // -#define ASSET_TYPE_NATIVE 0 -#define ASSET_TYPE_CREDIT_ALPHANUM4 1 +#define ASSET_TYPE_NATIVE 0 +#define ASSET_TYPE_CREDIT_ALPHANUM4 1 #define ASSET_TYPE_CREDIT_ALPHANUM12 2 -#define MEMO_TYPE_NONE 0 -#define MEMO_TYPE_TEXT 1 -#define MEMO_TYPE_ID 2 -#define MEMO_TYPE_HASH 3 +#define MEMO_TYPE_NONE 0 +#define MEMO_TYPE_TEXT 1 +#define MEMO_TYPE_ID 2 +#define MEMO_TYPE_HASH 3 #define MEMO_TYPE_RETURN 4 -#define NETWORK_TYPE_PUBLIC 0 -#define NETWORK_TYPE_TEST 1 +#define NETWORK_TYPE_PUBLIC 0 +#define NETWORK_TYPE_TEST 1 #define NETWORK_TYPE_UNKNOWN 2 -#define XDR_OPERATION_TYPE_CREATE_ACCOUNT 0 -#define XDR_OPERATION_TYPE_PAYMENT 1 -#define XDR_OPERATION_TYPE_PATH_PAYMENT 2 -#define XDR_OPERATION_TYPE_MANAGE_SELL_OFFER 3 +#define XDR_OPERATION_TYPE_CREATE_ACCOUNT 0 +#define XDR_OPERATION_TYPE_PAYMENT 1 +#define XDR_OPERATION_TYPE_PATH_PAYMENT 2 +#define XDR_OPERATION_TYPE_MANAGE_SELL_OFFER 3 #define XDR_OPERATION_TYPE_CREATE_PASSIVE_OFFER 4 -#define XDR_OPERATION_TYPE_SET_OPTIONS 5 -#define XDR_OPERATION_TYPE_CHANGE_TRUST 6 -#define XDR_OPERATION_TYPE_ALLOW_TRUST 7 -#define XDR_OPERATION_TYPE_ACCOUNT_MERGE 8 -#define XDR_OPERATION_TYPE_INFLATION 9 -#define XDR_OPERATION_TYPE_MANAGE_DATA 10 -#define XDR_OPERATION_TYPE_BUMP_SEQUENCE 11 -#define XDR_OPERATION_TYPE_MANAGE_BUY_OFFER 12 - -#define SIGNER_KEY_TYPE_ED25519 0 +#define XDR_OPERATION_TYPE_SET_OPTIONS 5 +#define XDR_OPERATION_TYPE_CHANGE_TRUST 6 +#define XDR_OPERATION_TYPE_ALLOW_TRUST 7 +#define XDR_OPERATION_TYPE_ACCOUNT_MERGE 8 +#define XDR_OPERATION_TYPE_INFLATION 9 +#define XDR_OPERATION_TYPE_MANAGE_DATA 10 +#define XDR_OPERATION_TYPE_BUMP_SEQUENCE 11 +#define XDR_OPERATION_TYPE_MANAGE_BUY_OFFER 12 + +#define SIGNER_KEY_TYPE_ED25519 0 #define SIGNER_KEY_TYPE_PRE_AUTH_TX 1 -#define SIGNER_KEY_TYPE_HASH_X 2 +#define SIGNER_KEY_TYPE_HASH_X 2 #define PUBLIC_KEY_TYPE_ED25519 0 -#define MEMO_TEXT_MAX_SIZE 28 -#define DATA_NAME_MAX_SIZE 64 -#define DATA_VALUE_MAX_SIZE 64 -#define HOME_DOMAIN_MAX_SIZE 32 +#define MEMO_TEXT_MAX_SIZE 28 +#define DATA_NAME_MAX_SIZE 64 +#define DATA_VALUE_MAX_SIZE 64 +#define HOME_DOMAIN_MAX_SIZE 32 // ------------------------------------------------------------------------- // // DISPLAY CONSTANTS // @@ -116,13 +115,14 @@ #define DETAIL_CAPTION_MAX_SIZE 20 /* - * DETAIL_VALUE_MAX_SIZE value of 89 is due to the maximum length of managed data value which can be 64 bytes long. - * Managed data values are displayed as base64 encoded strings, which are 4*((len+2)/3) characters long. - * (An additional slot is required for the end-of-string character of course) + * DETAIL_VALUE_MAX_SIZE value of 89 is due to the maximum length of managed data value which can be + * 64 bytes long. Managed data values are displayed as base64 encoded strings, which are + * 4*((len+2)/3) characters long. (An additional slot is required for the end-of-string character of + * course) */ #define DETAIL_VALUE_MAX_SIZE 89 -static const char* NETWORK_NAMES[3] = { "Public", "Test", "Unknown" }; +static const char *NETWORK_NAMES[3] = {"Public", "Test", "Unknown"}; // ------------------------------------------------------------------------- // // UTILITIES // @@ -130,15 +130,21 @@ static const char* NETWORK_NAMES[3] = { "Public", "Test", "Unknown" }; #ifdef TEST #include -#define THROW(code) do { printf("error: %d", code); } while (0) +#define THROW(code) \ + do { \ + printf("error: %d", code); \ + } while (0) #define PRINTF(msg, arg) printf(msg, arg) -#define PIC(code) code +#define PIC(code) code //#define TARGET_NANOS 1 #define MEMCLEAR(dest) memset(&dest, 0, sizeof(dest)); #else -#define MEMCLEAR(dest) do { os_memset(&dest, 0, sizeof(dest)); } while (0) +#define MEMCLEAR(dest) \ + do { \ + os_memset(&dest, 0, sizeof(dest)); \ + } while (0) #include "bolos_target.h" -#endif // TEST +#endif // TEST // ------------------------------------------------------------------------- // // TYPE DEFINITIONS // @@ -297,17 +303,9 @@ typedef struct { uint32_t tx; } tx_context_t; -enum request_type_t { - CONFIRM_ADDRESS, - CONFIRM_TRANSACTION -}; - -enum app_state_t { - STATE_NONE, - STATE_PARSE_TX, - STATE_APPROVE_TX, - STATE_APPROVE_TX_HASH -}; +enum request_type_t { CONFIRM_ADDRESS, CONFIRM_TRANSACTION }; + +enum app_state_t { STATE_NONE, STATE_PARSE_TX, STATE_APPROVE_TX, STATE_APPROVE_TX_HASH }; typedef struct { enum app_state_t state; diff --git a/src/stellar_utils.c b/src/stellar_utils.c index 2f16c46d..5def1609 100644 --- a/src/stellar_utils.c +++ b/src/stellar_utils.c @@ -28,30 +28,30 @@ static const char hexAlphabet[] = "0123456789ABCDEF"; static const char base32Alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; -static const char base64Alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +static const char base64Alphabet[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static int base64ModTable[] = {0, 2, 1}; - unsigned short crc16(char *ptr, int count) { - int crc; - char i; - crc = 0; - while (--count >= 0) { - crc = crc ^ (int) *ptr++ << 8; - i = 8; - do - { - if (crc & 0x8000) - crc = crc << 1 ^ 0x1021; - else - crc = crc << 1; - } while(--i); - } - return (crc); + int crc; + char i; + crc = 0; + while (--count >= 0) { + crc = crc ^ (int) *ptr++ << 8; + i = 8; + do { + if (crc & 0x8000) + crc = crc << 1 ^ 0x1021; + else + crc = crc << 1; + } while (--i); + } + return (crc); } /** - * adapted from https://stash.forgerock.org/projects/OPENAM/repos/forgerock-authenticator-ios/browse/ForgeRock-Authenticator/base32.c + * adapted from + * https://stash.forgerock.org/projects/OPENAM/repos/forgerock-authenticator-ios/browse/ForgeRock-Authenticator/base32.c */ int base32_encode(const uint8_t *data, int length, char *result, int bufSize) { int count = 0; @@ -108,13 +108,10 @@ int base32_encode(const uint8_t *data, int length, char *result, int bufSize) { } } - void base64_encode(const uint8_t *data, int inLen, char *out) { - size_t outLen = 4 * ((inLen + 2) / 3); for (int i = 0, j = 0; i < inLen;) { - uint32_t octet_a = i < inLen ? data[i++] : 0; uint32_t octet_b = i < inLen ? data[i++] : 0; uint32_t octet_c = i < inLen ? data[i++] : 0; @@ -140,9 +137,9 @@ void encode_key(const uint8_t *in, char *out, uint8_t versionByte) { buffer[0] = versionByte; int i; for (i = 0; i < 32; i++) { - buffer[i+1] = in[i]; + buffer[i + 1] = in[i]; } - short crc = crc16((char *)buffer, 33); // checksum + short crc = crc16((char *) buffer, 33); // checksum buffer[33] = crc; buffer[34] = crc >> 8; base32_encode(buffer, 35, out, 56); @@ -167,8 +164,8 @@ void print_summary(char *in, char *out, uint8_t numCharsL, uint8_t numCharsR) { if (inLength > outLength) { memcpy(out, in, numCharsL); out[numCharsL] = '.'; - out[numCharsL+1] = '.'; - memcpy(out + numCharsL+2, in + inLength - numCharsR, numCharsR); + out[numCharsL + 1] = '.'; + memcpy(out + numCharsL + 2, in + inLength - numCharsR, numCharsR); out[outLength] = '\0'; } else { memcpy(out, in, inLength); @@ -179,9 +176,9 @@ void print_binary(const uint8_t *in, char *out, uint8_t len) { out[0] = '0'; out[1] = 'x'; uint8_t i, j; - for (i = 0, j = 2; i < len; i+=1, j+=2) { + for (i = 0, j = 2; i < len; i += 1, j += 2) { out[j] = hexAlphabet[in[i] / 16]; - out[j+1] = hexAlphabet[in[i] % 16]; + out[j + 1] = hexAlphabet[in[i] % 16]; } out[j] = '\0'; } @@ -189,17 +186,17 @@ void print_binary(const uint8_t *in, char *out, uint8_t len) { void print_binary_summary(const uint8_t *in, char *out, uint8_t len) { out[0] = '0'; out[1] = 'x'; - if (2+len*2 > 18) { + if (2 + len * 2 > 18) { uint8_t i, j; - for (i = 0, j = 2; i < 4; i+=1, j+=2) { + for (i = 0, j = 2; i < 4; i += 1, j += 2) { out[j] = hexAlphabet[in[i] / 16]; - out[j+1] = hexAlphabet[in[i] % 16]; + out[j + 1] = hexAlphabet[in[i] % 16]; } out[j++] = '.'; out[j++] = '.'; - for (i = len - 4; i < len; i+=1, j+=2) { + for (i = len - 4; i < len; i += 1, j += 2) { out[j] = hexAlphabet[in[i] / 16]; - out[j+1] = hexAlphabet[in[i] % 16]; + out[j + 1] = hexAlphabet[in[i] % 16]; } out[j] = '\0'; } else { @@ -231,7 +228,7 @@ void print_amount(uint64_t amount, const char *asset, char *out) { } else { buffer[i] = '0'; } - if (i == 6) { // stroops to xlm: 1 xlm = 10000000 stroops + if (i == 6) { // stroops to xlm: 1 xlm = 10000000 stroops i += 1; buffer[i] = '.'; } @@ -240,7 +237,7 @@ void print_amount(uint64_t amount, const char *asset, char *out) { } } // reverse order - for (i -= 1, j = 0; i >= 0 && j < AMOUNT_MAX_SIZE-1; i--, j++) { + for (i -= 1, j = 0; i >= 0 && j < AMOUNT_MAX_SIZE - 1; i--, j++) { out[j] = buffer[i]; } // strip trailing 0s @@ -250,17 +247,16 @@ void print_amount(uint64_t amount, const char *asset, char *out) { j += 1; // strip trailing . - if (out[j-1] == '.') j -= 1; + if (out[j - 1] == '.') j -= 1; if (asset) { // qualify amount out[j++] = ' '; strcpy(out + j, asset); - out[j+strlen(asset)] = '\0'; + out[j + strlen(asset)] = '\0'; } else { out[j] = '\0'; } - } void print_int(int64_t l, char *out) { @@ -286,7 +282,7 @@ void print_int(int64_t l, char *out) { out[j++] = '-'; } // reverse order - for (i -= 1; i >= 0 && j < AMOUNT_MAX_SIZE-1; i--, j++) { + for (i -= 1; i >= 0 && j < AMOUNT_MAX_SIZE - 1; i--, j++) { out[j] = buffer[i]; } out[j] = '\0'; @@ -311,7 +307,7 @@ void print_uint(uint64_t l, char *out) { dVal /= 10; } // reverse order - for (i -= 1, j = 0; i >= 0 && j < AMOUNT_MAX_SIZE-1; i--, j++) { + for (i -= 1, j = 0; i >= 0 && j < AMOUNT_MAX_SIZE - 1; i--, j++) { out[j] = buffer[i]; } out[j] = '\0'; @@ -327,20 +323,20 @@ void print_asset(char *code, char *issuer, char *out) { uint8_t offset = strlen(code); strcpy(out, code); out[offset] = '@'; - strcpy(out+offset+1, issuer); + strcpy(out + offset + 1, issuer); } void print_flag(char *flag, char *out, char prefix) { uint8_t len = strlen(out); if (len) { - strcpy(out+len, ", "); + strcpy(out + len, ", "); len += 2; } if (prefix) { out[len] = prefix; len += 1; } - strcpy(out+len, flag); + strcpy(out + len, flag); } void print_flags(uint32_t flags, char *out, char prefix) { diff --git a/src/stellar_ux_common.c b/src/stellar_ux_common.c index d5c85989..f38ba94d 100644 --- a/src/stellar_ux_common.c +++ b/src/stellar_ux_common.c @@ -29,7 +29,7 @@ unsigned int io_seproxyhal_respond(unsigned short sw, uint32_t tx) { // Display back the original UX ui_idle(); - return 0; // do not redraw the widgets + return 0; // do not redraw the widgets } unsigned int io_seproxyhal_touch_address_ok(const bagl_element_t *e) { diff --git a/src/stellar_ux_nanox.c b/src/stellar_ux_nanox.c index eb80eb15..85d936ed 100644 --- a/src/stellar_ux_nanox.c +++ b/src/stellar_ux_nanox.c @@ -21,7 +21,8 @@ void settings_submenu_selector(unsigned int idx); // ------------------------------------------------------------------------- // ////////////////////////////////////////////////////////////////////////////////////// -UX_FLOW_DEF_VALID( +// clang-format off +UX_STEP_CB( settings_hash_signing_enable_step, pbb, settings_hash_signing_change(1), @@ -30,7 +31,7 @@ UX_FLOW_DEF_VALID( "Enable hash", "signing?", }); -UX_FLOW_DEF_VALID( +UX_STEP_CB( settings_hash_signing_disable_step, pb, settings_hash_signing_change(0), @@ -38,7 +39,7 @@ UX_FLOW_DEF_VALID( &C_icon_crossmark, "Disable", }); -UX_FLOW_DEF_VALID( +UX_STEP_CB( settings_hash_signing_go_back_step, pb, ux_menulist_init(0, settings_submenu_getter, settings_submenu_selector), @@ -52,13 +53,14 @@ UX_DEF(settings_hash_signing_flow, &settings_hash_signing_disable_step, &settings_hash_signing_go_back_step ); +// clang-format on void settings_hash_signing(void) { - ux_flow_init(0, settings_hash_signing_flow, NULL); + ux_flow_init(0, settings_hash_signing_flow, NULL); } void settings_hash_signing_change(unsigned int enabled) { - nvm_write((void*)&N_stellar_pstate.hashSigning, &enabled, 1); + nvm_write((void*) &N_stellar_pstate.hashSigning, &enabled, 1); ui_idle(); } @@ -66,29 +68,30 @@ void settings_hash_signing_change(unsigned int enabled) { // Settings menu: const char* const settings_submenu_getter_values[] = { - "Hash signing", - "Back", + "Hash signing", + "Back", }; const char* settings_submenu_getter(unsigned int idx) { - if (idx < ARRAYLEN(settings_submenu_getter_values)) { - return settings_submenu_getter_values[idx]; - } - return NULL; + if (idx < ARRAYLEN(settings_submenu_getter_values)) { + return settings_submenu_getter_values[idx]; + } + return NULL; } void settings_submenu_selector(unsigned int idx) { - switch(idx) { - case 0: - settings_hash_signing(); - break; - default: - ui_idle(); - } + switch (idx) { + case 0: + settings_hash_signing(); + break; + default: + ui_idle(); + } } ////////////////////////////////////////////////////////////////////////////////////// -UX_FLOW_DEF_NOCB( +// clang-format off +UX_STEP_NOCB( idle_welcome_step, pbb, { @@ -96,7 +99,7 @@ UX_FLOW_DEF_NOCB( "Use wallet to", "view accounts", }); -UX_FLOW_DEF_VALID( +UX_STEP_CB( idle_settings_step, pb, ux_menulist_init(0, settings_submenu_getter, settings_submenu_selector), @@ -106,14 +109,14 @@ UX_FLOW_DEF_VALID( "Settings", }); -UX_FLOW_DEF_NOCB( +UX_STEP_NOCB( idle_version_step, bn, { "Version", APPVERSION, }); -UX_FLOW_DEF_VALID( +UX_STEP_CB( idle_quit_step, pb, os_sched_exit(-1), @@ -128,23 +131,23 @@ UX_DEF(idle_flow, &idle_version_step, &idle_quit_step ); +// clang-format on void ui_idle(void) { - if(G_ux.stack_count == 0) { + if (G_ux.stack_count == 0) { ux_stack_push(); } - ux_flow_init(0, idle_flow, NULL); + ux_flow_init(0, idle_flow, NULL); } - bagl_element_t tmp_element; - // ------------------------------------------------------------------------- // // CONFIRM ADDRESS // // ------------------------------------------------------------------------- // ////////////////////////////////////////////////////////////////////////////////////// +// clang-format off UX_STEP_NOCB( ux_display_public_flow_0_step, pnn, @@ -153,14 +156,14 @@ UX_STEP_NOCB( "Confirm", "Address", }); -UX_FLOW_DEF_NOCB( +UX_STEP_NOCB( ux_display_public_flow_1_step, bnnn_paging, { .title = "Confirm Address", .text = detailValue, }); -UX_FLOW_DEF_VALID( +UX_STEP_CB( ux_display_public_flow_2_step, pb, io_seproxyhal_touch_address_ok(NULL), @@ -168,7 +171,7 @@ UX_FLOW_DEF_VALID( &C_icon_validate_14, "Approve", }); -UX_FLOW_DEF_VALID( +UX_STEP_CB( ux_display_public_flow_3_step, pb, io_seproxyhal_touch_address_cancel(NULL), @@ -183,9 +186,10 @@ UX_DEF(ux_display_public_flow, &ux_display_public_flow_2_step, &ux_display_public_flow_3_step ); +// clang-format on void ui_show_address_init(void) { - if(G_ux.stack_count == 0) { + if (G_ux.stack_count == 0) { ux_stack_push(); } print_public_key(ctx.req.pk.publicKey, detailValue, 0, 0); @@ -198,6 +202,7 @@ void ui_show_address_init(void) { void display_next_state(bool is_upper_border); +// clang-format off UX_STEP_NOCB( ux_confirm_tx_init_flow_step, pnn, @@ -229,7 +234,7 @@ UX_STEP_INIT( display_next_state(false); }); -UX_FLOW_DEF_VALID( +UX_STEP_CB( ux_confirm_tx_finalize_step, pnn, io_seproxyhal_touch_tx_ok(NULL), @@ -239,7 +244,7 @@ UX_FLOW_DEF_VALID( "Transaction", }); -UX_FLOW_DEF_VALID( +UX_STEP_CB( ux_reject_tx_flow_step, pb, io_seproxyhal_touch_tx_cancel(NULL), @@ -258,6 +263,7 @@ UX_FLOW(ux_confirm_flow, &ux_confirm_tx_finalize_step, &ux_reject_tx_flow_step ); +// clang-format on uint8_t num_data; volatile uint8_t current_state; @@ -265,62 +271,57 @@ volatile uint8_t current_state; #define INSIDE_BORDERS 0 #define OUT_OF_BORDERS 1 -void display_next_state(bool is_upper_border){ - - if(is_upper_border){ // -> from first screen - if(current_state == OUT_OF_BORDERS){ +void display_next_state(bool is_upper_border) { + if (is_upper_border) { // -> from first screen + if (current_state == OUT_OF_BORDERS) { current_state = INSIDE_BORDERS; set_state_data(true); ux_flow_next(); - } - else{ + } else { formatter_index -= 1; - if(current_data_index>0){ // <- from middle, more screens available + if (current_data_index > 0) { // <- from middle, more screens available set_state_data(false); - if(formatter_stack[formatter_index] != NULL){ + if (formatter_stack[formatter_index] != NULL) { ux_flow_next(); - } - else{ + } else { current_state = OUT_OF_BORDERS; current_data_index = 0; ux_flow_prev(); } - } - else{ // <- from middle, no more screens available + } else { // <- from middle, no more screens available current_state = OUT_OF_BORDERS; current_data_index = 0; ux_flow_prev(); } } - } - else // walking over the second border + } else // walking over the second border { - if(current_state == OUT_OF_BORDERS){ // <- from last screen + if (current_state == OUT_OF_BORDERS) { // <- from last screen current_state = INSIDE_BORDERS; set_state_data(false); ux_flow_prev(); - } - else{ + } else { formatter_index += 1; - if((num_data != 0 && current_data_index from middle, more screens available + if ((num_data != 0 && current_data_index < num_data - 1) || + formatter_stack[formatter_index] != + NULL) { // -> from middle, more screens available set_state_data(true); - /*dirty hack to have coherent behavior on bnnn_paging when there are multiple screens*/ - G_ux.flow_stack[G_ux.stack_count-1].prev_index = G_ux.flow_stack[G_ux.stack_count-1].index-2; - G_ux.flow_stack[G_ux.stack_count-1].index--; + /*dirty hack to have coherent behavior on bnnn_paging when there are multiple + * screens*/ + G_ux.flow_stack[G_ux.stack_count - 1].prev_index = + G_ux.flow_stack[G_ux.stack_count - 1].index - 2; + G_ux.flow_stack[G_ux.stack_count - 1].index--; ux_flow_relayout(); /*end of dirty hack*/ - } - else{ // -> from middle, no more screens available + } else { // -> from middle, no more screens available current_state = OUT_OF_BORDERS; ux_flow_next(); } } } - } - void ui_approve_tx_init(void) { ctx.req.tx.offset = 0; formatter_index = 0; @@ -331,7 +332,6 @@ void ui_approve_tx_init(void) { ux_flow_init(0, ux_confirm_flow, NULL); } - void ui_approve_tx_hash_init(void) { formatter_index = 0; MEMCLEAR(formatter_stack); @@ -341,7 +341,4 @@ void ui_approve_tx_hash_init(void) { ux_flow_init(0, ux_confirm_flow, NULL); } - - - #endif \ No newline at end of file diff --git a/src/stellar_vars.h b/src/stellar_vars.h index 63712efd..3c10d3aa 100644 --- a/src/stellar_vars.h +++ b/src/stellar_vars.h @@ -30,8 +30,6 @@ extern ux_state_t ux; extern stellar_context_t ctx; extern stellar_nv_state_t const N_state_pic; -#define N_stellar_pstate (*(volatile stellar_nv_state_t *)PIC(&N_state_pic)) +#define N_stellar_pstate (*(volatile stellar_nv_state_t *) PIC(&N_state_pic)) #endif - - diff --git a/test/test_parser.c b/test/test_parser.c index 2a28f308..eee3de14 100644 --- a/test/test_parser.c +++ b/test/test_parser.c @@ -9,1211 +9,1135 @@ #include "stellar_format.h" typedef struct { - const char *name; - const char *value; + const char *name; + const char *value; } detail_t; typedef struct { - size_t num_details; - const detail_t items[15]; + size_t num_details; + const detail_t items[15]; } op_summary; typedef struct { - size_t num_ops; - op_summary ops[3]; + size_t num_ops; + op_summary ops[3]; } ops_summary; stellar_context_t ctx; -static void test_tx(const uint8_t *data, size_t size, - const ops_summary *summary, const op_summary *details) { - tx_context_t tx_ctx = {0}; +static void test_tx(const uint8_t *data, + size_t size, + const ops_summary *summary, + const op_summary *details) { + tx_context_t tx_ctx = {0}; formatter_index = 0; ctx.state = STATE_APPROVE_TX; - assert_true(parse_tx_xdr(data, size, &tx_ctx)); - assert_int_equal(summary->num_ops, tx_ctx.opCount); + assert_true(parse_tx_xdr(data, size, &tx_ctx)); + assert_int_equal(summary->num_ops, tx_ctx.opCount); - for (int n = 0; n < tx_ctx.opCount; n++) { - formatter_stack[formatter_index] = format_confirm_operation; - const op_summary *op = &summary->ops[n]; + for (int n = 0; n < tx_ctx.opCount; n++) { + formatter_stack[formatter_index] = format_confirm_operation; + const op_summary *op = &summary->ops[n]; - if (tx_ctx.opCount > 1) { + if (tx_ctx.opCount > 1) { char tmp[30]; assert_non_null(formatter_stack[formatter_index]); formatter_stack[formatter_index](&tx_ctx); formatter_index++; sprintf(tmp, "Operation %d of %d", n + 1, tx_ctx.opCount); assert_string_equal(tmp, opCaption); - } + } - for (int i = 0; i < op->num_details; i++) { - memset(opCaption, 0, sizeof(opCaption)); - memset(detailCaption, 0, sizeof(detailCaption)); - memset(detailValue, 0, sizeof(detailValue)); + for (int i = 0; i < op->num_details; i++) { + memset(opCaption, 0, sizeof(opCaption)); + memset(detailCaption, 0, sizeof(detailCaption)); + memset(detailValue, 0, sizeof(detailValue)); - assert_non_null( formatter_stack[formatter_index]); - formatter_stack[formatter_index](&tx_ctx); + assert_non_null(formatter_stack[formatter_index]); + formatter_stack[formatter_index](&tx_ctx); - assert_string_equal(op->items[i].name, detailCaption); - assert_string_equal(op->items[i].value, detailValue); - formatter_index++; - } + assert_string_equal(op->items[i].name, detailCaption); + assert_string_equal(op->items[i].value, detailValue); + formatter_index++; + } - if (n != tx_ctx.opCount - 1) { - assert_true(parse_tx_xdr(data, size, &tx_ctx)); + if (n != tx_ctx.opCount - 1) { + assert_true(parse_tx_xdr(data, size, &tx_ctx)); + } } - } - assert_false(parse_tx_xdr(data, size, &tx_ctx)); + assert_false(parse_tx_xdr(data, size, &tx_ctx)); - // formatter_stack[formatter_index] = format_confirm_transaction_details; + // formatter_stack[formatter_index] = format_confirm_transaction_details; - for (int i = 0; i < details->num_details; i++) { - memset(opCaption, 0, sizeof(opCaption)); - memset(detailCaption, 0, sizeof(detailCaption)); - memset(detailValue, 0, sizeof(detailValue)); + for (int i = 0; i < details->num_details; i++) { + memset(opCaption, 0, sizeof(opCaption)); + memset(detailCaption, 0, sizeof(detailCaption)); + memset(detailValue, 0, sizeof(detailValue)); - assert_non_null( formatter_stack[formatter_index]); - formatter_stack[formatter_index](&tx_ctx); + assert_non_null(formatter_stack[formatter_index]); + formatter_stack[formatter_index](&tx_ctx); - assert_string_equal(details->items[i].name, detailCaption); - assert_string_equal(details->items[i].value, detailValue); - formatter_index++; - } - assert_null( formatter_stack[formatter_index]); + assert_string_equal(details->items[i].name, detailCaption); + assert_string_equal(details->items[i].value, detailValue); + formatter_index++; + } + assert_null(formatter_stack[formatter_index]); } static void test_tx_simple(void **state) { - (void)state; - - const uint8_t tx_data[157] = { - 0x7A, 0xC3, 0x39, 0x97, 0x54, 0x4E, 0x31, 0x75, 0xD2, 0x66, 0xBD, 0x02, - 0x24, 0x39, 0xB2, 0x2C, 0xDB, 0x16, 0x50, 0x8C, 0x01, 0x16, 0x3F, 0x26, - 0xE5, 0xCB, 0x2A, 0x3E, 0x10, 0x45, 0xA9, 0x79, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, 0xE4, 0x2B, 0x1F, - 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, - 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, - 0x00, 0x00, 0x00, 0x64, 0x00, 0xC5, 0xB4, 0xA5, 0x00, 0x00, 0x00, 0x19, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x95, 0x41, 0xF0, 0x27, 0x46, 0x24, 0x0C, 0x1E, 0x9F, 0x38, 0x43, 0xD2, - 0x8E, 0x56, 0xF0, 0xA5, 0x83, 0xEC, 0xD2, 0x75, 0x02, 0xFB, 0x0F, 0x4A, - 0x27, 0xD4, 0xD0, 0x92, 0x2F, 0xE0, 0x64, 0xA2, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x96, 0x80, 0x00, 0x00, 0x00, 0x00, - 0x00}; - - const ops_summary summary = { - 1, - - {2, + (void) state; + + const uint8_t tx_data[157] = { + 0x7A, 0xC3, 0x39, 0x97, 0x54, 0x4E, 0x31, 0x75, 0xD2, 0x66, 0xBD, 0x02, 0x24, 0x39, 0xB2, + 0x2C, 0xDB, 0x16, 0x50, 0x8C, 0x01, 0x16, 0x3F, 0x26, 0xE5, 0xCB, 0x2A, 0x3E, 0x10, 0x45, + 0xA9, 0x79, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, + 0xE4, 0x2B, 0x1F, 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, + 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, 0x00, 0x00, 0x00, + 0x64, 0x00, 0xC5, 0xB4, 0xA5, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x95, 0x41, 0xF0, 0x27, 0x46, 0x24, 0x0C, 0x1E, 0x9F, 0x38, 0x43, 0xD2, + 0x8E, 0x56, 0xF0, 0xA5, 0x83, 0xEC, 0xD2, 0x75, 0x02, 0xFB, 0x0F, 0x4A, 0x27, 0xD4, 0xD0, + 0x92, 0x2F, 0xE0, 0x64, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, + 0x96, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = { + 1, + + {2, + { + {"Send", "1 XLM"}, + {"Destination", "GCKUD4BHIYSAYHU7HBB5FDSW6CSYH3GSOUBPWD2KE7KNBERP4BSKEJDV"}, + + }}}; + + const op_summary details = { + 4, { - {"Send", "1 XLM"}, - {"Destination", - "GCKUD4BHIYSAYHU7HBB5FDSW6CSYH3GSOUBPWD2KE7KNBERP4BSKEJDV"}, - - }}}; - - const op_summary details = { - 4, - {{"Memo", "[none]"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Public"}, - {"Tx Source", - "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, - }}; - - test_tx(tx_data, sizeof(tx_data), &summary, &details); + {"Memo", "[none]"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Public"}, + {"Tx Source", "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, + }}; + + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_memo_id(void **state) { - (void)state; - - const uint8_t tx_data[165] = { - 0x7A, 0xC3, 0x39, 0x97, 0x54, 0x4E, 0x31, 0x75, 0xD2, 0x66, 0xBD, 0x02, - 0x24, 0x39, 0xB2, 0x2C, 0xDB, 0x16, 0x50, 0x8C, 0x01, 0x16, 0x3F, 0x26, - 0xE5, 0xCB, 0x2A, 0x3E, 0x10, 0x45, 0xA9, 0x79, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, 0xE4, 0x2B, 0x1F, - 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, - 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, - 0x00, 0x00, 0x00, 0x64, 0x00, 0xC5, 0xB4, 0xA5, 0x00, 0x00, 0x00, 0x1D, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x95, 0x41, 0xF0, 0x27, - 0x46, 0x24, 0x0C, 0x1E, 0x9F, 0x38, 0x43, 0xD2, 0x8E, 0x56, 0xF0, 0xA5, - 0x83, 0xEC, 0xD2, 0x75, 0x02, 0xFB, 0x0F, 0x4A, 0x27, 0xD4, 0xD0, 0x92, - 0x2F, 0xE0, 0x64, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0xE1, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - const ops_summary summary = { - 1, - - {2, + (void) state; + + const uint8_t tx_data[165] = { + 0x7A, 0xC3, 0x39, 0x97, 0x54, 0x4E, 0x31, 0x75, 0xD2, 0x66, 0xBD, 0x02, 0x24, 0x39, 0xB2, + 0x2C, 0xDB, 0x16, 0x50, 0x8C, 0x01, 0x16, 0x3F, 0x26, 0xE5, 0xCB, 0x2A, 0x3E, 0x10, 0x45, + 0xA9, 0x79, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, + 0xE4, 0x2B, 0x1F, 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, + 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, 0x00, 0x00, 0x00, + 0x64, 0x00, 0xC5, 0xB4, 0xA5, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x95, 0x41, 0xF0, 0x27, + 0x46, 0x24, 0x0C, 0x1E, 0x9F, 0x38, 0x43, 0xD2, 0x8E, 0x56, 0xF0, 0xA5, 0x83, 0xEC, 0xD2, + 0x75, 0x02, 0xFB, 0x0F, 0x4A, 0x27, 0xD4, 0xD0, 0x92, 0x2F, 0xE0, 0x64, 0xA2, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0xE1, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = { + 1, + + {2, + { + {"Send", "30 XLM"}, + {"Destination", "GCKUD4BHIYSAYHU7HBB5FDSW6CSYH3GSOUBPWD2KE7KNBERP4BSKEJDV"}, + + }}}; + + const op_summary details = { + 4, { - {"Send", "30 XLM"}, - {"Destination", - "GCKUD4BHIYSAYHU7HBB5FDSW6CSYH3GSOUBPWD2KE7KNBERP4BSKEJDV"}, - - }}}; - - const op_summary details = { - 4, - {{"Memo ID", "16"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Public"}, - {"Tx Source", - "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, - }}; - - test_tx(tx_data, sizeof(tx_data), &summary, &details); + {"Memo ID", "16"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Public"}, + {"Tx Source", "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, + }}; + + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_memo_text(void **state) { - (void)state; - - const uint8_t tx_data[173] = { - 0x7A, 0xC3, 0x39, 0x97, 0x54, 0x4E, 0x31, 0x75, 0xD2, 0x66, 0xBD, 0x02, - 0x24, 0x39, 0xB2, 0x2C, 0xDB, 0x16, 0x50, 0x8C, 0x01, 0x16, 0x3F, 0x26, - 0xE5, 0xCB, 0x2A, 0x3E, 0x10, 0x45, 0xA9, 0x79, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, 0xE4, 0x2B, 0x1F, - 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, - 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, - 0x00, 0x00, 0x00, 0x64, 0x00, 0xC5, 0xB4, 0xA5, 0x00, 0x00, 0x00, 0x1D, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, - 0x73, 0x74, 0x61, 0x72, 0x6C, 0x69, 0x67, 0x68, 0x74, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x95, 0x41, 0xF0, 0x27, 0x46, 0x24, 0x0C, 0x1E, - 0x9F, 0x38, 0x43, 0xD2, 0x8E, 0x56, 0xF0, 0xA5, 0x83, 0xEC, 0xD2, 0x75, - 0x02, 0xFB, 0x0F, 0x4A, 0x27, 0xD4, 0xD0, 0x92, 0x2F, 0xE0, 0x64, 0xA2, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0xE1, 0xA3, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00}; - - const ops_summary summary = { - 1, - - {2, + (void) state; + + const uint8_t tx_data[173] = { + 0x7A, 0xC3, 0x39, 0x97, 0x54, 0x4E, 0x31, 0x75, 0xD2, 0x66, 0xBD, 0x02, 0x24, 0x39, 0xB2, + 0x2C, 0xDB, 0x16, 0x50, 0x8C, 0x01, 0x16, 0x3F, 0x26, 0xE5, 0xCB, 0x2A, 0x3E, 0x10, 0x45, + 0xA9, 0x79, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, + 0xE4, 0x2B, 0x1F, 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, + 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, 0x00, 0x00, 0x00, + 0x64, 0x00, 0xC5, 0xB4, 0xA5, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0x73, 0x74, 0x61, 0x72, 0x6C, 0x69, 0x67, 0x68, 0x74, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x95, 0x41, 0xF0, 0x27, 0x46, 0x24, 0x0C, 0x1E, 0x9F, 0x38, 0x43, + 0xD2, 0x8E, 0x56, 0xF0, 0xA5, 0x83, 0xEC, 0xD2, 0x75, 0x02, 0xFB, 0x0F, 0x4A, 0x27, 0xD4, + 0xD0, 0x92, 0x2F, 0xE0, 0x64, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, + 0xE1, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = { + 1, + + {2, + { + {"Send", "30 XLM"}, + {"Destination", "GCKUD4BHIYSAYHU7HBB5FDSW6CSYH3GSOUBPWD2KE7KNBERP4BSKEJDV"}, + + }}}; + + const op_summary details = { + 4, { - {"Send", "30 XLM"}, - {"Destination", - "GCKUD4BHIYSAYHU7HBB5FDSW6CSYH3GSOUBPWD2KE7KNBERP4BSKEJDV"}, - - }}}; - - const op_summary details = { - 4, - {{"Memo Text", "starlight"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Public"}, - {"Tx Source", - "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, - }}; - - test_tx(tx_data, sizeof(tx_data), &summary, &details); + {"Memo Text", "starlight"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Public"}, + {"Tx Source", "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, + }}; + + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_memo_hash(void **state) { - (void)state; - - const uint8_t tx_data[189] = { - 0x7A, 0xC3, 0x39, 0x97, 0x54, 0x4E, 0x31, 0x75, 0xD2, 0x66, 0xBD, 0x02, - 0x24, 0x39, 0xB2, 0x2C, 0xDB, 0x16, 0x50, 0x8C, 0x01, 0x16, 0x3F, 0x26, - 0xE5, 0xCB, 0x2A, 0x3E, 0x10, 0x45, 0xA9, 0x79, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, 0xE4, 0x2B, 0x1F, - 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, - 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, - 0x00, 0x00, 0x00, 0x64, 0x00, 0xC5, 0xB4, 0xA5, 0x00, 0x00, 0x00, 0x1E, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x42, 0xA0, 0x84, 0x41, - 0x0A, 0xBD, 0x85, 0x6C, 0x4B, 0x67, 0x04, 0xE1, 0xC3, 0x8A, 0xFF, 0x73, - 0x3E, 0x8F, 0x63, 0xB8, 0x83, 0x8A, 0x6C, 0x18, 0xE5, 0xCB, 0x78, 0x75, - 0xD9, 0x20, 0x4D, 0x3B, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x95, 0x41, 0xF0, 0x27, - 0x46, 0x24, 0x0C, 0x1E, 0x9F, 0x38, 0x43, 0xD2, 0x8E, 0x56, 0xF0, 0xA5, - 0x83, 0xEC, 0xD2, 0x75, 0x02, 0xFB, 0x0F, 0x4A, 0x27, 0xD4, 0xD0, 0x92, - 0x2F, 0xE0, 0x64, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0xE1, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - const ops_summary summary = { - 1, - - {2, + (void) state; + + const uint8_t tx_data[189] = { + 0x7A, 0xC3, 0x39, 0x97, 0x54, 0x4E, 0x31, 0x75, 0xD2, 0x66, 0xBD, 0x02, 0x24, 0x39, 0xB2, + 0x2C, 0xDB, 0x16, 0x50, 0x8C, 0x01, 0x16, 0x3F, 0x26, 0xE5, 0xCB, 0x2A, 0x3E, 0x10, 0x45, + 0xA9, 0x79, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, + 0xE4, 0x2B, 0x1F, 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, + 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, 0x00, 0x00, 0x00, + 0x64, 0x00, 0xC5, 0xB4, 0xA5, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x03, 0x42, 0xA0, 0x84, 0x41, 0x0A, 0xBD, 0x85, 0x6C, 0x4B, 0x67, 0x04, 0xE1, 0xC3, + 0x8A, 0xFF, 0x73, 0x3E, 0x8F, 0x63, 0xB8, 0x83, 0x8A, 0x6C, 0x18, 0xE5, 0xCB, 0x78, 0x75, + 0xD9, 0x20, 0x4D, 0x3B, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x95, 0x41, 0xF0, 0x27, 0x46, 0x24, 0x0C, 0x1E, 0x9F, 0x38, + 0x43, 0xD2, 0x8E, 0x56, 0xF0, 0xA5, 0x83, 0xEC, 0xD2, 0x75, 0x02, 0xFB, 0x0F, 0x4A, 0x27, + 0xD4, 0xD0, 0x92, 0x2F, 0xE0, 0x64, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x11, 0xE1, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = { + 1, + + {2, + { + {"Send", "30 XLM"}, + {"Destination", "GCKUD4BHIYSAYHU7HBB5FDSW6CSYH3GSOUBPWD2KE7KNBERP4BSKEJDV"}, + + }}}; + + const op_summary details = { + 4, { - {"Send", "30 XLM"}, - {"Destination", - "GCKUD4BHIYSAYHU7HBB5FDSW6CSYH3GSOUBPWD2KE7KNBERP4BSKEJDV"}, - - }}}; - - const op_summary details = { - 4, - {{"Memo Hash", - "0x42A084..204D3B"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Public"}, - {"Tx Source", - "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, - }}; - - test_tx(tx_data, sizeof(tx_data), &summary, &details); + {"Memo Hash", "0x42A084..204D3B"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Public"}, + {"Tx Source", "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, + }}; + + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_custom_asset4(void **state) { - (void)state; - - const uint8_t tx_data[197] = { - 0x7A, 0xC3, 0x39, 0x97, 0x54, 0x4E, 0x31, 0x75, 0xD2, 0x66, 0xBD, 0x02, - 0x24, 0x39, 0xB2, 0x2C, 0xDB, 0x16, 0x50, 0x8C, 0x01, 0x16, 0x3F, 0x26, - 0xE5, 0xCB, 0x2A, 0x3E, 0x10, 0x45, 0xA9, 0x79, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, 0xE4, 0x2B, 0x1F, - 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, - 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, - 0x00, 0x00, 0x00, 0x64, 0x00, 0xC5, 0xB4, 0xA5, 0x00, 0x00, 0x00, 0x1D, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x95, 0x41, 0xF0, 0x27, 0x46, 0x24, 0x0C, 0x1E, 0x9F, 0x38, 0x43, 0xD2, - 0x8E, 0x56, 0xF0, 0xA5, 0x83, 0xEC, 0xD2, 0x75, 0x02, 0xFB, 0x0F, 0x4A, - 0x27, 0xD4, 0xD0, 0x92, 0x2F, 0xE0, 0x64, 0xA2, 0x00, 0x00, 0x00, 0x01, - 0x44, 0x55, 0x50, 0x45, 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, - 0x75, 0xE4, 0x2B, 0x1F, 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, - 0x46, 0xDF, 0x12, 0xAD, 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, - 0xB1, 0x6E, 0x57, 0x13, 0x00, 0x00, 0x00, 0x00, 0x11, 0xE1, 0xA3, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00}; - - const ops_summary summary = { - 1, - - {2, + (void) state; + + const uint8_t tx_data[197] = { + 0x7A, 0xC3, 0x39, 0x97, 0x54, 0x4E, 0x31, 0x75, 0xD2, 0x66, 0xBD, 0x02, 0x24, 0x39, 0xB2, + 0x2C, 0xDB, 0x16, 0x50, 0x8C, 0x01, 0x16, 0x3F, 0x26, 0xE5, 0xCB, 0x2A, 0x3E, 0x10, 0x45, + 0xA9, 0x79, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, + 0xE4, 0x2B, 0x1F, 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, + 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, 0x00, 0x00, 0x00, + 0x64, 0x00, 0xC5, 0xB4, 0xA5, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x95, 0x41, 0xF0, 0x27, 0x46, 0x24, 0x0C, 0x1E, 0x9F, 0x38, 0x43, 0xD2, + 0x8E, 0x56, 0xF0, 0xA5, 0x83, 0xEC, 0xD2, 0x75, 0x02, 0xFB, 0x0F, 0x4A, 0x27, 0xD4, 0xD0, + 0x92, 0x2F, 0xE0, 0x64, 0xA2, 0x00, 0x00, 0x00, 0x01, 0x44, 0x55, 0x50, 0x45, 0x00, 0x00, + 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, 0xE4, 0x2B, 0x1F, 0x7F, 0x85, 0xD0, 0x75, 0xC1, + 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, + 0xB1, 0x6E, 0x57, 0x13, 0x00, 0x00, 0x00, 0x00, 0x11, 0xE1, 0xA3, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00}; + + const ops_summary summary = { + 1, + + {2, + { + {"Send", "30 DUPE"}, + {"Destination", "GCKUD4BHIYSAYHU7HBB5FDSW6CSYH3GSOUBPWD2KE7KNBERP4BSKEJDV"}, + + }}}; + + const op_summary details = { + 4, { - {"Send", "30 DUPE"}, - {"Destination", - "GCKUD4BHIYSAYHU7HBB5FDSW6CSYH3GSOUBPWD2KE7KNBERP4BSKEJDV"}, - - }}}; - - const op_summary details = { - 4, - {{"Memo", "[none]"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Public"}, - {"Tx Source", - "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, - }}; - - test_tx(tx_data, sizeof(tx_data), &summary, &details); + {"Memo", "[none]"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Public"}, + {"Tx Source", "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, + }}; + + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_custom_asset12(void **state) { - (void)state; - - const uint8_t tx_data[205] = { - 0x7A, 0xC3, 0x39, 0x97, 0x54, 0x4E, 0x31, 0x75, 0xD2, 0x66, 0xBD, 0x02, - 0x24, 0x39, 0xB2, 0x2C, 0xDB, 0x16, 0x50, 0x8C, 0x01, 0x16, 0x3F, 0x26, - 0xE5, 0xCB, 0x2A, 0x3E, 0x10, 0x45, 0xA9, 0x79, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, 0xE4, 0x2B, 0x1F, - 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, - 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, - 0x00, 0x00, 0x00, 0x64, 0x00, 0xC5, 0xB4, 0xA5, 0x00, 0x00, 0x00, 0x1D, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x95, 0x41, 0xF0, 0x27, 0x46, 0x24, 0x0C, 0x1E, 0x9F, 0x38, 0x43, 0xD2, - 0x8E, 0x56, 0xF0, 0xA5, 0x83, 0xEC, 0xD2, 0x75, 0x02, 0xFB, 0x0F, 0x4A, - 0x27, 0xD4, 0xD0, 0x92, 0x2F, 0xE0, 0x64, 0xA2, 0x00, 0x00, 0x00, 0x02, - 0x4C, 0x45, 0x4E, 0x4F, 0x4E, 0x44, 0x55, 0x50, 0x45, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, 0xE4, 0x2B, 0x1F, - 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, - 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, - 0x00, 0x00, 0x00, 0x00, 0x11, 0xE1, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00}; - - const ops_summary summary = { - 1, - - {2, + (void) state; + + const uint8_t tx_data[205] = { + 0x7A, 0xC3, 0x39, 0x97, 0x54, 0x4E, 0x31, 0x75, 0xD2, 0x66, 0xBD, 0x02, 0x24, 0x39, 0xB2, + 0x2C, 0xDB, 0x16, 0x50, 0x8C, 0x01, 0x16, 0x3F, 0x26, 0xE5, 0xCB, 0x2A, 0x3E, 0x10, 0x45, + 0xA9, 0x79, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, + 0xE4, 0x2B, 0x1F, 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, + 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, 0x00, 0x00, 0x00, + 0x64, 0x00, 0xC5, 0xB4, 0xA5, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x95, 0x41, 0xF0, 0x27, 0x46, 0x24, 0x0C, 0x1E, 0x9F, 0x38, 0x43, 0xD2, + 0x8E, 0x56, 0xF0, 0xA5, 0x83, 0xEC, 0xD2, 0x75, 0x02, 0xFB, 0x0F, 0x4A, 0x27, 0xD4, 0xD0, + 0x92, 0x2F, 0xE0, 0x64, 0xA2, 0x00, 0x00, 0x00, 0x02, 0x4C, 0x45, 0x4E, 0x4F, 0x4E, 0x44, + 0x55, 0x50, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, + 0xE4, 0x2B, 0x1F, 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, + 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, 0x00, 0x00, 0x00, + 0x00, 0x11, 0xE1, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = { + 1, + + {2, + { + {"Send", "30 LENONDUPE"}, + {"Destination", "GCKUD4BHIYSAYHU7HBB5FDSW6CSYH3GSOUBPWD2KE7KNBERP4BSKEJDV"}, + + }}}; + + const op_summary details = { + 4, { - {"Send", "30 LENONDUPE"}, - {"Destination", - "GCKUD4BHIYSAYHU7HBB5FDSW6CSYH3GSOUBPWD2KE7KNBERP4BSKEJDV"}, - - }}}; - - const op_summary details = { - 4, - {{"Memo", "[none]"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Public"}, - {"Tx Source", - "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, - }}; - - test_tx(tx_data, sizeof(tx_data), &summary, &details); + {"Memo", "[none]"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Public"}, + {"Tx Source", "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, + }}; + + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_time_bounds(void **state) { - (void)state; - - const uint8_t tx_data[181] = { - 0x7A, 0xC3, 0x39, 0x97, 0x54, 0x4E, 0x31, 0x75, 0xD2, 0x66, 0xBD, 0x02, - 0x24, 0x39, 0xB2, 0x2C, 0xDB, 0x16, 0x50, 0x8C, 0x01, 0x16, 0x3F, 0x26, - 0xE5, 0xCB, 0x2A, 0x3E, 0x10, 0x45, 0xA9, 0x79, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, 0xE4, 0x2B, 0x1F, - 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, - 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, - 0x00, 0x00, 0x00, 0x64, 0x00, 0xC5, 0xB4, 0xA5, 0x00, 0x00, 0x00, 0x1D, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x95, 0x41, 0xF0, 0x27, 0x46, 0x24, 0x0C, 0x1E, 0x9F, 0x38, 0x43, 0xD2, - 0x8E, 0x56, 0xF0, 0xA5, 0x83, 0xEC, 0xD2, 0x75, 0x02, 0xFB, 0x0F, 0x4A, - 0x27, 0xD4, 0xD0, 0x92, 0x2F, 0xE0, 0x64, 0xA2, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x96, 0x80, 0x00, 0x00, 0x00, 0x00, - 0x00}; - - const ops_summary summary = { - 1, - - {2, + (void) state; + + const uint8_t tx_data[181] = { + 0x7A, 0xC3, 0x39, 0x97, 0x54, 0x4E, 0x31, 0x75, 0xD2, 0x66, 0xBD, 0x02, 0x24, 0x39, + 0xB2, 0x2C, 0xDB, 0x16, 0x50, 0x8C, 0x01, 0x16, 0x3F, 0x26, 0xE5, 0xCB, 0x2A, 0x3E, + 0x10, 0x45, 0xA9, 0x79, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, + 0x99, 0x8B, 0x75, 0xE4, 0x2B, 0x1F, 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, + 0x46, 0xDF, 0x12, 0xAD, 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, + 0x57, 0x13, 0x00, 0x00, 0x00, 0x64, 0x00, 0xC5, 0xB4, 0xA5, 0x00, 0x00, 0x00, 0x1D, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x95, 0x41, 0xF0, 0x27, 0x46, 0x24, 0x0C, 0x1E, + 0x9F, 0x38, 0x43, 0xD2, 0x8E, 0x56, 0xF0, 0xA5, 0x83, 0xEC, 0xD2, 0x75, 0x02, 0xFB, + 0x0F, 0x4A, 0x27, 0xD4, 0xD0, 0x92, 0x2F, 0xE0, 0x64, 0xA2, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x96, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = { + 1, + + {2, + { + {"Send", "1 XLM"}, + {"Destination", "GCKUD4BHIYSAYHU7HBB5FDSW6CSYH3GSOUBPWD2KE7KNBERP4BSKEJDV"}, + }}}; + + const op_summary details = { + 6, { - {"Send", "1 XLM"}, - {"Destination", - "GCKUD4BHIYSAYHU7HBB5FDSW6CSYH3GSOUBPWD2KE7KNBERP4BSKEJDV"}, - }}}; - - const op_summary details = { - 6, - {{"Memo ID", "33"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Public"}, - {"Time Bounds From", "50"}, - {"Time Bounds To", "100"}, - {"Tx Source", - "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, - }}; - - test_tx(tx_data, sizeof(tx_data), &summary, &details); + {"Memo ID", "33"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Public"}, + {"Time Bounds From", "50"}, + {"Time Bounds To", "100"}, + {"Tx Source", "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, + }}; + + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_op_source(void **state) { - (void)state; - - const uint8_t tx_data[201] = { - 0x7A, 0xC3, 0x39, 0x97, 0x54, 0x4E, 0x31, 0x75, 0xD2, 0x66, 0xBD, 0x02, - 0x24, 0x39, 0xB2, 0x2C, 0xDB, 0x16, 0x50, 0x8C, 0x01, 0x16, 0x3F, 0x26, - 0xE5, 0xCB, 0x2A, 0x3E, 0x10, 0x45, 0xA9, 0x79, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, 0xE4, 0x2B, 0x1F, - 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, - 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, - 0x00, 0x00, 0x00, 0x64, 0x00, 0xC5, 0xB4, 0xA5, 0x00, 0x00, 0x00, 0x1D, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, 0xE4, 0x2B, 0x1F, - 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, - 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x95, 0x41, 0xF0, 0x27, - 0x46, 0x24, 0x0C, 0x1E, 0x9F, 0x38, 0x43, 0xD2, 0x8E, 0x56, 0xF0, 0xA5, - 0x83, 0xEC, 0xD2, 0x75, 0x02, 0xFB, 0x0F, 0x4A, 0x27, 0xD4, 0xD0, 0x92, - 0x2F, 0xE0, 0x64, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0xE1, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - const ops_summary summary = { - 1, - - {3, + (void) state; + + const uint8_t tx_data[201] = { + 0x7A, 0xC3, 0x39, 0x97, 0x54, 0x4E, 0x31, 0x75, 0xD2, 0x66, 0xBD, 0x02, 0x24, 0x39, 0xB2, + 0x2C, 0xDB, 0x16, 0x50, 0x8C, 0x01, 0x16, 0x3F, 0x26, 0xE5, 0xCB, 0x2A, 0x3E, 0x10, 0x45, + 0xA9, 0x79, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, + 0xE4, 0x2B, 0x1F, 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, + 0x96, 0xF0, 0x10, 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, 0x00, 0x00, 0x00, + 0x64, 0x00, 0xC5, 0xB4, 0xA5, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x20, 0xDA, 0x99, 0x8B, 0x75, 0xE4, 0x2B, 0x1F, + 0x7F, 0x85, 0xD0, 0x75, 0xC1, 0x27, 0xF5, 0xB2, 0x46, 0xDF, 0x12, 0xAD, 0x96, 0xF0, 0x10, + 0xBC, 0xF7, 0xF7, 0x6F, 0x72, 0xB1, 0x6E, 0x57, 0x13, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x95, 0x41, 0xF0, 0x27, 0x46, 0x24, 0x0C, 0x1E, 0x9F, 0x38, 0x43, 0xD2, 0x8E, + 0x56, 0xF0, 0xA5, 0x83, 0xEC, 0xD2, 0x75, 0x02, 0xFB, 0x0F, 0x4A, 0x27, 0xD4, 0xD0, 0x92, + 0x2F, 0xE0, 0x64, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0xE1, 0xA3, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = { + 1, + + {3, + { + {"Send", "30 XLM"}, + {"Destination", "GCKUD4BHIYSAYHU7HBB5FDSW6CSYH3GSOUBPWD2KE7KNBERP4BSKEJDV"}, + {"Op Source", "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, + }}}; + + const op_summary details = { + 4, { - {"Send", "30 XLM"}, - {"Destination", - "GCKUD4BHIYSAYHU7HBB5FDSW6CSYH3GSOUBPWD2KE7KNBERP4BSKEJDV"}, - {"Op Source", - "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, - }}}; - - const op_summary details = { - 4, - {{"Memo ID", "16"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Public"}, - {"Tx Source", - "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, - }}; - - test_tx(tx_data, sizeof(tx_data), &summary, &details); + {"Memo ID", "16"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Public"}, + {"Tx Source", "GAQNVGMLOXSCWH37QXIHLQJH6WZENXYSVWLPAEF4673W64VRNZLRHMFM"}, + }}; + + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_create_account(void **state) { - (void)state; - - const uint8_t tx_data[153] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, 0xFD, 0x8D, 0xA2, 0x76, - 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, 0x11, - 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x4D, 0x31, 0xCF, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x58, 0x7C, 0x68, 0x88, 0x21, 0x8A, 0x7B, 0x78, 0xDC, 0x72, 0x05, 0xE8, - 0x03, 0xE8, 0xFA, 0x28, 0xFA, 0x0C, 0x7B, 0xDB, 0xCC, 0x24, 0xAE, 0xA2, - 0xEF, 0xE6, 0x77, 0x0C, 0x94, 0x86, 0x3D, 0xA5, 0x00, 0x00, 0x00, 0x00, - 0x3B, 0x9A, 0xCA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - const ops_summary summary = { - 1, - {2, + (void) state; + + const uint8_t tx_data[153] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, + 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, + 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, + 0x88, 0x4F, 0xFD, 0x8D, 0xA2, 0x76, 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, + 0x97, 0x88, 0x43, 0x11, 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, + 0x6D, 0x2B, 0x00, 0x00, 0x00, 0x64, 0x00, 0x4D, 0x31, 0xCF, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x7C, 0x68, 0x88, + 0x21, 0x8A, 0x7B, 0x78, 0xDC, 0x72, 0x05, 0xE8, 0x03, 0xE8, 0xFA, 0x28, 0xFA, 0x0C, + 0x7B, 0xDB, 0xCC, 0x24, 0xAE, 0xA2, 0xEF, 0xE6, 0x77, 0x0C, 0x94, 0x86, 0x3D, 0xA5, + 0x00, 0x00, 0x00, 0x00, 0x3B, 0x9A, 0xCA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = { + 1, + {2, + { + {"Create Account", "GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD"}, + {"Starting Balance", "100 XLM"}, + + }}}; + + const op_summary details = { + 4, { - {"Create Account", - "GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD"}, - {"Starting Balance", "100 XLM"}, - - }}}; - - const op_summary details = { - 4, - {{"Memo", "[none]"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, - }}; - - test_tx(tx_data, sizeof(tx_data), &summary, &details); + {"Memo", "[none]"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, + }}; + + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_account_merge(void **state) { - (void)state; - - const uint8_t tx_data[165] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, 0xFD, 0x8D, 0xA2, 0x76, - 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, 0x11, - 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x4D, 0x31, 0xCF, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0D, - 0x6D, 0x65, 0x72, 0x67, 0x65, 0x20, 0x61, 0x63, 0x63, 0x6F, 0x75, 0x6E, - 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x58, 0x7C, 0x68, 0x88, - 0x21, 0x8A, 0x7B, 0x78, 0xDC, 0x72, 0x05, 0xE8, 0x03, 0xE8, 0xFA, 0x28, - 0xFA, 0x0C, 0x7B, 0xDB, 0xCC, 0x24, 0xAE, 0xA2, 0xEF, 0xE6, 0x77, 0x0C, - 0x94, 0x86, 0x3D, 0xA5, 0x00, 0x00, 0x00, 0x00, 0x00}; - - const ops_summary summary = { - 1, - {2, - {{"Merge Account", - "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, - {"Destination", - "GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD"}, + (void) state; + + const uint8_t tx_data[165] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, 0xDD, + 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, + 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, 0xFD, + 0x8D, 0xA2, 0x76, 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, 0x11, + 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x4D, 0x31, 0xCF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x0D, 0x6D, 0x65, 0x72, 0x67, 0x65, 0x20, 0x61, 0x63, 0x63, + 0x6F, 0x75, 0x6E, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x58, 0x7C, 0x68, 0x88, 0x21, 0x8A, 0x7B, + 0x78, 0xDC, 0x72, 0x05, 0xE8, 0x03, 0xE8, 0xFA, 0x28, 0xFA, 0x0C, 0x7B, 0xDB, 0xCC, 0x24, + 0xAE, 0xA2, 0xEF, 0xE6, 0x77, 0x0C, 0x94, 0x86, 0x3D, 0xA5, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = { + 1, + {2, + { + {"Merge Account", "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, + {"Destination", "GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD"}, }}}; - const op_summary details = { - 4, - {{"Memo Text", "merge account"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, - }}; + const op_summary details = { + 4, + { + {"Memo Text", "merge account"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, + }}; - test_tx(tx_data, sizeof(tx_data), &summary, &details); + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_path_payment(void **state) { - (void)state; - - const uint8_t tx_data[361] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, - 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, - 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0F, - 0x64, 0x6F, 0x6C, 0x6C, 0x61, 0x72, 0x20, 0x74, 0x6F, 0x20, 0x6E, 0x61, - 0x69, 0x72, 0x61, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x55, 0x53, 0x44, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, - 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, - 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, - 0x00, 0x00, 0x00, 0x00, 0x1D, 0xCD, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x58, 0x7C, 0x68, 0x88, 0x21, 0x8A, 0x7B, 0x78, 0xDC, 0x72, 0x05, 0xE8, - 0x03, 0xE8, 0xFA, 0x28, 0xFA, 0x0C, 0x7B, 0xDB, 0xCC, 0x24, 0xAE, 0xA2, - 0xEF, 0xE6, 0x77, 0x0C, 0x94, 0x86, 0x3D, 0xA5, 0x00, 0x00, 0x00, 0x01, - 0x4E, 0x47, 0x4E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, - 0xBD, 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, - 0x23, 0x15, 0x27, 0x87, 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, - 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, 0x00, 0x29, 0xE8, 0xD6, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x59, 0x45, 0x4E, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, - 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, - 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, - 0x00, 0x00, 0x00, 0x01, 0x43, 0x41, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, - 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, 0xA5, 0x12, 0x61, 0xD9, - 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, 0x00, 0x00, - 0x00}; - - const ops_summary summary = { - 1, - {4, - {{"Send Max", "50 USD"}, - {"Destination", - "GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD"}, - {"Receive", "18000 NGN"}, - {"Via", "YEN, CAD"}, + (void) state; + + const uint8_t tx_data[361] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, 0xDD, + 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, + 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, + 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, + 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x0F, 0x64, 0x6F, 0x6C, 0x6C, 0x61, 0x72, 0x20, 0x74, 0x6F, + 0x20, 0x6E, 0x61, 0x69, 0x72, 0x61, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x55, 0x53, 0x44, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, + 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, + 0x70, 0x16, 0x48, 0x00, 0x00, 0x00, 0x00, 0x1D, 0xCD, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x58, 0x7C, 0x68, 0x88, 0x21, 0x8A, 0x7B, 0x78, 0xDC, 0x72, 0x05, 0xE8, 0x03, 0xE8, 0xFA, + 0x28, 0xFA, 0x0C, 0x7B, 0xDB, 0xCC, 0x24, 0xAE, 0xA2, 0xEF, 0xE6, 0x77, 0x0C, 0x94, 0x86, + 0x3D, 0xA5, 0x00, 0x00, 0x00, 0x01, 0x4E, 0x47, 0x4E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, + 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, + 0x23, 0x15, 0x27, 0x87, 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, + 0x48, 0x00, 0x00, 0x00, 0x29, 0xE8, 0xD6, 0x08, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x01, 0x59, 0x45, 0x4E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, + 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, + 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, 0x00, + 0x01, 0x43, 0x41, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, + 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, 0xA5, + 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, 0x00, 0x00, + 0x00}; + + const ops_summary summary = { + 1, + {4, + { + {"Send Max", "50 USD"}, + {"Destination", "GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD"}, + {"Receive", "18000 NGN"}, + {"Via", "YEN, CAD"}, }}}; - const op_summary details = { - 4, - {{"Memo Text", "dollar to naira"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, - }}; + const op_summary details = { + 4, + { + {"Memo Text", "dollar to naira"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, + }}; - test_tx(tx_data, sizeof(tx_data), &summary, &details); + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_set_data(void **state) { - (void)state; - - const uint8_t tx_data[149] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, 0xFD, 0x8D, 0xA2, 0x76, - 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, 0x11, - 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x4D, 0x31, 0xCF, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0B, - 0x6D, 0x61, 0x6E, 0x61, 0x67, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, - 0x00, 0x00, 0x00, 0x04, 0x6E, 0x61, 0x6D, 0x65, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x05, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00}; - - const ops_summary summary = { - 1, - {2, {{"Set Data", "name"}, {"Data Value", "dmFsdWU="}, }}}; - - const op_summary details = { - 4, - {{"Memo Text", "manage data"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, - }}; - - test_tx(tx_data, sizeof(tx_data), &summary, &details); + (void) state; + + const uint8_t tx_data[149] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, 0xDD, + 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, + 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, 0xFD, + 0x8D, 0xA2, 0x76, 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, 0x11, + 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x4D, 0x31, 0xCF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x0B, 0x6D, 0x61, 0x6E, 0x61, 0x67, 0x65, 0x20, 0x64, 0x61, + 0x74, 0x61, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, + 0x00, 0x00, 0x00, 0x04, 0x6E, 0x61, 0x6D, 0x65, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x05, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = {1, + {2, + { + {"Set Data", "name"}, + {"Data Value", "dmFsdWU="}, + }}}; + + const op_summary details = { + 4, + { + {"Memo Text", "manage data"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, + }}; + + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_remove_data(void **state) { - (void)state; - - const uint8_t tx_data[149] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, - 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, - 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0B, - 0x6D, 0x61, 0x6E, 0x61, 0x67, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, - 0x00, 0x00, 0x00, 0x0E, 0x6D, 0x61, 0x6E, 0x61, 0x67, 0x65, 0x64, 0x44, - 0x61, 0x74, 0x61, 0x4B, 0x65, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00}; - - const ops_summary summary = { - 1, {1, {{"Remove Data", "managedDataKey"}, }}}; - - const op_summary details = { - 4, - {{"Memo Text", "manage data"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, - }}; - - test_tx(tx_data, sizeof(tx_data), &summary, &details); + (void) state; + + const uint8_t tx_data[149] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, 0xDD, + 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, + 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, + 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, + 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x0B, 0x6D, 0x61, 0x6E, 0x61, 0x67, 0x65, 0x20, 0x64, 0x61, + 0x74, 0x61, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, + 0x00, 0x00, 0x00, 0x0E, 0x6D, 0x61, 0x6E, 0x61, 0x67, 0x65, 0x64, 0x44, 0x61, 0x74, 0x61, + 0x4B, 0x65, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = {1, + {1, + { + {"Remove Data", "managedDataKey"}, + }}}; + + const op_summary details = { + 4, + { + {"Memo Text", "manage data"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, + }}; + + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_change_trust(void **state) { - (void)state; - - const uint8_t tx_data[161] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, 0xFD, 0x8D, 0xA2, 0x76, - 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, 0x11, - 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x4D, 0x31, 0xCF, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, - 0x44, 0x55, 0x50, 0x45, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, - 0xFD, 0x8D, 0xA2, 0x76, 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, - 0x97, 0x88, 0x43, 0x11, 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, - 0xB8, 0x47, 0x6D, 0x2B, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x00, 0x00, 0x00, 0x00, 0x00}; - - const ops_summary summary = { - 1, - {2, {{"Change Trust", "DUPE@GBG..XESH"}, {"Trust Limit", "[maximum]"}, }}}; - - const op_summary details = { - 4, - {{"Memo", "[none]"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, - }}; - - test_tx(tx_data, sizeof(tx_data), &summary, &details); + (void) state; + + const uint8_t tx_data[161] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, 0xDD, + 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, + 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, 0xFD, + 0x8D, 0xA2, 0x76, 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, 0x11, + 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x4D, 0x31, 0xCF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, + 0x00, 0x00, 0x01, 0x44, 0x55, 0x50, 0x45, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, + 0xFD, 0x8D, 0xA2, 0x76, 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, + 0x11, 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, 0x7F, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = {1, + {2, + { + {"Change Trust", "DUPE@GBG..XESH"}, + {"Trust Limit", "[maximum]"}, + }}}; + + const op_summary details = { + 4, + { + {"Memo", "[none]"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, + }}; + + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_remove_trust(void **state) { - (void)state; - - const uint8_t tx_data[161] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, - 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, - 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, - 0x53, 0x4C, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, - 0xBD, 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, - 0x23, 0x15, 0x27, 0x87, 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, - 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00}; - - const ops_summary summary = { - 1, {1, {{"Remove Trust", "SLT@GAD..QN2I"}, }}}; - - const op_summary details = { - 4, - {{"Memo", "[none]"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, - }}; - - test_tx(tx_data, sizeof(tx_data), &summary, &details); + (void) state; + + const uint8_t tx_data[161] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, 0xDD, + 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, + 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, + 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, + 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, + 0x00, 0x00, 0x01, 0x53, 0x4C, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, + 0xBD, 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, + 0x87, 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = {1, + {1, + { + {"Remove Trust", "SLT@GAD..QN2I"}, + }}}; + + const op_summary details = { + 4, + { + {"Memo", "[none]"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, + }}; + + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_allow_trust(void **state) { - (void)state; - - const uint8_t tx_data[173] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, 0xFD, 0x8D, 0xA2, 0x76, - 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, 0x11, - 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x4D, 0x31, 0xCF, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0B, - 0x61, 0x6C, 0x6C, 0x6F, 0x77, 0x20, 0x74, 0x72, 0x75, 0x73, 0x74, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x58, 0x7C, 0x68, 0x88, 0x21, 0x8A, 0x7B, 0x78, - 0xDC, 0x72, 0x05, 0xE8, 0x03, 0xE8, 0xFA, 0x28, 0xFA, 0x0C, 0x7B, 0xDB, - 0xCC, 0x24, 0xAE, 0xA2, 0xEF, 0xE6, 0x77, 0x0C, 0x94, 0x86, 0x3D, 0xA5, - 0x00, 0x00, 0x00, 0x01, 0x4A, 0x50, 0x59, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00}; - - const ops_summary summary = { - 1, - {2, - {{"Allow Trust", "JPY"}, - {"Account ID", - "GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD"}, + (void) state; + + const uint8_t tx_data[173] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, 0xDD, + 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, + 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, 0xFD, + 0x8D, 0xA2, 0x76, 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, 0x11, + 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x4D, 0x31, 0xCF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x0B, 0x61, 0x6C, 0x6C, 0x6F, 0x77, 0x20, 0x74, 0x72, 0x75, + 0x73, 0x74, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x58, 0x7C, 0x68, 0x88, 0x21, 0x8A, 0x7B, 0x78, 0xDC, 0x72, 0x05, + 0xE8, 0x03, 0xE8, 0xFA, 0x28, 0xFA, 0x0C, 0x7B, 0xDB, 0xCC, 0x24, 0xAE, 0xA2, 0xEF, 0xE6, + 0x77, 0x0C, 0x94, 0x86, 0x3D, 0xA5, 0x00, 0x00, 0x00, 0x01, 0x4A, 0x50, 0x59, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = { + 1, + {2, + { + {"Allow Trust", "JPY"}, + {"Account ID", "GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD"}, }}}; - const op_summary details = { - 4, - {{"Memo Text", "allow trust"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, - }}; + const op_summary details = { + 4, + { + {"Memo Text", "allow trust"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, + }}; - test_tx(tx_data, sizeof(tx_data), &summary, &details); + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_revoke_trust(void **state) { - (void)state; - - const uint8_t tx_data[173] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, - 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, - 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, - 0x72, 0x65, 0x76, 0x6F, 0x6B, 0x65, 0x20, 0x74, 0x72, 0x75, 0x73, 0x74, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x58, 0x7C, 0x68, 0x88, 0x21, 0x8A, 0x7B, 0x78, - 0xDC, 0x72, 0x05, 0xE8, 0x03, 0xE8, 0xFA, 0x28, 0xFA, 0x0C, 0x7B, 0xDB, - 0xCC, 0x24, 0xAE, 0xA2, 0xEF, 0xE6, 0x77, 0x0C, 0x94, 0x86, 0x3D, 0xA5, - 0x00, 0x00, 0x00, 0x01, 0x4A, 0x50, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00}; - - const ops_summary summary = { - 1, - {2, - {{"Revoke Trust", "JPY"}, - {"Account ID", - "GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD"}, + (void) state; + + const uint8_t tx_data[173] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, 0xDD, + 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, + 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, + 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, + 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x72, 0x65, 0x76, 0x6F, 0x6B, 0x65, 0x20, 0x74, 0x72, + 0x75, 0x73, 0x74, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x58, 0x7C, 0x68, 0x88, 0x21, 0x8A, 0x7B, 0x78, 0xDC, 0x72, 0x05, + 0xE8, 0x03, 0xE8, 0xFA, 0x28, 0xFA, 0x0C, 0x7B, 0xDB, 0xCC, 0x24, 0xAE, 0xA2, 0xEF, 0xE6, + 0x77, 0x0C, 0x94, 0x86, 0x3D, 0xA5, 0x00, 0x00, 0x00, 0x01, 0x4A, 0x50, 0x59, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = { + 1, + {2, + { + {"Revoke Trust", "JPY"}, + {"Account ID", "GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD"}, }}}; - const op_summary details = { - 4, - {{"Memo Text", "revoke trust"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, - }}; + const op_summary details = { + 4, + { + {"Memo Text", "revoke trust"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, + }}; - test_tx(tx_data, sizeof(tx_data), &summary, &details); + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_create_offer(void **state) { - (void)state; - - const uint8_t tx_data[181] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, 0xFD, 0x8D, 0xA2, 0x76, - 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, 0x11, - 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x4D, 0x31, 0xCF, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x44, 0x55, 0x50, 0x45, 0x00, 0x00, 0x00, 0x00, - 0x4C, 0x19, 0x88, 0x4F, 0xFD, 0x8D, 0xA2, 0x76, 0xE5, 0xC2, 0xE0, 0x54, - 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, 0x11, 0xD5, 0xED, 0x2B, 0xD3, - 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, 0x00, 0x00, 0x00, 0x00, - 0xB2, 0xD0, 0x5E, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00}; - - const ops_summary summary = {1, - {4, - {{"Create Offer", "Type Active"}, - {"Buy", "DUPE@GBG..XESH"}, - {"Price", "0.3333333 DUPE"}, - {"Sell", "300 XLM"}, + (void) state; + + const uint8_t tx_data[181] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, + 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, + 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, + 0x88, 0x4F, 0xFD, 0x8D, 0xA2, 0x76, 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, + 0x97, 0x88, 0x43, 0x11, 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, + 0x6D, 0x2B, 0x00, 0x00, 0x00, 0x64, 0x00, 0x4D, 0x31, 0xCF, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x44, 0x55, 0x50, 0x45, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, 0xFD, 0x8D, + 0xA2, 0x76, 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, 0x11, + 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, 0x00, 0x00, + 0x00, 0x00, 0xB2, 0xD0, 0x5E, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = {1, + {4, + { + {"Create Offer", "Type Active"}, + {"Buy", "DUPE@GBG..XESH"}, + {"Price", "0.3333333 DUPE"}, + {"Sell", "300 XLM"}, }}}; - const op_summary details = { - 4, - {{"Memo", "[none]"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, - }}; + const op_summary details = { + 4, + { + {"Memo", "[none]"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, + }}; - test_tx(tx_data, sizeof(tx_data), &summary, &details); + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_create_offer2(void **state) { - (void)state; - - const uint8_t tx_data[181] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x8C, 0xDB, 0xE7, 0xA6, 0xF1, 0x6C, 0x26, 0x8C, - 0x3F, 0x3F, 0xCD, 0xAF, 0xDB, 0x12, 0x80, 0xED, 0x8B, 0x6D, 0x01, 0x53, - 0x32, 0xEA, 0x5D, 0x9F, 0x57, 0xA8, 0xF6, 0xB0, 0x60, 0x80, 0xD8, 0xE6, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x49, 0x96, 0x02, 0xD3, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, - 0x52, 0x4D, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC8, 0x67, 0x5D, 0xE2, - 0x3D, 0xEC, 0x5C, 0x63, 0x5B, 0xE0, 0xF5, 0x8C, 0xC9, 0xE4, 0x4E, 0xB8, - 0x1B, 0xF3, 0x44, 0x92, 0x5B, 0x53, 0xE3, 0xA7, 0xFC, 0xED, 0x68, 0x4B, - 0x11, 0x6F, 0x72, 0xAC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x54, 0x0B, 0xE4, 0x00, 0x00, 0xEE, 0xB6, 0x27, 0x00, 0x98, 0x96, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00}; - - const ops_summary summary = {1, - {4, - {{"Create Offer", "Type Active"}, - {"Buy", "XLM"}, - {"Price", "1.5644199 XLM"}, - {"Sell", "1000 RMT"}, + (void) state; + + const uint8_t tx_data[181] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, + 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, + 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x8C, 0xDB, + 0xE7, 0xA6, 0xF1, 0x6C, 0x26, 0x8C, 0x3F, 0x3F, 0xCD, 0xAF, 0xDB, 0x12, 0x80, 0xED, + 0x8B, 0x6D, 0x01, 0x53, 0x32, 0xEA, 0x5D, 0x9F, 0x57, 0xA8, 0xF6, 0xB0, 0x60, 0x80, + 0xD8, 0xE6, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x49, 0x96, 0x02, 0xD3, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x52, 0x4D, 0x54, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xC8, 0x67, 0x5D, 0xE2, 0x3D, 0xEC, 0x5C, 0x63, 0x5B, 0xE0, + 0xF5, 0x8C, 0xC9, 0xE4, 0x4E, 0xB8, 0x1B, 0xF3, 0x44, 0x92, 0x5B, 0x53, 0xE3, 0xA7, + 0xFC, 0xED, 0x68, 0x4B, 0x11, 0x6F, 0x72, 0xAC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x54, 0x0B, 0xE4, 0x00, 0x00, 0xEE, 0xB6, 0x27, 0x00, 0x98, 0x96, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = {1, + {4, + { + {"Create Offer", "Type Active"}, + {"Buy", "XLM"}, + {"Price", "1.5644199 XLM"}, + {"Sell", "1000 RMT"}, }}}; - const op_summary details = { - 4, - {{"Memo", "[none]"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GCGNXZ5G6FWCNDB7H7G27WYSQDWYW3IBKMZOUXM7K6UPNMDAQDMONKJ2"}, - }}; + const op_summary details = { + 4, + { + {"Memo", "[none]"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GCGNXZ5G6FWCNDB7H7G27WYSQDWYW3IBKMZOUXM7K6UPNMDAQDMONKJ2"}, + }}; - test_tx(tx_data, sizeof(tx_data), &summary, &details); + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_change_offer(void **state) { - (void)state; - - const uint8_t tx_data[181] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, - 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, - 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x53, 0x4C, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, - 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, 0xA5, 0x12, 0x61, 0xD9, - 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, 0x00, 0x00, - 0x77, 0x35, 0x94, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x98, 0x3C, 0x07, 0xF2, 0x00, 0x00, 0x00, 0x00, - 0x00}; - - const ops_summary summary = {1, - {4, - {{"Change Offer", "6849038322"}, - {"Buy", "SLT@GAD..QN2I"}, - {"Price", "1.6666666 SLT"}, - {"Sell", "200 XLM"}, + (void) state; + + const uint8_t tx_data[181] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, + 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, + 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, + 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, + 0x23, 0x15, 0x27, 0x87, 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, + 0x16, 0x48, 0x00, 0x00, 0x00, 0x64, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x53, 0x4C, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, + 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, + 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, + 0x00, 0x00, 0x77, 0x35, 0x94, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x98, 0x3C, 0x07, 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = {1, + {4, + { + {"Change Offer", "6849038322"}, + {"Buy", "SLT@GAD..QN2I"}, + {"Price", "1.6666666 SLT"}, + {"Sell", "200 XLM"}, }}}; - const op_summary details = { - 4, - {{"Memo", "[none]"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, - }}; + const op_summary details = { + 4, + { + {"Memo", "[none]"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, + }}; - test_tx(tx_data, sizeof(tx_data), &summary, &details); + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_remove_offer(void **state) { - (void)state; - - const uint8_t tx_data[181] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, - 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, - 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x53, 0x4C, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, - 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, 0xA5, 0x12, 0x61, 0xD9, - 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x00, 0x0C, 0x7D, 0xFE, 0x69, 0x00, 0x00, 0x00, 0x00, - 0x00}; - - const ops_summary summary = { - 1, {1, {{"Remove Offer", "209583721"}, }}}; - - const op_summary details = { - 4, - {{"Memo", "[none]"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, - }}; - - test_tx(tx_data, sizeof(tx_data), &summary, &details); + (void) state; + + const uint8_t tx_data[181] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, + 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, + 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, + 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, + 0x23, 0x15, 0x27, 0x87, 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, + 0x16, 0x48, 0x00, 0x00, 0x00, 0x64, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x53, 0x4C, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, + 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, + 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x0C, 0x7D, 0xFE, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = {1, + {1, + { + {"Remove Offer", "209583721"}, + }}}; + + const op_summary details = { + 4, + { + {"Memo", "[none]"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, + }}; + + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_passive_offer(void **state) { - (void)state; - - const uint8_t tx_data[189] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, - 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, - 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x20, 0x6F, 0x66, 0x66, 0x65, 0x72, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x53, 0x4C, 0x54, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, - 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, - 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, - 0x00, 0x00, 0x00, 0x02, 0x54, 0x0B, 0xE4, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00}; - - const ops_summary summary = {1, - {4, - {{"Create Offer", "Type Passive"}, - {"Buy", "SLT@GAD..QN2I"}, - {"Price", "0.25 SLT"}, - {"Sell", "1000 XLM"}, + (void) state; + + const uint8_t tx_data[189] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, 0xDD, + 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, + 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, + 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, + 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x20, 0x6F, 0x66, + 0x66, 0x65, 0x72, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x53, 0x4C, 0x54, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, + 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, + 0x70, 0x16, 0x48, 0x00, 0x00, 0x00, 0x02, 0x54, 0x0B, 0xE4, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = {1, + {4, + { + {"Create Offer", "Type Passive"}, + {"Buy", "SLT@GAD..QN2I"}, + {"Price", "0.25 SLT"}, + {"Sell", "1000 XLM"}, }}}; - const op_summary details = { - 4, - {{"Memo Text", "create offer"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, - }}; + const op_summary details = { + 4, + { + {"Memo Text", "create offer"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, + }}; - test_tx(tx_data, sizeof(tx_data), &summary, &details); + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_set_all_options(void **state) { - (void)state; - - const uint8_t tx_data[265] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, 0xFD, 0x8D, 0xA2, 0x76, - 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, 0x11, - 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x4D, 0x31, 0xCF, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0xCD, 0x4E, 0xB8, 0x0F, 0x3B, 0x5F, 0x4E, 0xD0, - 0x4B, 0x27, 0x62, 0x34, 0x9C, 0xDF, 0x7D, 0xF2, 0x58, 0x62, 0xCA, 0x11, - 0x5C, 0x4B, 0xCA, 0xED, 0x64, 0x7C, 0xA8, 0xC2, 0x28, 0xEC, 0xFD, 0x7B, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0F, 0x77, 0x77, 0x77, 0x2E, - 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xCD, 0x4E, 0xB8, 0x0F, - 0x3B, 0x5F, 0x4E, 0xD0, 0x4B, 0x27, 0x62, 0x34, 0x9C, 0xDF, 0x7D, 0xF2, - 0x58, 0x62, 0xCA, 0x11, 0x5C, 0x4B, 0xCA, 0xED, 0x64, 0x7C, 0xA8, 0xC2, - 0x28, 0xEC, 0xFD, 0x7B, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00}; - - const ops_summary summary = { - 1, - {11, - {{"Inflation Dest", - "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7"}, - {"Clear Flags", "Auth revocable, Auth immutable"}, - {"Set Flags", "Auth required"}, - {"Master Weight", "0"}, - {"Low Threshold", "1"}, - {"Medium Threshold", "2"}, - {"High Threshold", "3"}, - {"Home Domain", "www.example.com"}, - {"Add Signer", "Type Public Key"}, - {"Signer Key", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7"}, - {"Weight", "1"}, + (void) state; + + const uint8_t tx_data[265] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, 0xDD, + 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, + 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, 0xFD, + 0x8D, 0xA2, 0x76, 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, 0x11, + 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x4D, 0x31, 0xCF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xCD, 0x4E, 0xB8, 0x0F, 0x3B, 0x5F, 0x4E, 0xD0, + 0x4B, 0x27, 0x62, 0x34, 0x9C, 0xDF, 0x7D, 0xF2, 0x58, 0x62, 0xCA, 0x11, 0x5C, 0x4B, 0xCA, + 0xED, 0x64, 0x7C, 0xA8, 0xC2, 0x28, 0xEC, 0xFD, 0x7B, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, + 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xCD, + 0x4E, 0xB8, 0x0F, 0x3B, 0x5F, 0x4E, 0xD0, 0x4B, 0x27, 0x62, 0x34, 0x9C, 0xDF, 0x7D, 0xF2, + 0x58, 0x62, 0xCA, 0x11, 0x5C, 0x4B, 0xCA, 0xED, 0x64, 0x7C, 0xA8, 0xC2, 0x28, 0xEC, 0xFD, + 0x7B, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = { + 1, + {11, + { + {"Inflation Dest", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7"}, + {"Clear Flags", "Auth revocable, Auth immutable"}, + {"Set Flags", "Auth required"}, + {"Master Weight", "0"}, + {"Low Threshold", "1"}, + {"Medium Threshold", "2"}, + {"High Threshold", "3"}, + {"Home Domain", "www.example.com"}, + {"Add Signer", "Type Public Key"}, + {"Signer Key", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7"}, + {"Weight", "1"}, }}}; - const op_summary details = { - 4, - {{"Memo", "[none]"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, - }}; + const op_summary details = { + 4, + { + {"Memo", "[none]"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, + }}; - test_tx(tx_data, sizeof(tx_data), &summary, &details); + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_set_some_options(void **state) { - (void)state; - - const uint8_t tx_data[253] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, 0xFD, 0x8D, 0xA2, 0x76, - 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, 0x11, - 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x4D, 0x31, 0xCF, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0xCD, 0x4E, 0xB8, 0x0F, 0x3B, 0x5F, 0x4E, 0xD0, - 0x4B, 0x27, 0x62, 0x34, 0x9C, 0xDF, 0x7D, 0xF2, 0x58, 0x62, 0xCA, 0x11, - 0x5C, 0x4B, 0xCA, 0xED, 0x64, 0x7C, 0xA8, 0xC2, 0x28, 0xEC, 0xFD, 0x7B, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0F, 0x77, 0x77, 0x77, 0x2E, - 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xCD, 0x4E, 0xB8, 0x0F, - 0x3B, 0x5F, 0x4E, 0xD0, 0x4B, 0x27, 0x62, 0x34, 0x9C, 0xDF, 0x7D, 0xF2, - 0x58, 0x62, 0xCA, 0x11, 0x5C, 0x4B, 0xCA, 0xED, 0x64, 0x7C, 0xA8, 0xC2, - 0x28, 0xEC, 0xFD, 0x7B, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00}; - - const ops_summary summary = { - 1, - {8, - {{"Inflation Dest", - "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7"}, - {"Set Flags", "Auth required"}, - {"Low Threshold", "1"}, - {"High Threshold", "3"}, - {"Home Domain", "www.example.com"}, - {"Add Signer", "Type Public Key"}, - {"Signer Key", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7"}, - {"Weight", "1"}, + (void) state; + + const uint8_t tx_data[253] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, 0xDD, + 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, + 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x19, 0x88, 0x4F, 0xFD, + 0x8D, 0xA2, 0x76, 0xE5, 0xC2, 0xE0, 0x54, 0xBF, 0x43, 0xC3, 0xA1, 0x97, 0x88, 0x43, 0x11, + 0xD5, 0xED, 0x2B, 0xD3, 0xC8, 0xF8, 0x13, 0xB1, 0xB8, 0x47, 0x6D, 0x2B, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x4D, 0x31, 0xCF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xCD, 0x4E, 0xB8, 0x0F, 0x3B, 0x5F, 0x4E, 0xD0, + 0x4B, 0x27, 0x62, 0x34, 0x9C, 0xDF, 0x7D, 0xF2, 0x58, 0x62, 0xCA, 0x11, 0x5C, 0x4B, 0xCA, + 0xED, 0x64, 0x7C, 0xA8, 0xC2, 0x28, 0xEC, 0xFD, 0x7B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x65, 0x78, 0x61, + 0x6D, 0x70, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0xCD, 0x4E, 0xB8, 0x0F, 0x3B, 0x5F, 0x4E, 0xD0, 0x4B, 0x27, 0x62, 0x34, 0x9C, + 0xDF, 0x7D, 0xF2, 0x58, 0x62, 0xCA, 0x11, 0x5C, 0x4B, 0xCA, 0xED, 0x64, 0x7C, 0xA8, 0xC2, + 0x28, 0xEC, 0xFD, 0x7B, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = { + 1, + {8, + { + {"Inflation Dest", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7"}, + {"Set Flags", "Auth required"}, + {"Low Threshold", "1"}, + {"High Threshold", "3"}, + {"Home Domain", "www.example.com"}, + {"Add Signer", "Type Public Key"}, + {"Signer Key", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7"}, + {"Weight", "1"}, }}}; - const op_summary details = { - 4, - {{"Memo", "[none]"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, - }}; + const op_summary details = { + 4, + { + {"Memo", "[none]"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GBGBTCCP7WG2E5XFYLQFJP2DYOQZPCCDCHK62K6TZD4BHMNYI5WSXESH"}, + }}; - test_tx(tx_data, sizeof(tx_data), &summary, &details); + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_inflation(void **state) { - (void)state; - - const uint8_t tx_data[141] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, - 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, - 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1C, - 0x6D, 0x61, 0x78, 0x69, 0x6D, 0x75, 0x6D, 0x20, 0x6D, 0x65, 0x6D, 0x6F, - 0x20, 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x20, 0x32, 0x38, 0x20, 0x63, - 0x68, 0x61, 0x72, 0x73, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00}; - - const ops_summary summary = {1, - {1, {"", ""}}}; - - const op_summary details = { - 4, - {{"Memo Text", "maximum memo length 28 chars"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, - }}; - - test_tx(tx_data, sizeof(tx_data), &summary, &details); + (void) state; + + const uint8_t tx_data[141] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, 0xDD, + 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, + 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, + 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, + 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x1C, 0x6D, 0x61, 0x78, 0x69, 0x6D, 0x75, 0x6D, 0x20, 0x6D, + 0x65, 0x6D, 0x6F, 0x20, 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x20, 0x32, 0x38, 0x20, 0x63, + 0x68, 0x61, 0x72, 0x73, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x00, 0x00}; + + const ops_summary summary = {1, {1, {"", ""}}}; + + const op_summary details = { + 4, + { + {"Memo Text", "maximum memo length 28 chars"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, + }}; + + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_multi_op(void **state) { - (void)state; - - const uint8_t tx_data[213] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, 0x54, 0x37, 0x53, - 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, - 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, - 0x00, 0x00, 0x00, 0xC8, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, - 0x6D, 0x75, 0x6C, 0x74, 0x69, 0x2D, 0x6F, 0x70, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, - 0x58, 0x7C, 0x68, 0x88, 0x21, 0x8A, 0x7B, 0x78, 0xDC, 0x72, 0x05, 0xE8, - 0x03, 0xE8, 0xFA, 0x28, 0xFA, 0x0C, 0x7B, 0xDB, 0xCC, 0x24, 0xAE, 0xA2, - 0xEF, 0xE6, 0x77, 0x0C, 0x94, 0x86, 0x3D, 0xA5, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x58, 0x7C, 0x68, 0x88, - 0x21, 0x8A, 0x7B, 0x78, 0xDC, 0x72, 0x05, 0xE8, 0x03, 0xE8, 0xFA, 0x28, - 0xFA, 0x0C, 0x7B, 0xDB, 0xCC, 0x24, 0xAE, 0xA2, 0xEF, 0xE6, 0x77, 0x0C, - 0x94, 0x86, 0x3D, 0xA5, 0x00, 0x00, 0x00, 0x01, 0x4A, 0x50, 0x59, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00}; - - const ops_summary summary = { - 2, - { - {2, - {{"Merge Account", - "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, - {"Destination", - "GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD"}, + (void) state; + + const uint8_t tx_data[213] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, 0xDD, + 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, + 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x06, 0x5A, 0xDB, 0x74, 0xBD, + 0x54, 0x37, 0x53, 0xDA, 0xF5, 0xE8, 0xFC, 0x0D, 0x34, 0xD0, 0x4A, 0x23, 0x15, 0x27, 0x87, + 0xA5, 0x12, 0x61, 0xD9, 0xF2, 0x13, 0x5E, 0x5E, 0x47, 0x70, 0x16, 0x48, 0x00, 0x00, 0x00, + 0xC8, 0x00, 0x63, 0x14, 0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x6D, 0x75, 0x6C, 0x74, 0x69, 0x2D, 0x6F, 0x70, 0x00, + 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x58, 0x7C, 0x68, 0x88, 0x21, 0x8A, 0x7B, 0x78, 0xDC, 0x72, 0x05, 0xE8, 0x03, 0xE8, 0xFA, + 0x28, 0xFA, 0x0C, 0x7B, 0xDB, 0xCC, 0x24, 0xAE, 0xA2, 0xEF, 0xE6, 0x77, 0x0C, 0x94, 0x86, + 0x3D, 0xA5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x58, + 0x7C, 0x68, 0x88, 0x21, 0x8A, 0x7B, 0x78, 0xDC, 0x72, 0x05, 0xE8, 0x03, 0xE8, 0xFA, 0x28, + 0xFA, 0x0C, 0x7B, 0xDB, 0xCC, 0x24, 0xAE, 0xA2, 0xEF, 0xE6, 0x77, 0x0C, 0x94, 0x86, 0x3D, + 0xA5, 0x00, 0x00, 0x00, 0x01, 0x4A, 0x50, 0x59, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00}; + + const ops_summary summary = { + 2, + {{2, + { + {"Merge Account", "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, + {"Destination", "GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD"}, }}, {2, - {{"Allow Trust", "JPY"}, - {"Account ID", - "GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD"}, + { + {"Allow Trust", "JPY"}, + {"Account ID", "GBMHY2EIEGFHW6G4OIC6QA7I7IUPUDD33PGCJLVC57THODEUQY62KNHD"}, }}}}; - const op_summary details = { - 4, - {{"Memo Text", "multi-op"}, - {"Fee", "0.00002 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, - }}; + const op_summary details = { + 4, + { + {"Memo Text", "multi-op"}, + {"Fee", "0.00002 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I"}, + }}; - test_tx(tx_data, sizeof(tx_data), &summary, &details); + test_tx(tx_data, sizeof(tx_data), &summary, &details); } static void test_tx_bump_sequence(void **state) { - (void)state; - - const uint8_t tx_data[113] = { - 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, - 0x82, 0x03, 0xDD, 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, - 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x8C, 0xDB, 0xE7, 0xA6, 0xF1, 0x6C, 0x26, 0x8C, - 0x3F, 0x3F, 0xCD, 0xAF, 0xDB, 0x12, 0x80, 0xED, 0x8B, 0x6D, 0x01, 0x53, - 0x32, 0xEA, 0x5D, 0x9F, 0x57, 0xA8, 0xF6, 0xB0, 0x60, 0x80, 0xD8, 0xE6, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x49, 0x96, 0x02, 0xD3, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x02, 0x00}; - - const ops_summary summary = { - 1, {1, {{"Bump Sequence", "2"}, }}}; - - const op_summary details = { - 4, - {{"Memo", "[none]"}, - {"Fee", "0.00001 XLM"}, - {"Network", "Test"}, - {"Tx Source", - "GCGNXZ5G6FWCNDB7H7G27WYSQDWYW3IBKMZOUXM7K6UPNMDAQDMONKJ2"}, - }}; - - test_tx(tx_data, sizeof(tx_data), &summary, &details); + (void) state; + + const uint8_t tx_data[113] = { + 0xCE, 0xE0, 0x30, 0x2D, 0x59, 0x84, 0x4D, 0x32, 0xBD, 0xCA, 0x91, 0x5C, 0x82, 0x03, 0xDD, + 0x44, 0xB3, 0x3F, 0xBB, 0x7E, 0xDC, 0x19, 0x05, 0x1E, 0xA3, 0x7A, 0xBE, 0xDF, 0x28, 0xEC, + 0xD4, 0x72, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x8C, 0xDB, 0xE7, 0xA6, 0xF1, + 0x6C, 0x26, 0x8C, 0x3F, 0x3F, 0xCD, 0xAF, 0xDB, 0x12, 0x80, 0xED, 0x8B, 0x6D, 0x01, 0x53, + 0x32, 0xEA, 0x5D, 0x9F, 0x57, 0xA8, 0xF6, 0xB0, 0x60, 0x80, 0xD8, 0xE6, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x00, 0x00, 0x00, 0x49, 0x96, 0x02, 0xD3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00}; + + const ops_summary summary = {1, + {1, + { + {"Bump Sequence", "2"}, + }}}; + + const op_summary details = { + 4, + { + {"Memo", "[none]"}, + {"Fee", "0.00001 XLM"}, + {"Network", "Test"}, + {"Tx Source", "GCGNXZ5G6FWCNDB7H7G27WYSQDWYW3IBKMZOUXM7K6UPNMDAQDMONKJ2"}, + }}; + + test_tx(tx_data, sizeof(tx_data), &summary, &details); } int main() { + // clang-format off const struct CMUnitTest tests[] = { cmocka_unit_test(test_tx_simple), cmocka_unit_test(test_tx_memo_id), @@ -1242,7 +1166,7 @@ int main() { cmocka_unit_test(test_tx_inflation), cmocka_unit_test(test_tx_multi_op), cmocka_unit_test(test_tx_bump_sequence), - }; - return cmocka_run_group_tests(tests, NULL, NULL); + // clang-format on + return cmocka_run_group_tests(tests, NULL, NULL); } \ No newline at end of file diff --git a/test/test_printers.c b/test/test_printers.c index 64dc2de4..80aab331 100644 --- a/test/test_printers.c +++ b/test/test_printers.c @@ -23,78 +23,78 @@ #include "stellar_api.h" void test_print_amount(void **state) { - (void)state; - - char printed[24]; - const char *asset = "XLM"; - - print_amount(1, asset, printed); - assert_string_equal(printed, "0.0000001 XLM"); - print_amount(10000000, asset, printed); - assert_string_equal(printed, "1 XLM"); - print_amount(100000000000001, asset, printed); - assert_string_equal(printed, "10000000.0000001 XLM"); - print_amount(100000001, asset, printed); - assert_string_equal(printed, "10.0000001 XLM"); - print_amount(100000001000000, asset, printed); - assert_string_equal(printed, "10000000.1 XLM"); + (void) state; + + char printed[24]; + const char *asset = "XLM"; + + print_amount(1, asset, printed); + assert_string_equal(printed, "0.0000001 XLM"); + print_amount(10000000, asset, printed); + assert_string_equal(printed, "1 XLM"); + print_amount(100000000000001, asset, printed); + assert_string_equal(printed, "10000000.0000001 XLM"); + print_amount(100000001, asset, printed); + assert_string_equal(printed, "10.0000001 XLM"); + print_amount(100000001000000, asset, printed); + assert_string_equal(printed, "10000000.1 XLM"); } void test_print_uint(void **state) { - (void)state; + (void) state; - char printed[24]; - print_uint(1230, printed); - assert_string_equal(printed, "1230"); + char printed[24]; + print_uint(1230, printed); + assert_string_equal(printed, "1230"); } void test_print_int(void **state) { - (void)state; + (void) state; - char printed[24]; - print_int(1230, printed); - assert_string_equal(printed, "1230"); - print_int(-1230, printed); - assert_string_equal(printed, "-1230"); + char printed[24]; + print_int(1230, printed); + assert_string_equal(printed, "1230"); + print_int(-1230, printed); + assert_string_equal(printed, "-1230"); } void test_print_summary(void **state) { - (void)state; - - char summary[27]; - print_summary("GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I", - summary, 12, 12); - assert_string_equal(summary, "GADFVW3UXVKD..4XSHOALEQN2I"); - print_summary("GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I", - summary, 6, 6); - assert_string_equal(summary, "GADFVW..LEQN2I"); + (void) state; + + char summary[27]; + print_summary("GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I", summary, 12, 12); + assert_string_equal(summary, "GADFVW3UXVKD..4XSHOALEQN2I"); + print_summary("GADFVW3UXVKDOU626XUPYDJU2BFCGFJHQ6SREYOZ6IJV4XSHOALEQN2I", summary, 6, 6); + assert_string_equal(summary, "GADFVW..LEQN2I"); } void test_print_binary(void **state) { - (void)state; + (void) state; - const uint8_t binary[32] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; - char hex[16]; + const uint8_t binary[32] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; + char hex[16]; - print_binary_summary(binary, hex, 32); - assert_string_equal(hex, "0x00010203..1C1D1E1F"); + print_binary_summary(binary, hex, 32); + assert_string_equal(hex, "0x00010203..1C1D1E1F"); } void test_base64_encode(void **state) { - (void)state; + (void) state; - char base64[20]; - base64_encode((uint8_t *)"starlight", 9, base64); - assert_string_equal(base64, "c3RhcmxpZ2h0"); + char base64[20]; + base64_encode((uint8_t *) "starlight", 9, base64); + assert_string_equal(base64, "c3RhcmxpZ2h0"); } int main() { - const struct CMUnitTest tests[] = { - cmocka_unit_test(test_print_amount), cmocka_unit_test(test_print_uint), - cmocka_unit_test(test_print_int), cmocka_unit_test(test_print_summary), - cmocka_unit_test(test_print_binary), cmocka_unit_test(test_base64_encode), - }; - return cmocka_run_group_tests(tests, NULL, NULL); + const struct CMUnitTest tests[] = { + cmocka_unit_test(test_print_amount), + cmocka_unit_test(test_print_uint), + cmocka_unit_test(test_print_int), + cmocka_unit_test(test_print_summary), + cmocka_unit_test(test_print_binary), + cmocka_unit_test(test_base64_encode), + }; + return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/test/test_utils.c b/test/test_utils.c index dc23e274..672d0d61 100644 --- a/test/test_utils.c +++ b/test/test_utils.c @@ -19,36 +19,35 @@ #include int read_file(char *filename, uint8_t *buffer, int maxlen) { - int size, read; - FILE *handler = fopen(filename, "r"); + int size, read; + FILE *handler = fopen(filename, "r"); - if (handler) { + if (handler) { + // calculate the needed buffer size + fseek(handler, 0, SEEK_END); + size = ftell(handler); + rewind(handler); - // calculate the needed buffer size - fseek(handler, 0, SEEK_END); - size = ftell(handler); - rewind(handler); - - if (size/2 > maxlen) { - printf("Buffer too small\n"); - } + if (size / 2 > maxlen) { + printf("Buffer too small\n"); + } - char *hex = (char*) malloc(size); - read = fread(hex, 1, size, handler); - fclose(handler); + char *hex = (char *) malloc(size); + read = fread(hex, 1, size, handler); + fclose(handler); - if (size != read) { - printf("Failed to read file\n"); - free(hex); - hex = NULL; - return 0; - } + if (size != read) { + printf("Failed to read file\n"); + free(hex); + hex = NULL; + return 0; + } - int i; - for (i = 0; i < maxlen; i++) { - sscanf(hex + 2*i, "%2hhx", &buffer[i]); - } - return read / 2; + int i; + for (i = 0; i < maxlen; i++) { + sscanf(hex + 2 * i, "%2hhx", &buffer[i]); + } + return read / 2; } else { printf("No such file\n"); return 0;