├── .github
├── stale.yml
└── workflows
│ └── build.yml
├── .gitignore
├── CHANGELOG.md
├── LICENSE
├── Makefile
├── README.md
├── Vagrantfile
├── ark.png
├── banner.png
├── docs
├── ARK_BASED_CHAIN_SUPPORT.md
├── INSTALLATION.md
├── PAYLOADS.md
├── RESOURCES.md
└── fixtures
│ ├── all.json
│ ├── type_0.json
│ ├── type_0.md
│ ├── type_0_multi_sign.json
│ ├── type_0_vendorfield.json
│ ├── type_0_vendorfield.md
│ ├── type_0_vendorfield_multi_sign.json
│ ├── type_1.json
│ ├── type_1.md
│ ├── type_10.json
│ ├── type_10.md
│ ├── type_10_multi_sign.json
│ ├── type_2.json
│ ├── type_2.md
│ ├── type_3.json
│ ├── type_3.md
│ ├── type_3_multi_sign.json
│ ├── type_4.json
│ ├── type_4.md
│ ├── type_5.json
│ ├── type_5.md
│ ├── type_5_multi_sign.json
│ ├── type_6.json
│ ├── type_6.md
│ ├── type_7.json
│ ├── type_7.md
│ ├── type_8.json
│ ├── type_8.md
│ ├── type_8_multi_sign.json
│ ├── type_8_vendorfield.json
│ ├── type_8_vendorfield.md
│ ├── type_8_vendorfield_multi_sign.json
│ ├── type_9.json
│ ├── type_9.md
│ └── type_9_multi_sign.json
├── examples
├── README.md
├── all.sh
├── example_helper.py
├── message.sh
├── multi_signature.sh
├── v1.sh
└── v2.sh
├── glyphs
├── badge_ark.gif
├── badge_ripple.gif
├── badge_transaction.gif
├── icon.gif
├── icon_ark.gif
├── icon_back.gif
├── icon_back_x.gif
├── icon_certificate.gif
├── icon_coggle.gif
├── icon_crossmark.gif
├── icon_dashboard.gif
├── icon_dashboard_x.gif
├── icon_down.gif
├── icon_eye.gif
├── icon_left.gif
├── icon_right.gif
├── icon_toggle_reset.gif
├── icon_toggle_set.gif
├── icon_up.gif
├── icon_validate_14.gif
└── icon_warning.gif
├── icons
├── ark.png
├── icon.gif
├── nanos_app_ark.gif
└── nanox_app_ark.gif
├── nanox_app_ark.gif
├── scripts
├── provision.sh
├── rebuild.sh
├── rebuild_nanos.sh
├── rebuild_nanox.sh
└── udev.sh
└── src
├── approval.c
├── approval.h
├── constants.h
├── crypto
├── hashing.c
├── hashing.h
├── keys.c
├── keys.h
├── schnorr_bcrypto_410.c
├── schnorr_bcrypto_410.h
├── signing.c
└── signing.h
├── display
├── context.c
├── context.h
├── display.h
├── nano.c
└── nano.h
├── io.c
├── io.h
├── main.c
├── operations.c
├── operations.h
├── operations
├── message_op.h
├── transaction_op.h
└── transactions
│ ├── deserializer.c
│ ├── deserializer.h
│ ├── deserializer_v1.c
│ ├── deserializer_v1.h
│ ├── offsets.h
│ ├── transaction.h
│ ├── types
│ ├── assets.h
│ ├── htlc_claim.c
│ ├── htlc_claim.h
│ ├── htlc_lock.c
│ ├── htlc_lock.h
│ ├── htlc_refund.c
│ ├── htlc_refund.h
│ ├── ipfs.c
│ ├── ipfs.h
│ ├── multi_signature.c
│ ├── multi_signature.h
│ ├── signatures.c
│ ├── signatures.h
│ ├── transfer.c
│ ├── transfer.h
│ ├── types.h
│ ├── vote.c
│ └── vote.h
│ └── ux
│ ├── display_ux.c
│ ├── display_ux.h
│ ├── htlc_claim_ux.c
│ ├── htlc_claim_ux.h
│ ├── htlc_lock_ux.c
│ ├── htlc_lock_ux.h
│ ├── htlc_refund_ux.c
│ ├── htlc_refund_ux.h
│ ├── ipfs_ux.c
│ ├── ipfs_ux.h
│ ├── multi_signature_ux.c
│ ├── multi_signature_ux.h
│ ├── signatures_ux.c
│ ├── signatures_ux.h
│ ├── transfer_ux.c
│ ├── transfer_ux.h
│ ├── vendorfield_ux.c
│ ├── vendorfield_ux.h
│ ├── vote_ux.c
│ └── vote_ux.h
├── platform.h
└── utils
├── base58.c
├── base58.h
├── hex.c
├── hex.h
├── print.h
├── str.c
├── str.h
├── unpack.h
└── utils.h
/.github/stale.yml:
--------------------------------------------------------------------------------
1 | _extends: .github
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # IDE
2 | .vscode
3 |
4 | # Ledger/BOLOS SDK
5 | apps
6 | bin
7 | debug
8 | dep
9 | obj
10 | src/glyphs.c
11 | src/glyphs.h
12 |
13 | # OS
14 | .DS_Store
15 |
16 | # Vagrant
17 | *console.log
18 | .vagrant
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # ARK Ledger
3 |
4 |
5 |
6 |
7 | > A simple Ledger NanoS/NanoX app for the ARK Blockchain.
8 |
9 | [](https://github.com/ArkEcosystem/ledger/actions)
10 | [](https://opensource.org/licenses/MIT)
11 |
12 |
13 | * [The Ledger ARK app](#the-ledger-ark-app)
14 | * [Security](#security)
15 | * [Credits](#credits)
16 | * [License](#license)
17 |
18 |
19 | ## The Ledger ARK app
20 |
21 | This app is written in C for the Ledger NanoS and NanoX devices.
22 |
23 | While the Ledger ARK app _is_ compatible with the Ledger NanoX, there is currently no way to load a custom app until LedgerHQ releases the nanox-secure-sdk.
24 |
25 | The Ledger NanoS is fully supported for development and flashing.
26 |
27 | For more development resources or environment installation and usage, see the following links:
28 |
29 | * [ARK Ledger App Example Payloads](./docs/PAYLOADS.md)
30 | * [Development Resources](./docs/RESOURCES.md)
31 | * [Development Environment Installation and Usage](./docs/INSTALLATION.md)
32 |
33 | ## Security
34 |
35 | If you discover a security vulnerability within this package, please send an e-mail to security@ark.io. All security vulnerabilities will be promptly addressed.
36 |
37 | ## Credits
38 |
39 | This project exists thanks to all the people who [contribute](../../contributors).
40 |
41 | ## License
42 |
43 | [MIT](LICENSE) © [ARK Ecosystem](https://ark.io)
44 |
--------------------------------------------------------------------------------
/Vagrantfile:
--------------------------------------------------------------------------------
1 | Vagrant.configure("2") do |config|
2 |
3 | # Specify the OS VM Box
4 | config.vm.box = "ubuntu/bionic64"
5 | config.vm.box_version = "20190814.0.0"
6 |
7 | # Sync the 'app', 'examples', 'glyphs', and 'src' directories
8 | config.vm.synced_folder("apps/", "/home/vagrant/apps/",
9 | id: "appsdir",
10 | :create => true,
11 | type: "virtualbox")
12 | config.vm.synced_folder("examples/", "/home/vagrant/apps/ledger-app-ark/examples/",
13 | id: "examplesdir",
14 | :create => true,
15 | type: "virtualbox")
16 | config.vm.synced_folder("glyphs/", "/home/vagrant/apps/ledger-app-ark/glyphs/",
17 | id: "glyphsdir",
18 | :create => true,
19 | type: "virtualbox")
20 | config.vm.synced_folder("src/", "/home/vagrant/apps/ledger-app-ark/src/",
21 | id: "srcdir",
22 | :create => true,
23 | type: "virtualbox")
24 |
25 | # Copy scripts and the Makefile to the VM
26 | config.vm.provision("file",
27 | source: "./scripts/rebuild.sh",
28 | destination: "/home/vagrant/apps/ledger-app-ark/scripts/")
29 | config.vm.provision("file",
30 | source: "./scripts/rebuild_nanos.sh",
31 | destination: "/home/vagrant/apps/ledger-app-ark/scripts/")
32 | config.vm.provision("file",
33 | source: "./scripts/rebuild_nanox.sh",
34 | destination: "/home/vagrant/apps/ledger-app-ark/scripts/")
35 | config.vm.provision("file",
36 | source: "./scripts/udev.sh",
37 | destination: "/home/vagrant/apps/ledger-app-ark/scripts/")
38 | config.vm.provision("file",
39 | source: "./Makefile",
40 | destination: "/home/vagrant/apps/ledger-app-ark/")
41 |
42 | # Copy Icons
43 | config.vm.provision("file",
44 | source: "./icons/nanos_app_ark.gif",
45 | destination: "/home/vagrant/apps/ledger-app-ark/icons/")
46 | config.vm.provision("file",
47 | source: "./icons/nanox_app_ark.gif",
48 | destination: "/home/vagrant/apps/ledger-app-ark/icons/")
49 |
50 | # VM configuration
51 | config.vm.provider "virtualbox" do |v|
52 | v.name = "ARK Ledger App Development Box"
53 | v.customize ["modifyvm", :id, "--memory", "1024"]
54 |
55 | # Configure the Ledger Nano S/X USB connection
56 | v.customize ["modifyvm", :id, "--usb", "on"]
57 | v.customize ["modifyvm", :id, "--usbehci", "on"]
58 | v.customize ["usbfilter", "add", "0",
59 | "--target", :id,
60 | "--name", "Ledger Nano S/X",
61 | "--manufacturer", "Ledger",
62 | "--product", "Nano S/X"]
63 | end
64 |
65 | # Run the Provisioning script
66 | config.vm.provision "shell" do |s|
67 | s.path = "scripts/provision.sh"
68 | end
69 | end
70 |
--------------------------------------------------------------------------------
/ark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/ark.png
--------------------------------------------------------------------------------
/banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/banner.png
--------------------------------------------------------------------------------
/docs/ARK_BASED_CHAIN_SUPPORT.md:
--------------------------------------------------------------------------------
1 |
2 | # ARK-Based Chain Support
3 |
4 | Ledger devices make use of [BIP32 / Hierarchical Deterministic (HD) Wallets](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) and require that all [Slip44](https://github.com/satoshilabs/slips/blob/master/slip-0044.md) paths be explicitly-defined in an App's `Makefile`.
5 |
6 | ## What Does This Mean?
7 |
8 | This means that while using the ARK App, attempting any PublicKey or Signing operations who's BIP32 path makes use of a Slip44 other than `1'` (ARK Devnet) or `111'` (ARK Mainnet) will be rejected.
9 |
10 | ## Why is This Enforced?
11 |
12 | While not ideal for ARK-based chains, Ledger has opted to enforce this rule as a security measure to mitigate cross-chain attacks.
13 |
14 | > more info: [Ledger Security Bulletin 014: Path derivation too permissive in Bitcoin derivative apps](https://donjon.ledger.com/lsb/014/#4)
15 |
16 | ## What Options Do ARK-Based Chains Have?
17 |
18 | As a result, ARK-based chains have 2 options for being supported by Ledger:
19 |
20 | 1. *Open a PR in the ARK App's Repo adding your network's Slip44.
21 | 2. Fork the ARK App, customize it using your network's Slip44 and branding, then submit it to Ledger for [approval](https://developers.ledger.com/docs/nano-app/introduction/#submit-your-app-for-the-ledger-live-manager).
22 |
23 | While an ARK-based chain _could_ technically reuse `111'` for their Slip44, it is not recommended as it's officially registered and reserved for ARK's Mainnet and could result in a loss of user funds.
24 |
25 | _*note that while opening a PR is always welcome, there is no guarantee that it will be accepted. All decisions are made on a case-by-case basis and done solely at our discretion._
26 |
--------------------------------------------------------------------------------
/docs/RESOURCES.md:
--------------------------------------------------------------------------------
1 |
2 | # ARK Ledger App Development Resources
3 |
4 | This section contains some useful resources for learning about Ledger and embedded development—which is especially nuanced and requires additional considerations beyond typical crypto development.
5 |
6 | This is by no means an exhaustive list, but aims to provide some key materials.
7 |
8 |
9 | * [The Ledger Docs](#the-ledger-docs)
10 | * [The NanoS Secure SDK](#the-nanos-secure-sdk)
11 | * [More Ledger Apps](#the-nanos-secure-sdk)
12 | * [Further Reading](#further-reading)
13 |
14 |
15 | ## The Ledger Docs
16 |
17 | The Ledger Docs are by far the best place to start.
18 |
19 | They cover anything from how a Ledger works, to publishing a Ledger Application, to secure app development.
20 |
21 | ***Be sure to read the Ledger Security Guidelines.**
22 |
23 | It covers many concerns that would typically not be obvious, and is something that should be read more than once.
24 |
25 | * [Ledger Documentation Hub](https://ledger.readthedocs.io/en/latest/index.html)
26 | * [Ledger Documentation Hub: BOLOS](https://ledger.readthedocs.io/en/latest/bolos/features.html)
27 | * [***Ledger Documentation Hub: Security Guidelines**](https://ledger.readthedocs.io/en/latest/additional/security_guidelines.html)
28 |
29 | ## The NanoS Secure SDK
30 |
31 | * [GitHub: Ledger NanoS Secure SDK](https://github.com/LedgerHQ/nanos-secure-sdk)
32 |
33 | ## More Ledger Apps
34 |
35 | * [Github: LedgerHQ Ledger Apps](https://github.com/LedgerHQ?q=ledger-app)
36 |
37 | ## Further Reading
38 |
39 | * [ARM Developer Docs: The Arm C and C++ Libraries](https://developer.arm.com/docs/dui0475/i/the-arm-c-and-c-libraries)
40 | * [C Library ABI for the ARM (PDF)](http://infocenter.arm.com/help/topic/com.arm.doc.ihi0039d/IHI0039D_clibabi.pdf)
41 | * [Stanford Wiki: AVR Programming](https://ccrma.stanford.edu/wiki/AVR_Programming)
42 |
--------------------------------------------------------------------------------
/docs/fixtures/type_0.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 2,
3 | "network": 23,
4 | "type": 0,
5 | "nonce": "1",
6 | "senderPublicKey": "03a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933",
7 | "fee": "10000000",
8 | "amount": "100000",
9 | "expiration": 0,
10 | "recipientId": "AJWRd23HNEhPLkK1ymMnwnDBX2a7QBZqff",
11 | "signature": "4f01bd21828a633a3c821b9984fe642deab87237b99e62a543ca6948ff1d6d32f2475ada1f933da0591c40603693614afa69fcb4caa2b4be018788de9f10c42a",
12 | "id": "8c85167cb1ca6f70e350f30173deb4c0a00ce7169d04f78fe4e4bcf2c3a75214",
13 | "serialized": "ff0217010000000000010000000000000003a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933809698000000000000a08601000000000000000000171dfc69b54c7fe901e91d5a9ab78388645e2427ea4f01bd21828a633a3c821b9984fe642deab87237b99e62a543ca6948ff1d6d32f2475ada1f933da0591c40603693614afa69fcb4caa2b4be018788de9f10c42a"
14 | }
15 |
--------------------------------------------------------------------------------
/docs/fixtures/type_0.md:
--------------------------------------------------------------------------------
1 |
2 | # Type 0: Transfer
3 |
4 | ## Signed Json Payload
5 |
6 | ```json
7 | {
8 | "version": 2,
9 | "network": 23,
10 | "type": 0,
11 | "nonce": "1",
12 | "senderPublicKey": "03a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933",
13 | "fee": "10000000",
14 | "amount": "100000",
15 | "expiration": 0,
16 | "recipientId": "AJWRd23HNEhPLkK1ymMnwnDBX2a7QBZqff",
17 | "signature": "4f01bd21828a633a3c821b9984fe642deab87237b99e62a543ca6948ff1d6d32f2475ada1f933da0591c40603693614afa69fcb4caa2b4be018788de9f10c42a",
18 | "id": "8c85167cb1ca6f70e350f30173deb4c0a00ce7169d04f78fe4e4bcf2c3a75214"
19 | }
20 | ```
21 |
22 | ## Serialized Payload
23 |
24 | ```shell
25 | ff0217010000000000010000000000000003a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933809698000000000000a08601000000000000000000171dfc69b54c7fe901e91d5a9ab78388645e2427ea4f01bd21828a633a3c821b9984fe642deab87237b99e62a543ca6948ff1d6d32f2475ada1f933da0591c40603693614afa69fcb4caa2b4be018788de9f10c42a
26 | ```
27 |
28 | ## Deserializing the Hex
29 |
30 | | Key | Pos. | Size
_(bytes)_ | Value
_(hex)_ |
31 | | :-- | :--: | :---------------: | :---------------- |
32 | | **Header:** | **[0]** | **1** | `0xff` |
33 | | **Version:** | **[1]** | **1** | `0x02` |
34 | | **Network:** | **[2]** | **1** | `0x17` |
35 | | **Typegroup:** | **[3]** | **4** | `0x01000000` |
36 | | **Type:** | **[7]** | **2** | `0x0000` |
37 | | **Nonce:** | **[9]** | **8** | `0x0100000000000000` |
38 | | **SenderPublicKey:** | **[17]** | **33** | `0x03a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933` |
39 | | **Fee:** | **[50]** | **8** | `0x8096980000000000` |
40 | | **VendorField Length:** | **[58]** | **1** | `0x00` |
41 | | **Amount:** | **[59]** | **8** | `0xa086010000000000` |
42 | | **Expiration:** | **[67]** | **4** | `0x00000000` |
43 | | **Recipient:** | **[71]** | **21** | `0x171dfc69b54c7fe901e91d5a9ab78388645e2427ea` |
44 | | **Signature:** | **[92]** | **64** | `0x4f01bd21828a633a3c821b9984fe642deab87237b99e62a543ca6948ff1d6d32f2475ada1f933da0591c40603693614afa69fcb4caa2b4be018788de9f10c42a` |
45 |
46 | ## Example Ledger Payload
47 |
48 | ```shell
49 | python3 examples/example_helper.py --tx ff0217010000000000010000000000000003a02b9d5fdd1307c2ee4652ba54d492d1fd11a7d1bb3f3a44c4a05e79f19de933809698000000000000a08601000000000000000000171dfc69b54c7fe901e91d5a9ab78388645e2427ea
50 | ```
51 |
--------------------------------------------------------------------------------
/docs/fixtures/type_0_multi_sign.json:
--------------------------------------------------------------------------------
1 | {
2 | "data": {
3 | "version": 2,
4 | "network": 23,
5 | "typeGroup": 1,
6 | "type": 0,
7 | "nonce": "1",
8 | "senderPublicKey": "03fb92a2c3efaa177d8a51fc0cdf41905098d8b2cd900cbac94617492827e5f015",
9 | "fee": "10000000",
10 | "amount": "200000000",
11 | "expiration": 0,
12 | "recipientId": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC",
13 | "signatures": [
14 | "00c01c44bf33bea20a74d5acc12c5d6aafe82240f3571121382b77c871f4b33d6da2b62fdc6ca2cc6bc583abb2a69e7975be29e8d80a59c52bcff8d54514cf999e",
15 | "01830a2e319f2070f3519bc22c2d449acdb7691bf9dd25e3649a72ac843e08ce26e0b87e30e65b73f853cf8e375dbc495cc75c6fd199bf4b15327bf8c5ec4bfac5",
16 | "0292c299b739f0cb5e36133d85f51fff2fcc7745e8af4d0778908560c0874e3f2303e0436eabce1c09d88efab0004e61c5d6e47768aa8d2ab0cb9f14d523a38308"
17 | ],
18 | "id": "a7245dcc720d3e133035cff04b4a14dbc0f8ff889c703c89c99f2f03e8f3c59d"
19 | },
20 | "serialized": "ff0217010000000000010000000000000003fb92a2c3efaa177d8a51fc0cdf41905098d8b2cd900cbac94617492827e5f01580969800000000000000c2eb0b0000000000000000170995750207ecaf0ccf251c1265b92ad84f55366200c01c44bf33bea20a74d5acc12c5d6aafe82240f3571121382b77c871f4b33d6da2b62fdc6ca2cc6bc583abb2a69e7975be29e8d80a59c52bcff8d54514cf999e01830a2e319f2070f3519bc22c2d449acdb7691bf9dd25e3649a72ac843e08ce26e0b87e30e65b73f853cf8e375dbc495cc75c6fd199bf4b15327bf8c5ec4bfac50292c299b739f0cb5e36133d85f51fff2fcc7745e8af4d0778908560c0874e3f2303e0436eabce1c09d88efab0004e61c5d6e47768aa8d2ab0cb9f14d523a38308"
21 | }
22 |
--------------------------------------------------------------------------------
/docs/fixtures/type_0_vendorfield.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 2,
3 | "network": 23,
4 | "type": 0,
5 | "nonce": "3",
6 | "senderPublicKey": "029f0ab8ab10258144332230178353fa24eb4274370345eaaf1594948a79c89399",
7 | "fee": "10000000",
8 | "amount": "1",
9 | "vendorFieldHex": "48656c6c6f20576f726c64",
10 | "vendorField": "Hello World",
11 | "expiration": 0,
12 | "recipientId": "AMLFBUUXs8ss9iq4k5fLLnZJ5TV757dUFV",
13 | "signature": "0e23e11473c80ea9e2d32d32bb338a649ad09ac1e4b302ec938efcbe3046176344495e538d3fb1b95efd1f2d0d847b34eee0c440ae4575446d93e5c4219c0e63",
14 | "id": "ffc4ace894fb29d986d0b11829e67740b47056bd362a52a5eaeda8cf8c18d349",
15 | "serialized": "ff02170100000000000300000000000000029f0ab8ab10258144332230178353fa24eb4274370345eaaf1594948a79c8939980969800000000000b48656c6c6f20576f726c64010000000000000000000000173cf7ea59e8d9690e858b7674885b9a4a2c4365d60e23e11473c80ea9e2d32d32bb338a649ad09ac1e4b302ec938efcbe3046176344495e538d3fb1b95efd1f2d0d847b34eee0c440ae4575446d93e5c4219c0e63"
16 | }
17 |
--------------------------------------------------------------------------------
/docs/fixtures/type_0_vendorfield.md:
--------------------------------------------------------------------------------
1 |
2 | # Type 0: Transfer with VendorField
3 |
4 | ## Signed Json Payload
5 |
6 | ```json
7 | {
8 | "version": 2,
9 | "network": 23,
10 | "type": 0,
11 | "nonce": "3",
12 | "senderPublicKey": "029f0ab8ab10258144332230178353fa24eb4274370345eaaf1594948a79c89399",
13 | "fee": "10000000",
14 | "amount": "1",
15 | "vendorFieldHex": "48656c6c6f20576f726c64",
16 | "vendorField": "Hello World",
17 | "expiration": 0,
18 | "recipientId": "AMLFBUUXs8ss9iq4k5fLLnZJ5TV757dUFV",
19 | "signature": "0e23e11473c80ea9e2d32d32bb338a649ad09ac1e4b302ec938efcbe3046176344495e538d3fb1b95efd1f2d0d847b34eee0c440ae4575446d93e5c4219c0e63",
20 | "id": "ffc4ace894fb29d986d0b11829e67740b47056bd362a52a5eaeda8cf8c18d349"
21 | }
22 | ```
23 |
24 | ## Serialized Payload
25 |
26 | ```shell
27 | ff02170100000000000300000000000000029f0ab8ab10258144332230178353fa24eb4274370345eaaf1594948a79c8939980969800000000000b48656c6c6f20576f726c64010000000000000000000000173cf7ea59e8d9690e858b7674885b9a4a2c4365d60e23e11473c80ea9e2d32d32bb338a649ad09ac1e4b302ec938efcbe3046176344495e538d3fb1b95efd1f2d0d847b34eee0c440ae4575446d93e5c4219c0e63
28 | ```
29 |
30 | ## Deserializing the Hex
31 |
32 | | Key | Pos. | Size
_(bytes)_ | Value
_(hex)_ |
33 | | :-- | :--: | :---------------: | :---------------- |
34 | | **Header:** | **[0]** | **1** | `0xff` |
35 | | **Version:** | **[1]** | **1** | `0x02` |
36 | | **Network:** | **[2]** | **1** | `0x17` |
37 | | **Typegroup:** | **[3]** | **4** | `0x01000000` |
38 | | **Type:** | **[7]** | **2** | `0x0000` |
39 | | **Nonce:** | **[9]** | **8** | `0x0300000000000000` |
40 | | **SenderPublicKey:** | **[17]** | **33** | `0x029f0ab8ab10258144332230178353fa24eb4274370345eaaf1594948a79c89399` |
41 | | **Fee:** | **[50]** | **8** | `0x8096980000000000` |
42 | | **VendorField Length:** | **[58]** | **1** | `0x0b` |
43 | | **VendorField:** | **[59]** | **11** | `0x48656c6c6f20576f726c64` |
44 | | **Amount:** | **[70]** | **8** | `0x0100000000000000` |
45 | | **Expiration:** | **[78]** | **4** | `0x00000000` |
46 | | **Recipient:** | **[82]** | **21** | `0x173cf7ea59e8d9690e858b7674885b9a4a2c4365d6` |
47 | | **Signature:** | **[103]** | **64** | `0x0e23e11473c80ea9e2d32d32bb338a649ad09ac1e4b302ec938efcbe3046176344495e538d3fb1b95efd1f2d0d847b34eee0c440ae4575446d93e5c4219c0e63` |
48 |
49 | ## Example Ledger Payload
50 |
51 | ```shell
52 | python3 examples/example_helper.py --tx ff02170100000000000300000000000000029f0ab8ab10258144332230178353fa24eb4274370345eaaf1594948a79c8939980969800000000000b48656c6c6f20576f726c64010000000000000000000000173cf7ea59e8d9690e858b7674885b9a4a2c4365d6
53 | ```
54 |
--------------------------------------------------------------------------------
/docs/fixtures/type_0_vendorfield_multi_sign.json:
--------------------------------------------------------------------------------
1 | {
2 | "data": {
3 | "version": 2,
4 | "network": 23,
5 | "typeGroup": 1,
6 | "type": 0,
7 | "nonce": "1",
8 | "senderPublicKey": "03fb92a2c3efaa177d8a51fc0cdf41905098d8b2cd900cbac94617492827e5f015",
9 | "fee": "10000000",
10 | "amount": "200000000",
11 | "vendorFieldHex": "74686973206973206120746f70207365637265742076656e646f72206669656c64",
12 | "vendorField": "this is a top secret vendor field",
13 | "expiration": 0,
14 | "recipientId": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC",
15 | "signatures": [
16 | "0033194adf162a4e3039bf1fbb96d1edd9f0103d54935c1fac56a0382fa6269b715d5d79577a06e334e0836941035954106b1a689d079a69f94462d4df58a8749d",
17 | "015e34212ac4ff97b04510d48e15f10d3e7b7a4f15c739fd07f598720402f3bb69ccf828417ff96cd97a86de6d710d21ad560145d3abdc8739fb7f6f2d48d490c7",
18 | "0287ff743ca6d45c262c89c738dc2271fca2cbab7cbf429b8cbcda6cc31471425d48a2db0c4b4554088e3692e8d442f9d6ca07cd20971ab301e0902c3a4bae4727"
19 | ],
20 | "id": "35d79432c76468deb3ca57f77890c346a92836666aa50fcfa11b3e10c064f8cd"
21 | },
22 | "serialized": "ff0217010000000000010000000000000003fb92a2c3efaa177d8a51fc0cdf41905098d8b2cd900cbac94617492827e5f01580969800000000002174686973206973206120746f70207365637265742076656e646f72206669656c6400c2eb0b0000000000000000170995750207ecaf0ccf251c1265b92ad84f5536620033194adf162a4e3039bf1fbb96d1edd9f0103d54935c1fac56a0382fa6269b715d5d79577a06e334e0836941035954106b1a689d079a69f94462d4df58a8749d015e34212ac4ff97b04510d48e15f10d3e7b7a4f15c739fd07f598720402f3bb69ccf828417ff96cd97a86de6d710d21ad560145d3abdc8739fb7f6f2d48d490c70287ff743ca6d45c262c89c738dc2271fca2cbab7cbf429b8cbcda6cc31471425d48a2db0c4b4554088e3692e8d442f9d6ca07cd20971ab301e0902c3a4bae4727"
23 | }
24 |
--------------------------------------------------------------------------------
/docs/fixtures/type_1.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 2,
3 | "network": 23,
4 | "type": 1,
5 | "nonce": "2",
6 | "senderPublicKey": "02e0c063777427ac196af3c426fd648231ebc4ea06fff5edb1652b98f9c8420c69",
7 | "fee": "500000000",
8 | "amount": "0",
9 | "asset": {
10 | "signature": {
11 | "publicKey": "02877e4f35c76abaeb152b128670db0a7ae10b3999afcd28a42938b653fbf87ae9"
12 | }
13 | },
14 | "signature": "adb983dd28827860f69c6a98b2f9db88a9e084cc7fe3a691463377c3225b02fee24547b516d1cf05f2f77b65a9c36069f6540605c01694008e2a5cb4fc88f62f",
15 | "id": "4c2cd8c4281a34a60505f260d067e5c678d3c57510bfbcda24c5e0da5f46bd5e",
16 | "serialized": "ff0217010000000100020000000000000002e0c063777427ac196af3c426fd648231ebc4ea06fff5edb1652b98f9c8420c690065cd1d000000000002877e4f35c76abaeb152b128670db0a7ae10b3999afcd28a42938b653fbf87ae9adb983dd28827860f69c6a98b2f9db88a9e084cc7fe3a691463377c3225b02fee24547b516d1cf05f2f77b65a9c36069f6540605c01694008e2a5cb4fc88f62f"
17 | }
18 |
--------------------------------------------------------------------------------
/docs/fixtures/type_1.md:
--------------------------------------------------------------------------------
1 |
2 | # Type 1: Second Signature Registration
3 |
4 | ## Signed Json Payload
5 |
6 | ```json
7 | {
8 | "version": 2,
9 | "network": 23,
10 | "type": 1,
11 | "nonce": "2",
12 | "senderPublicKey": "02e0c063777427ac196af3c426fd648231ebc4ea06fff5edb1652b98f9c8420c69",
13 | "fee": "500000000",
14 | "amount": "0",
15 | "asset": {
16 | "signature": {
17 | "publicKey": "02877e4f35c76abaeb152b128670db0a7ae10b3999afcd28a42938b653fbf87ae9"
18 | }
19 | },
20 | "signature": "adb983dd28827860f69c6a98b2f9db88a9e084cc7fe3a691463377c3225b02fee24547b516d1cf05f2f77b65a9c36069f6540605c01694008e2a5cb4fc88f62f",
21 | "id": "4c2cd8c4281a34a60505f260d067e5c678d3c57510bfbcda24c5e0da5f46bd5e"
22 | }
23 | ```
24 |
25 | ## Serialized Payload
26 |
27 | ```shell
28 | ff0217010000000100020000000000000002e0c063777427ac196af3c426fd648231ebc4ea06fff5edb1652b98f9c8420c690065cd1d000000000002877e4f35c76abaeb152b128670db0a7ae10b3999afcd28a42938b653fbf87ae9adb983dd28827860f69c6a98b2f9db88a9e084cc7fe3a691463377c3225b02fee24547b516d1cf05f2f77b65a9c36069f6540605c01694008e2a5cb4fc88f62f
29 | ```
30 |
31 | ## Deserializing the Hex
32 |
33 | | Key | Pos. | Size
_(bytes)_ | Value
_(hex)_ |
34 | | :-- | :--: | :---------------: | :---------------- |
35 | | **Header:** | **[0]** | **1** | `0xff` |
36 | | **Version:** | **[1]** | **1** | `0x02` |
37 | | **Network:** | **[2]** | **1** | `0x17` |
38 | | **Typegroup:** | **[3]** | **4** | `0x01000000` |
39 | | **Type:** | **[7]** | **2** | `0x0100` |
40 | | **Nonce:** | **[9]** | **8** | `0x0200000000000000` |
41 | | **SenderPublicKey:** | **[17]** | **33** | `0x02e0c063777427ac196af3c426fd648231ebc4ea06fff5edb1652b98f9c8420c69` |
42 | | **Fee:** | **[50]** | **8** | `0x0065cd1d00000000` |
43 | | **VendorField Length:** | **[58]** | **1** | `0x00` |
44 | | **Second PublicKey:** | **[59]** | **8** | `0x02877e4f35c76abaeb152b128670db0a7ae10b3999afcd28a42938b653fbf87ae9` |
45 | | **Signature:** | **[67]** | **64** | `0xadb983dd28827860f69c6a98b2f9db88a9e084cc7fe3a691463377c3225b02fee24547b516d1cf05f2f77b65a9c36069f6540605c01694008e2a5cb4fc88f62f` |
46 |
47 | ## Example Ledger Payload
48 |
49 | ```shell
50 | python3 examples/example_helper.py --tx ff0217010000000100020000000000000002e0c063777427ac196af3c426fd648231ebc4ea06fff5edb1652b98f9c8420c690065cd1d000000000002877e4f35c76abaeb152b128670db0a7ae10b3999afcd28a42938b653fbf87ae9
51 | ```
52 |
--------------------------------------------------------------------------------
/docs/fixtures/type_10.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 2,
3 | "network": 23,
4 | "type": 10,
5 | "nonce": "3",
6 | "senderPublicKey": "037fc2e14f626586722a4f9e00dca2efbc4ac409c1ca63bc4309f56184265f95d5",
7 | "fee": "0",
8 | "amount": "0",
9 | "asset": {
10 | "refund": {
11 | "lockTransactionId": "c62bd36c162dd0116a08bf8a75cd6d1f83b8f5f1e17e89c8231ebb7af595f64d"
12 | }
13 | },
14 | "signature": "ae272f4650ee1d46260b8f62e7e956af33cd25587318fed056aec8e9d518e2394d0fd3166d8cd8506abfc303c644041a4bab35daf7c8aaa77f916ef09dc90336",
15 | "id": "4d9ee7f8b27999d4ce7acf6afee08e3da67bc1fca258f2bd17e426933a846602",
16 | "serialized": "ff0217010000000a000300000000000000037fc2e14f626586722a4f9e00dca2efbc4ac409c1ca63bc4309f56184265f95d5000000000000000000c62bd36c162dd0116a08bf8a75cd6d1f83b8f5f1e17e89c8231ebb7af595f64dae272f4650ee1d46260b8f62e7e956af33cd25587318fed056aec8e9d518e2394d0fd3166d8cd8506abfc303c644041a4bab35daf7c8aaa77f916ef09dc90336"
17 | }
18 |
--------------------------------------------------------------------------------
/docs/fixtures/type_10.md:
--------------------------------------------------------------------------------
1 |
2 | # Type 10: HTLC Refund
3 |
4 | ## Signed Json Payload
5 |
6 | ```json
7 | {
8 | "version": 2,
9 | "network": 23,
10 | "type": 10,
11 | "nonce": "3",
12 | "senderPublicKey": "037fc2e14f626586722a4f9e00dca2efbc4ac409c1ca63bc4309f56184265f95d5",
13 | "fee": "0",
14 | "amount": "0",
15 | "asset": {
16 | "refund": {
17 | "lockTransactionId": "c62bd36c162dd0116a08bf8a75cd6d1f83b8f5f1e17e89c8231ebb7af595f64d"
18 | }
19 | },
20 | "signature": "ae272f4650ee1d46260b8f62e7e956af33cd25587318fed056aec8e9d518e2394d0fd3166d8cd8506abfc303c644041a4bab35daf7c8aaa77f916ef09dc90336",
21 | "id": "4d9ee7f8b27999d4ce7acf6afee08e3da67bc1fca258f2bd17e426933a846602"
22 | }
23 | ```
24 |
25 | ## Serialized Payload
26 |
27 | ```shell
28 | ff0217010000000a000300000000000000037fc2e14f626586722a4f9e00dca2efbc4ac409c1ca63bc4309f56184265f95d5000000000000000000c62bd36c162dd0116a08bf8a75cd6d1f83b8f5f1e17e89c8231ebb7af595f64dae272f4650ee1d46260b8f62e7e956af33cd25587318fed056aec8e9d518e2394d0fd3166d8cd8506abfc303c644041a4bab35daf7c8aaa77f916ef09dc90336
29 | ```
30 |
31 | ## Deserializing the Hex
32 |
33 | | Key | Pos. | Size
_(bytes)_ | Value
_(hex)_ |
34 | | :-- | :--: | :---------------: | :---------------- |
35 | | **Header:** | **[0]** | **1** | `0xff` |
36 | | **Version:** | **[1]** | **1** | `0x02` |
37 | | **Network:** | **[2]** | **1** | `0x17` |
38 | | **Typegroup:** | **[3]** | **4** | `0x01000000` |
39 | | **Type:** | **[7]** | **2** | `0x0a00` |
40 | | **Nonce:** | **[9]** | **8** | `0x0300000000000000` |
41 | | **SenderPublicKey:** | **[17]** | **33** | `0x037fc2e14f626586722a4f9e00dca2efbc4ac409c1ca63bc4309f56184265f95d5` |
42 | | **Fee:** | **[50]** | **8** | `0x0000000000000000` |
43 | | **VendorField Length:** | **[58]** | **1** | `0x00` |
44 | | **Lock Id:** | **[59]** | **32** | `0xc62bd36c162dd0116a08bf8a75cd6d1f83b8f5f1e17e89c8231ebb7af595f64d` |
45 | | **Signature:** | **[91]** | **64** | `0xae272f4650ee1d46260b8f62e7e956af33cd25587318fed056aec8e9d518e2394d0fd3166d8cd8506abfc303c644041a4bab35daf7c8aaa77f916ef09dc90336` |
46 |
47 | ## Example Ledger Payload
48 |
49 | ```shell
50 | python3 examples/example_helper.py --tx ff0217010000000a000300000000000000037fc2e14f626586722a4f9e00dca2efbc4ac409c1ca63bc4309f56184265f95d5000000000000000000c62bd36c162dd0116a08bf8a75cd6d1f83b8f5f1e17e89c8231ebb7af595f64d
51 | ```
52 |
--------------------------------------------------------------------------------
/docs/fixtures/type_10_multi_sign.json:
--------------------------------------------------------------------------------
1 | {
2 | "data": {
3 | "version": 2,
4 | "network": 23,
5 | "typeGroup": 1,
6 | "type": 10,
7 | "nonce": "1",
8 | "senderPublicKey": "03fb92a2c3efaa177d8a51fc0cdf41905098d8b2cd900cbac94617492827e5f015",
9 | "fee": "0",
10 | "amount": "0",
11 | "asset": {
12 | "refund": {
13 | "lockTransactionId": "943c220691e711c39c79d437ce185748a0018940e1a4144293af9d05627d2eb4"
14 | }
15 | },
16 | "signatures": [
17 | "0003fbc187eed1d69df28f0583bd1f1252968e5d01e1fe4615e8a146f3b87ca1b60a5fe28973c4756d650f8e878571ca7929747668da76443053d6eb384e3f8480",
18 | "015124b35ac4ba1aacd3842cb51c2d590fca3909dedff016ddeae9f72f0ca4f984d54dc4cd631d7aa0befa67d39e506cba1563bc9cb8b3af5506a08e93f625bca4",
19 | "02309e80689b70901bf1f20aa2b151ec1a1d12da29af829aa0bd59bdb423997f81b6a9479d4211889aee486bb9141dd0cef09433381afc00c9c297115be665c168"
20 | ],
21 | "id": "4971fe722261ca9e6442ae3bba7758a0be3572c80d4fc1607f30ffda629f9dad"
22 | },
23 | "serialized": "ff0217010000000a00010000000000000003fb92a2c3efaa177d8a51fc0cdf41905098d8b2cd900cbac94617492827e5f015000000000000000000943c220691e711c39c79d437ce185748a0018940e1a4144293af9d05627d2eb40003fbc187eed1d69df28f0583bd1f1252968e5d01e1fe4615e8a146f3b87ca1b60a5fe28973c4756d650f8e878571ca7929747668da76443053d6eb384e3f8480015124b35ac4ba1aacd3842cb51c2d590fca3909dedff016ddeae9f72f0ca4f984d54dc4cd631d7aa0befa67d39e506cba1563bc9cb8b3af5506a08e93f625bca402309e80689b70901bf1f20aa2b151ec1a1d12da29af829aa0bd59bdb423997f81b6a9479d4211889aee486bb9141dd0cef09433381afc00c9c297115be665c168"
24 | }
25 |
--------------------------------------------------------------------------------
/docs/fixtures/type_2.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 2,
3 | "network": 23,
4 | "type": 2,
5 | "nonce": "2",
6 | "senderPublicKey": "02a574b8995542631976691a7f73b59e4700cd84badb831331ab18ae2113a184ba",
7 | "fee": "2500000000",
8 | "amount": "0",
9 | "asset": {
10 | "delegate": {
11 | "username": "02a574b8995542631976"
12 | }
13 | },
14 | "signature": "f2cf8acf6ccb71fa0e848ca185a93e6ff44e0dd266b08c4bc0dfc7984499acd759f6067ace6bb00eae404eafa6af3548f5d35f8727f4ddeba69b6d925c604338",
15 | "id": "9b232e31c6385a2c730f5bec3c0220da6a184320e6c38bd7b6fd5a18b8501472",
16 | "serialized": "ff0217010000000200020000000000000002a574b8995542631976691a7f73b59e4700cd84badb831331ab18ae2113a184ba00f902950000000000143032613537346238393935353432363331393736f2cf8acf6ccb71fa0e848ca185a93e6ff44e0dd266b08c4bc0dfc7984499acd759f6067ace6bb00eae404eafa6af3548f5d35f8727f4ddeba69b6d925c604338"
17 | }
18 |
--------------------------------------------------------------------------------
/docs/fixtures/type_2.md:
--------------------------------------------------------------------------------
1 |
2 | # Type 2: Delegate Registration
3 |
4 | ## Signed Json Payload
5 |
6 | ```json
7 | {
8 | "version": 2,
9 | "network": 23,
10 | "type": 2,
11 | "nonce": "2",
12 | "senderPublicKey": "02a574b8995542631976691a7f73b59e4700cd84badb831331ab18ae2113a184ba",
13 | "fee": "2500000000",
14 | "amount": "0",
15 | "asset": {
16 | "delegate": {
17 | "username": "02a574b8995542631976"
18 | }
19 | },
20 | "signature": "f2cf8acf6ccb71fa0e848ca185a93e6ff44e0dd266b08c4bc0dfc7984499acd759f6067ace6bb00eae404eafa6af3548f5d35f8727f4ddeba69b6d925c604338",
21 | "id": "9b232e31c6385a2c730f5bec3c0220da6a184320e6c38bd7b6fd5a18b8501472"
22 | }
23 | ```
24 |
25 | ## Serialized Payload
26 |
27 | ```shell
28 | ff0217010000000200020000000000000002a574b8995542631976691a7f73b59e4700cd84badb831331ab18ae2113a184ba00f902950000000000143032613537346238393935353432363331393736f2cf8acf6ccb71fa0e848ca185a93e6ff44e0dd266b08c4bc0dfc7984499acd759f6067ace6bb00eae404eafa6af3548f5d35f8727f4ddeba69b6d925c604338
29 | ```
30 |
31 | ## Deserializing the Hex
32 |
33 | | Key | Pos. | Size
_(bytes)_ | Value
_(hex)_ |
34 | | :-- | :--: | :---------------: | :---------------- |
35 | | **Header:** | **[0]** | **1** | `0xff` |
36 | | **Version:** | **[1]** | **1** | `0x02` |
37 | | **Network:** | **[2]** | **1** | `0x17` |
38 | | **Typegroup:** | **[3]** | **4** | `0x01000000` |
39 | | **Type:** | **[7]** | **2** | `0x0200` |
40 | | **Nonce:** | **[9]** | **8** | `0x0200000000000000` |
41 | | **SenderPublicKey:** | **[17]** | **33** | `0x02a574b8995542631976691a7f73b59e4700cd84badb831331ab18ae2113a184ba` |
42 | | **Fee:** | **[50]** | **8** | `0x00f9029500000000` |
43 | | **VendorField Length:** | **[58]** | **1** | `0x00` |
44 | | **Username Length:** | **[59]** | **1** | `0x14` |
45 | | **Username:** | **[60]** | **20** | `0x3032613537346238393935353432363331393736` |
46 | | **Signature:** | **[80]** | **64** | `0xf2cf8acf6ccb71fa0e848ca185a93e6ff44e0dd266b08c4bc0dfc7984499acd759f6067ace6bb00eae404eafa6af3548f5d35f8727f4ddeba69b6d925c604338` |
47 |
48 | ## Example Ledger Payload
49 |
50 | ```shell
51 | python3 examples/example_helper.py --tx ff0217010000000200020000000000000002a574b8995542631976691a7f73b59e4700cd84badb831331ab18ae2113a184ba00f902950000000000143032613537346238393935353432363331393736
52 | ```
53 |
--------------------------------------------------------------------------------
/docs/fixtures/type_3.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 2,
3 | "network": 23,
4 | "type": 3,
5 | "nonce": "2",
6 | "senderPublicKey": "02555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d",
7 | "fee": "100000000",
8 | "amount": "0",
9 | "asset": {
10 | "count": 2,
11 | "votes": [
12 | "+02555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d",
13 | "-02555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d"
14 | ]
15 | },
16 | "signature": "4651686a5c7832fb98e3d68bf9840d35ac4ea55269c9030155e9e6ddf47713cafab10ff2f6e07f3979009fe71381e5b96ddda4a6e4cd2c6d15e9de5c0b5073a1",
17 | "id": "45694c63f6630f9144e7cffa441efca6899e60e2e569192f52c86985e841f3e7",
18 | "serialized": "ff0217010000000300020000000000000002555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d00e1f5050000000000020102555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d0002555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d4651686a5c7832fb98e3d68bf9840d35ac4ea55269c9030155e9e6ddf47713cafab10ff2f6e07f3979009fe71381e5b96ddda4a6e4cd2c6d15e9de5c0b5073a1"
19 | }
20 |
--------------------------------------------------------------------------------
/docs/fixtures/type_3.md:
--------------------------------------------------------------------------------
1 |
2 | # Type 3: Vote
3 |
4 | ## Signed Json Payload
5 |
6 | ```json
7 | {
8 | "version": 2,
9 | "network": 23,
10 | "type": 3,
11 | "nonce": "2",
12 | "senderPublicKey": "02555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d",
13 | "fee": "100000000",
14 | "amount": "0",
15 | "asset": {
16 | "count": 2,
17 | "votes": [
18 | "+02555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d",
19 | "-02555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d"
20 | ]
21 | },
22 | "signature": "4651686a5c7832fb98e3d68bf9840d35ac4ea55269c9030155e9e6ddf47713cafab10ff2f6e07f3979009fe71381e5b96ddda4a6e4cd2c6d15e9de5c0b5073a1",
23 | "id": "45694c63f6630f9144e7cffa441efca6899e60e2e569192f52c86985e841f3e7",
24 | }
25 | ```
26 |
27 | ## Serialized Payload
28 |
29 | ```shell
30 | ff0217010000000300020000000000000002555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d00e1f5050000000000020102555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d0002555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d4651686a5c7832fb98e3d68bf9840d35ac4ea55269c9030155e9e6ddf47713cafab10ff2f6e07f3979009fe71381e5b96ddda4a6e4cd2c6d15e9de5c0b5073a1
31 | ```
32 |
33 | ## Deserializing the Hex
34 |
35 | | Key | Pos. | Size
_(bytes)_ | Value
_(hex)_ |
36 | | :-- | :--: | :---------------: | :---------------- |
37 | | **Header:** | **[0]** | **1** | `0xff` |
38 | | **Version:** | **[1]** | **1** | `0x02` |
39 | | **Network:** | **[2]** | **1** | `0x17` |
40 | | **Typegroup:** | **[3]** | **4** | `0x01000000` |
41 | | **Type:** | **[7]** | **2** | `0x0300` |
42 | | **Nonce:** | **[9]** | **8** | `0x0200000000000000` |
43 | | **SenderPublicKey:** | **[17]** | **33** | `0x02555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d` |
44 | | **Fee:** | **[50]** | **8** | `0x00e1f50500000000` |
45 | | **VendorField Length:** | **[58]** | **1** | `0x00` |
46 | | **Vote Count:** | **[59]** | **1** | `0x02` |
47 | | **Vote:** | **[60]** | **34** | `0x0102555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d` |
48 | | **Vote:** | **[94]** | **34** | `0x0002555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d` |
49 | | **Signature:** | **[128]** | **64** | `0x77a40e4b4170ce613c8f9ccc0650887349330a9a8b459189ee379c88cf2c8506d65aa3ca8293705373f1bde8d6b27e5071de1785ac9c0182f41e364f8f9e3b64` |
50 |
51 | ## Example Ledger Payload
52 |
53 | ```shell
54 | python3 examples/example_helper.py --tx ff0217010000000300020000000000000002555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d00e1f5050000000000020102555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d0002555806bca6737eaeaff6434d5171bac8aeb72533ed9bafb280dd11b328a3822d
55 | ```
56 |
--------------------------------------------------------------------------------
/docs/fixtures/type_3_multi_sign.json:
--------------------------------------------------------------------------------
1 | {
2 | "data": {
3 | "version": 2,
4 | "network": 23,
5 | "typeGroup": 1,
6 | "type": 3,
7 | "nonce": "1",
8 | "senderPublicKey": "03fb92a2c3efaa177d8a51fc0cdf41905098d8b2cd900cbac94617492827e5f015",
9 | "fee": "100000000",
10 | "amount": "0",
11 | "asset": {
12 | "votes": [
13 | "+022cca9529ec97a772156c152a00aad155ee6708243e65c9d211a589cb5d43234d"
14 | ]
15 | },
16 | "signatures": [
17 | "003c728aa533024b0d36386652ba80bdccdd70d71f1cfbe63739672975f8562abfe87b5d9ec82a5cb741c58511b08ede21e8c6af640de6c43d4f7bff039c61cb79",
18 | "013c342d6e892ff5d5410b825d5781137a158350e7139cf450b327accacee9d6b32304654679c52f8bfa472a8739f249c427b3ebc8c2cc9f3c1c15a724466797bf",
19 | "0258a19937052d6eb6c76c09dafa711c766a97de7bd897983275b27028133ba816b60a45cae12e00f4a599b9b8dc9530c25a5b134841f8bb60e28cb81b30bc6eed"
20 | ],
21 | "id": "320ec28539f10b06ca02834503ac818fb0a299119aadfa48849707ed5ace56e5"
22 | },
23 | "serialized": "ff0217010000000300010000000000000003fb92a2c3efaa177d8a51fc0cdf41905098d8b2cd900cbac94617492827e5f01500e1f50500000000000101022cca9529ec97a772156c152a00aad155ee6708243e65c9d211a589cb5d43234d003c728aa533024b0d36386652ba80bdccdd70d71f1cfbe63739672975f8562abfe87b5d9ec82a5cb741c58511b08ede21e8c6af640de6c43d4f7bff039c61cb79013c342d6e892ff5d5410b825d5781137a158350e7139cf450b327accacee9d6b32304654679c52f8bfa472a8739f249c427b3ebc8c2cc9f3c1c15a724466797bf0258a19937052d6eb6c76c09dafa711c766a97de7bd897983275b27028133ba816b60a45cae12e00f4a599b9b8dc9530c25a5b134841f8bb60e28cb81b30bc6eed"
24 | }
25 |
--------------------------------------------------------------------------------
/docs/fixtures/type_4.json:
--------------------------------------------------------------------------------
1 | {
2 | "data": {
3 | "version": 2,
4 | "network": 23,
5 | "typeGroup": 1,
6 | "type": 4,
7 | "nonce": "1",
8 | "senderPublicKey": "0205d9bbe71c343ac9a6a83a4344fd404c3534fc7349827097d0835d160bc2b896",
9 | "fee": "2000000000",
10 | "amount": "0",
11 | "asset": {
12 | "multiSignature": {
13 | "publicKeys": [
14 | "0205d9bbe71c343ac9a6a83a4344fd404c3534fc7349827097d0835d160bc2b896",
15 | "03df0a1eb42d99b5de395cead145ba1ec2ea837be308c7ce3a4e8018b7efc7fdb8",
16 | "03860d76b1df09659ac282cea3da5bd84fc45729f348a4a8e5f802186be72dc17f"
17 | ],
18 | "min": 2
19 | }
20 | },
21 | "signature": "f5e9859c955bf8917b308ea21c88daf58661686c2017e476dcf735ad7f00aebf8e6effda3fe99e5f33f6007db7db9c9155796d9b5d31c53bd6156364a6a765d0",
22 | "signatures": [
23 | "0064900cb2cc3db6ca9c7e3bd363b322cdc4a39e051f655e9867935e1bb856b6dcce52845c031c690808f40340bc827bbaacd7b04bceff866cb0d386ab84715174",
24 | "01dd363ccc101a958bded1a5db1c08f13283fc7cee53da93dfe00785eb406512467ff8e445f8ad843744ac4179f30f942645dfd5bdf5f2bfc344ad02393053880a",
25 | "02d0012f035dc3fd54173c83d40217914653488fe9ce592dca34234163181d255281f2be7033725cfc4a6786509e7fabbaf0be8cf50882fc7b66fe94f259fd004e"
26 | ],
27 | "id": "c868aad20165a336c35e324378f0c12008d18af4c1025291efcb7539c7c917f0"
28 | },
29 | "serialized": "ff021701000000040001000000000000000205d9bbe71c343ac9a6a83a4344fd404c3534fc7349827097d0835d160bc2b89600943577000000000002030205d9bbe71c343ac9a6a83a4344fd404c3534fc7349827097d0835d160bc2b89603df0a1eb42d99b5de395cead145ba1ec2ea837be308c7ce3a4e8018b7efc7fdb803860d76b1df09659ac282cea3da5bd84fc45729f348a4a8e5f802186be72dc17ff5e9859c955bf8917b308ea21c88daf58661686c2017e476dcf735ad7f00aebf8e6effda3fe99e5f33f6007db7db9c9155796d9b5d31c53bd6156364a6a765d00064900cb2cc3db6ca9c7e3bd363b322cdc4a39e051f655e9867935e1bb856b6dcce52845c031c690808f40340bc827bbaacd7b04bceff866cb0d386ab8471517401dd363ccc101a958bded1a5db1c08f13283fc7cee53da93dfe00785eb406512467ff8e445f8ad843744ac4179f30f942645dfd5bdf5f2bfc344ad02393053880a02d0012f035dc3fd54173c83d40217914653488fe9ce592dca34234163181d255281f2be7033725cfc4a6786509e7fabbaf0be8cf50882fc7b66fe94f259fd004e"
30 | }
31 |
--------------------------------------------------------------------------------
/docs/fixtures/type_5.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 2,
3 | "network": 23,
4 | "type": 5,
5 | "nonce": "2",
6 | "senderPublicKey": "038e000c902d4551065ac5705637c685d52e6ac4032e158ad0370c5ef2bbafae2c",
7 | "fee": "500000000",
8 | "amount": "0",
9 | "asset": {
10 | "ipfs": "QmYSK2JyM3RyDyB52caZCTKFR3HKniEcMnNJYdk8DQ6KKB"
11 | },
12 | "signature": "ed8e729b40e73ab86c3b6675d463c19d88495bf4e091037e80352afe0ea29efff04d2667bfe8d78e5c4ad410fb0f7a0f511fbd657a54181aca8de4e8c6ebfe2c",
13 | "id": "77d8134144780e50db71adb496e02bcbde43e76a0cd7eeae7ff3641db75187ec",
14 | "serialized": "ff02170100000005000200000000000000038e000c902d4551065ac5705637c685d52e6ac4032e158ad0370c5ef2bbafae2c0065cd1d000000000012209608184d6cee2b9af8e6c2a46fc9318adf73329aeb8a86cf8472829fff5bb89eed8e729b40e73ab86c3b6675d463c19d88495bf4e091037e80352afe0ea29efff04d2667bfe8d78e5c4ad410fb0f7a0f511fbd657a54181aca8de4e8c6ebfe2c"
15 | }
16 |
--------------------------------------------------------------------------------
/docs/fixtures/type_5_multi_sign.json:
--------------------------------------------------------------------------------
1 | {
2 | "data": {
3 | "version": 2,
4 | "network": 23,
5 | "typeGroup": 1,
6 | "type": 5,
7 | "nonce": "1",
8 | "senderPublicKey": "03fb92a2c3efaa177d8a51fc0cdf41905098d8b2cd900cbac94617492827e5f015",
9 | "fee": "500000000",
10 | "amount": "0",
11 | "asset": {
12 | "ipfs": "QmR45FmbVVrixReBwJkhEKde2qwHYaQzGxu4ZoDeswuF9w"
13 | },
14 | "signatures": [
15 | "006323832cc6627fdafef14f6487224947b50fb67ecf39d508cae53a504e38d0616cbe03c814501124236c2812b0a62463d1cfcdaea4db1368732ce9543e94573b",
16 | "015698acde626fe38cd5d374e225ac0b0a8fc60debcf4d389e73f227f13c4768f4168016745619addd5474378de08e3534e1ffdc01b857c1b31abc4c6fa8a85867",
17 | "02da0fe52c86505c6cf17ba7e9a0402d7cfef1574d1938a2c55adfc779f23e7795a4ee81515a1e8150824dededafbb2ecc3a067b697a3aac5b0a4f564304b699be"
18 | ],
19 | "id": "533ad038573215683197ed795f49020efb5a495ce35a87cda2262a891aaa0650"
20 | },
21 | "serialized": "ff0217010000000500010000000000000003fb92a2c3efaa177d8a51fc0cdf41905098d8b2cd900cbac94617492827e5f0150065cd1d000000000012202853f0f11ab91d73b73a2a86606103f45dd469ad2e89ec6f9a25febe8758d3fe006323832cc6627fdafef14f6487224947b50fb67ecf39d508cae53a504e38d0616cbe03c814501124236c2812b0a62463d1cfcdaea4db1368732ce9543e94573b015698acde626fe38cd5d374e225ac0b0a8fc60debcf4d389e73f227f13c4768f4168016745619addd5474378de08e3534e1ffdc01b857c1b31abc4c6fa8a8586702da0fe52c86505c6cf17ba7e9a0402d7cfef1574d1938a2c55adfc779f23e7795a4ee81515a1e8150824dededafbb2ecc3a067b697a3aac5b0a4f564304b699be"
22 | }
23 |
--------------------------------------------------------------------------------
/docs/fixtures/type_7.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 2,
3 | "network": 23,
4 | "type": 7,
5 | "nonce": "2",
6 | "senderPublicKey": "037a12518205254e6ebf25290d9786fd9821c43bb7319c9fc2499c8d472809dfaf",
7 | "fee": "2500000000",
8 | "amount": "0",
9 | "signature": "ad7a61a76433260ef9dc687311ab6c657f6c733dbf1a80c3514da823d43226235a70a94fa1a0b8cb2f4b3d0be5011945bfbe8c8fc5b5ca0e07f6c2a37e3cf11b",
10 | "id": "ee2a5253e28f66d5546b28bba96b4fa88973305e2e0d3b82afd5b3386ab0b6d4",
11 | "serialized": "ff02170100000007000200000000000000037a12518205254e6ebf25290d9786fd9821c43bb7319c9fc2499c8d472809dfaf00f902950000000000ad7a61a76433260ef9dc687311ab6c657f6c733dbf1a80c3514da823d43226235a70a94fa1a0b8cb2f4b3d0be5011945bfbe8c8fc5b5ca0e07f6c2a37e3cf11b"
12 | }
13 |
--------------------------------------------------------------------------------
/docs/fixtures/type_7.md:
--------------------------------------------------------------------------------
1 |
2 | # Type 7: Delegate Resignation
3 |
4 | ## Signed Json Payload
5 |
6 | ```json
7 | {
8 | "version": 2,
9 | "network": 23,
10 | "type": 7,
11 | "nonce": "2",
12 | "senderPublicKey": "037a12518205254e6ebf25290d9786fd9821c43bb7319c9fc2499c8d472809dfaf",
13 | "fee": "2500000000",
14 | "amount": "0",
15 | "signature": "ad7a61a76433260ef9dc687311ab6c657f6c733dbf1a80c3514da823d43226235a70a94fa1a0b8cb2f4b3d0be5011945bfbe8c8fc5b5ca0e07f6c2a37e3cf11b",
16 | "id": "ee2a5253e28f66d5546b28bba96b4fa88973305e2e0d3b82afd5b3386ab0b6d4"
17 | }
18 | ```
19 |
20 | ## Serialized Payload
21 |
22 | ```shell
23 | ff02170100000007000200000000000000037a12518205254e6ebf25290d9786fd9821c43bb7319c9fc2499c8d472809dfaf00f902950000000000ad7a61a76433260ef9dc687311ab6c657f6c733dbf1a80c3514da823d43226235a70a94fa1a0b8cb2f4b3d0be5011945bfbe8c8fc5b5ca0e07f6c2a37e3cf11b
24 | ```
25 |
26 | ## Deserializing the Hex
27 |
28 | | Key | Pos. | Size
_(bytes)_ | Value
_(hex)_ |
29 | | :-- | :--: | :---------------: | :---------------- |
30 | | **Header:** | **[0]** | **1** | `0xff` |
31 | | **Version:** | **[1]** | **1** | `0x02` |
32 | | **Network:** | **[2]** | **1** | `0x17` |
33 | | **Typegroup:** | **[3]** | **4** | `0x01000000` |
34 | | **Type:** | **[7]** | **2** | `0x0700` |
35 | | **Nonce:** | **[9]** | **8** | `0x0200000000000000` |
36 | | **SenderPublicKey:** | **[17]** | **33** | `0x037a12518205254e6ebf25290d9786fd9821c43bb7319c9fc2499c8d472809dfaf` |
37 | | **Fee:** | **[50]** | **8** | `0x00f9029500000000` |
38 | | **VendorField Length:** | **[58]** | **1** | `0x00` |
39 | | **Amount:** | **[..]** | **0** | Not Serialized |
40 | | **Signature:** | **[59]** | **64** | `0xad7a61a76433260ef9dc687311ab6c657f6c733dbf1a80c3514da823d43226235a70a94fa1a0b8cb2f4b3d0be5011945bfbe8c8fc5b5ca0e07f6c2a37e3cf11b` |
41 |
42 | ## Example Ledger Payload
43 |
44 | ```shell
45 | python3 examples/example_helper.py --tx ff02170100000007000200000000000000037a12518205254e6ebf25290d9786fd9821c43bb7319c9fc2499c8d472809dfaf00f902950000000000
46 | ```
47 |
--------------------------------------------------------------------------------
/docs/fixtures/type_8.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 2,
3 | "network": 23,
4 | "type": 8,
5 | "nonce": "2",
6 | "senderPublicKey": "020d272fab67c179a9e4df4d006344d3ca47fb531b4246b483373940f0603a9216",
7 | "fee": "10000000",
8 | "amount": "1",
9 | "recipientId": "ATNGUiu6sYRb7MXtdcVc7KjoyM6TdfuoC1",
10 | "asset": {
11 | "lock": {
12 | "secretHash": "09b9a28393efd02fcd76a21b0f0f55ba2aad8f3640ff8cae86de033a9cfbd78c",
13 | "expiration": {
14 | "type": 1,
15 | "value": 78740307
16 | }
17 | }
18 | },
19 | "signature": "11b1c06b4e5ba7c196f6f36fca2540275173a472e61581e949cd24a7cf5ee98af6a74f3c919f9b82a2e65b51b737bdf22f7a08ffcf52b88dc4a16d6ac5c10bfe",
20 | "id": "f84efeab77224af8959301a7185597a7cfbfbc9a4d99cb021af62f3714feb9d3",
21 | "serialized": "ff02170100000008000200000000000000020d272fab67c179a9e4df4d006344d3ca47fb531b4246b483373940f0603a9216809698000000000000010000000000000009b9a28393efd02fcd76a21b0f0f55ba2aad8f3640ff8cae86de033a9cfbd78c01537bb104177f2a95c7076ea278776d8fcecc5b18e588976da611b1c06b4e5ba7c196f6f36fca2540275173a472e61581e949cd24a7cf5ee98af6a74f3c919f9b82a2e65b51b737bdf22f7a08ffcf52b88dc4a16d6ac5c10bfe"
22 | }
23 |
--------------------------------------------------------------------------------
/docs/fixtures/type_8.md:
--------------------------------------------------------------------------------
1 |
2 | # Type 8: HTLC Lock
3 |
4 | ## Signed Json Payload
5 |
6 | ```json
7 | {
8 | "version": 2,
9 | "network": 23,
10 | "type": 8,
11 | "nonce": "2",
12 | "senderPublicKey": "020d272fab67c179a9e4df4d006344d3ca47fb531b4246b483373940f0603a9216",
13 | "fee": "10000000",
14 | "amount": "1",
15 | "recipientId": "ATNGUiu6sYRb7MXtdcVc7KjoyM6TdfuoC1",
16 | "asset": {
17 | "lock": {
18 | "secretHash": "09b9a28393efd02fcd76a21b0f0f55ba2aad8f3640ff8cae86de033a9cfbd78c",
19 | "expiration": {
20 | "type": 1,
21 | "value": 78740307
22 | }
23 | }
24 | },
25 | "signature": "11b1c06b4e5ba7c196f6f36fca2540275173a472e61581e949cd24a7cf5ee98af6a74f3c919f9b82a2e65b51b737bdf22f7a08ffcf52b88dc4a16d6ac5c10bfe",
26 | "id": "f84efeab77224af8959301a7185597a7cfbfbc9a4d99cb021af62f3714feb9d3"
27 | }
28 | ```
29 |
30 | ## Serialized Payload
31 |
32 | ```shell
33 | ff02170100000008000200000000000000020d272fab67c179a9e4df4d006344d3ca47fb531b4246b483373940f0603a9216809698000000000000010000000000000009b9a28393efd02fcd76a21b0f0f55ba2aad8f3640ff8cae86de033a9cfbd78c01537bb104177f2a95c7076ea278776d8fcecc5b18e588976da611b1c06b4e5ba7c196f6f36fca2540275173a472e61581e949cd24a7cf5ee98af6a74f3c919f9b82a2e65b51b737bdf22f7a08ffcf52b88dc4a16d6ac5c10bfe
34 | ```
35 |
36 | ## Deserializing the Hex
37 |
38 | | Key | Pos. | Size
_(bytes)_ | Value
_(hex)_ |
39 | | :-- | :--: | :---------------: | :---------------- |
40 | | **Header:** | **[0]** | **1** | `0xff` |
41 | | **Version:** | **[1]** | **1** | `0x02` |
42 | | **Network:** | **[2]** | **1** | `0x17` |
43 | | **Typegroup:** | **[3]** | **4** | `0x01000000` |
44 | | **Type:** | **[7]** | **2** | `0x0800` |
45 | | **Nonce:** | **[9]** | **8** | `0x0200000000000000` |
46 | | **SenderPublicKey:** | **[17]** | **33** | `0x020d272fab67c179a9e4df4d006344d3ca47fb531b4246b483373940f0603a9216` |
47 | | **Fee:** | **[50]** | **8** | `0x8096980000000000` |
48 | | **VendorField Length:** | **[58]** | **1** | `0x00` |
49 | | **Amount:** | **[59]** | **8** | `0x0100000000000000` |
50 | | **Secret Hash:** | **[67]** | **32** | `0x09b9a28393efd02fcd76a21b0f0f55ba2aad8f3640ff8cae86de033a9cfbd78c` |
51 | | **Expiration Type:** | **[99]** | **1** | `0x01` |
52 | | **Expiration Value:** | **[100]** | **4** | `0x537bb104` |
53 | | **Recipient:** | **[104]** | **21** | `0x177f2a95c7076ea278776d8fcecc5b18e588976da6` |
54 | | **Signature:** | **[125]** | **64** | `0x11b1c06b4e5ba7c196f6f36fca2540275173a472e61581e949cd24a7cf5ee98af6a74f3c919f9b82a2e65b51b737bdf22f7a08ffcf52b88dc4a16d6ac5c10bfe` |
55 |
56 | ## Example Ledger Payload
57 |
58 | ```shell
59 | python3 examples/example_helper.py --tx ff02170100000008000200000000000000020d272fab67c179a9e4df4d006344d3ca47fb531b4246b483373940f0603a9216809698000000000000010000000000000009b9a28393efd02fcd76a21b0f0f55ba2aad8f3640ff8cae86de033a9cfbd78c01537bb104177f2a95c7076ea278776d8fcecc5b18e588976da6
60 | ```
61 |
--------------------------------------------------------------------------------
/docs/fixtures/type_8_multi_sign.json:
--------------------------------------------------------------------------------
1 | {
2 | "data": {
3 | "version": 2,
4 | "network": 23,
5 | "typeGroup": 1,
6 | "type": 8,
7 | "nonce": "1",
8 | "senderPublicKey": "03fb92a2c3efaa177d8a51fc0cdf41905098d8b2cd900cbac94617492827e5f015",
9 | "fee": "10000000",
10 | "amount": "200000000",
11 | "recipientId": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC",
12 | "asset": {
13 | "lock": {
14 | "secretHash": "0f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454",
15 | "expiration": {
16 | "type": 1,
17 | "value": 1607104000
18 | }
19 | }
20 | },
21 | "signatures": [
22 | "00c874d61a8f0b9abfc0f962a09ccce59b67375a468572953a56e1f990a220eef71f1853160242265505802b266a2ae9f76c870cfe4ade51451d75871c4c1e7bb6",
23 | "016b0162c6f9613515dd35242cca52c3f81738596d25d41c755ad374f42a9fae86a47e4a00aea576c10e6cb308245aaabd2b636e59083752a472899884e7a732a1",
24 | "025628b1a36409bc85afd313993d4a19b93644aeb2bfe87d885a50e29657be148d512e670b8e99172abbdc6cbab1a054cb00f5acc24724fb876f955c8f0eb604f5"
25 | ],
26 | "id": "67b5f4a8aebe678b8d535e165f598d2bce94293f5464756fdb11e348c6ae23a0"
27 | },
28 | "serialized": "ff0217010000000800010000000000000003fb92a2c3efaa177d8a51fc0cdf41905098d8b2cd900cbac94617492827e5f01580969800000000000000c2eb0b000000000f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454010076ca5f170995750207ecaf0ccf251c1265b92ad84f55366200c874d61a8f0b9abfc0f962a09ccce59b67375a468572953a56e1f990a220eef71f1853160242265505802b266a2ae9f76c870cfe4ade51451d75871c4c1e7bb6016b0162c6f9613515dd35242cca52c3f81738596d25d41c755ad374f42a9fae86a47e4a00aea576c10e6cb308245aaabd2b636e59083752a472899884e7a732a1025628b1a36409bc85afd313993d4a19b93644aeb2bfe87d885a50e29657be148d512e670b8e99172abbdc6cbab1a054cb00f5acc24724fb876f955c8f0eb604f5"
29 | }
30 |
--------------------------------------------------------------------------------
/docs/fixtures/type_8_vendorfield.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 2,
3 | "network": 23,
4 | "type": 8,
5 | "nonce": "0",
6 | "senderPublicKey": "034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed192",
7 | "fee": "10000000",
8 | "amount": "1",
9 | "vendorField": "Hello World",
10 | "recipientId": "AZRJYXhknRmKMuwgqbYxr8FsfHQKn8Fk9K",
11 | "asset": {
12 | "lock": {
13 | "secretHash": "09b9a28393efd02fcd76a21b0f0f55ba2aad8f3640ff8cae86de033a9cfbd78c",
14 | "expiration": {
15 | "type": 1,
16 | "value": 88506746
17 | }
18 | }
19 | },
20 | "signature": "3045022100a1cd1c89cb8e1accb0fb394dc5e14ee49385fb990c4b6ea60af37f0523213b950220037c0f8538c04d0041c3f8a3737a8e0fa7c59cde9d6ead9fad6101f0d5a85ea8",
21 | "id": "f981d2590e59d4ae8d563aa906899ebce0a56e93fde665fd7760152108bf7209",
22 | "serialized": "ff02170100000008000000000000000000034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000000b48656c6c6f20576f726c64010000000000000009b9a28393efd02fcd76a21b0f0f55ba2aad8f3640ff8cae86de033a9cfbd78c017a81460517c18e4fdcd78bf9a9eac22e91d52edfeb04bc8e9e3045022100a1cd1c89cb8e1accb0fb394dc5e14ee49385fb990c4b6ea60af37f0523213b950220037c0f8538c04d0041c3f8a3737a8e0fa7c59cde9d6ead9fad6101f0d5a85ea8"
23 | }
24 |
--------------------------------------------------------------------------------
/docs/fixtures/type_8_vendorfield_multi_sign.json:
--------------------------------------------------------------------------------
1 | {
2 | "data": {
3 | "version": 2,
4 | "network": 23,
5 | "typeGroup": 1,
6 | "type": 8,
7 | "nonce": "1",
8 | "senderPublicKey": "03fb92a2c3efaa177d8a51fc0cdf41905098d8b2cd900cbac94617492827e5f015",
9 | "fee": "10000000",
10 | "amount": "200000000",
11 | "vendorFieldHex": "74686973206973206120746f70207365637265742076656e646f72206669656c64",
12 | "vendorField": "this is a top secret vendor field",
13 | "recipientId": "AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC",
14 | "asset": {
15 | "lock": {
16 | "secretHash": "0f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454",
17 | "expiration": {
18 | "type": 1,
19 | "value": 1607104000
20 | }
21 | }
22 | },
23 | "signatures": [
24 | "00b6eee2df1bb8a3e0ef265a1ff86c94b4171f66b1f2ca42f6c9b6710501f95060c63463cb2349fac80f3207f3514ba23bbb68f9c16d3a892d4516fb10a458ba4d",
25 | "01df90d5fa936368e742c4ececea9637effff33695aa5570ce97277d353873a1a1755802be31eb0703a42570bb28ad06de3cb45c23df927777efcaf5c692201c07",
26 | "02720b042334205a58451a47ed4d7075b3e70dbe42b56d9b0d075dff138206780d8585ff298eebb801c92cd77dc08e498567f751aafbbe114ca2e82d301a9920f4"
27 | ],
28 | "id": "2e61254c4b0f6f5aa5e20bd73e968b9e7e24c7aa23647ee2781a0af053445359"
29 | },
30 | "serialized": "ff0217010000000800010000000000000003fb92a2c3efaa177d8a51fc0cdf41905098d8b2cd900cbac94617492827e5f01580969800000000002174686973206973206120746f70207365637265742076656e646f72206669656c6400c2eb0b000000000f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454010076ca5f170995750207ecaf0ccf251c1265b92ad84f55366200b6eee2df1bb8a3e0ef265a1ff86c94b4171f66b1f2ca42f6c9b6710501f95060c63463cb2349fac80f3207f3514ba23bbb68f9c16d3a892d4516fb10a458ba4d01df90d5fa936368e742c4ececea9637effff33695aa5570ce97277d353873a1a1755802be31eb0703a42570bb28ad06de3cb45c23df927777efcaf5c692201c0702720b042334205a58451a47ed4d7075b3e70dbe42b56d9b0d075dff138206780d8585ff298eebb801c92cd77dc08e498567f751aafbbe114ca2e82d301a9920f4"
31 | }
32 |
--------------------------------------------------------------------------------
/docs/fixtures/type_9.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 2,
3 | "network": 23,
4 | "type": 9,
5 | "nonce": "3",
6 | "senderPublicKey": "039d974aa6feff6a19fde69a8a8b25b991798e98252765a887118ba61218f473a2",
7 | "fee": "0",
8 | "amount": "0",
9 | "asset": {
10 | "claim": {
11 | "lockTransactionId": "f84efeab77224af8959301a7185597a7cfbfbc9a4d99cb021af62f3714feb9d3",
12 | "unlockSecret": "f5ea877a311ced90cf4524cb489e972f"
13 | }
14 | },
15 | "signature": "c2b9f3655174c13686dde428cf18d5d18f465712985a7086b04860457e8d2db64443083bdf69fdc5b94dcd2c4c722606cf0e058ffae98d8f9f069177c5c189ab",
16 | "id": "d8acf49eba509e94494f454a86add1fab8b2130f223c9cc25e8e92745a584813",
17 | "serialized": "ff02170100000009000300000000000000039d974aa6feff6a19fde69a8a8b25b991798e98252765a887118ba61218f473a2000000000000000000f84efeab77224af8959301a7185597a7cfbfbc9a4d99cb021af62f3714feb9d36635656138373761333131636564393063663435323463623438396539373266c2b9f3655174c13686dde428cf18d5d18f465712985a7086b04860457e8d2db64443083bdf69fdc5b94dcd2c4c722606cf0e058ffae98d8f9f069177c5c189ab"
18 | }
19 |
--------------------------------------------------------------------------------
/docs/fixtures/type_9.md:
--------------------------------------------------------------------------------
1 |
2 | # Type 9: HTLC Claim
3 |
4 | ## Signed Json Payload
5 |
6 | ```json
7 | {
8 | "version": 2,
9 | "network": 23,
10 | "type": 9,
11 | "nonce": "3",
12 | "senderPublicKey": "039d974aa6feff6a19fde69a8a8b25b991798e98252765a887118ba61218f473a2",
13 | "fee": "0",
14 | "amount": "0",
15 | "asset": {
16 | "claim": {
17 | "lockTransactionId": "f84efeab77224af8959301a7185597a7cfbfbc9a4d99cb021af62f3714feb9d3",
18 | "unlockSecret": "f5ea877a311ced90cf4524cb489e972f"
19 | }
20 | },
21 | "signature": "c2b9f3655174c13686dde428cf18d5d18f465712985a7086b04860457e8d2db64443083bdf69fdc5b94dcd2c4c722606cf0e058ffae98d8f9f069177c5c189ab",
22 | "id": "d8acf49eba509e94494f454a86add1fab8b2130f223c9cc25e8e92745a584813"
23 | }
24 | ```
25 |
26 | ## Serialized Payload
27 |
28 | ```shell
29 | ff02170100000009000300000000000000039d974aa6feff6a19fde69a8a8b25b991798e98252765a887118ba61218f473a2000000000000000000f84efeab77224af8959301a7185597a7cfbfbc9a4d99cb021af62f3714feb9d36635656138373761333131636564393063663435323463623438396539373266c2b9f3655174c13686dde428cf18d5d18f465712985a7086b04860457e8d2db64443083bdf69fdc5b94dcd2c4c722606cf0e058ffae98d8f9f069177c5c189ab
30 | ```
31 |
32 | ## Deserializing the Hex
33 |
34 | | Key | Pos. | Size
_(bytes)_ | Value
_(hex)_ |
35 | | :-- | :--: | :---------------: | :---------------- |
36 | | **Header:** | **[0]** | **1** | `0xff` |
37 | | **Version:** | **[1]** | **1** | `0x02` |
38 | | **Network:** | **[2]** | **1** | `0x17` |
39 | | **TypeGroup:** | **[3]** | **4** | `0x01000000` |
40 | | **Type:** | **[7]** | **2** | `0x0900` |
41 | | **Nonce:** | **[9]** | **8** | `0x0200000000000000` |
42 | | **SenderPublicKey:** | **[17]** | **33** | `0x039d974aa6feff6a19fde69a8a8b25b991798e98252765a887118ba61218f473a2` |
43 | | **Fee:** | **[50]** | **8** | `0x0000000000000000` |
44 | | **VendorField Length:** | **[58]** | **1** | `0x00` |
45 | | **Lock Id:** | **[59]** | **32** | `0xf84efeab77224af8959301a7185597a7cfbfbc9a4d99cb021af62f3714feb9d3` |
46 | | **Unlock Secret:** | **[91]** | **32** | `0x6635656138373761333131636564393063663435323463623438396539373266` |
47 | | **Signature:** | **[123]** | **64** | `0xc2b9f3655174c13686dde428cf18d5d18f465712985a7086b04860457e8d2db64443083bdf69fdc5b94dcd2c4c722606cf0e058ffae98d8f9f069177c5c189ab` |
48 |
49 | ## Example Ledger Payload
50 |
51 | ```shell
52 | python3 examples/example_helper.py --tx ff02170100000009000300000000000000039d974aa6feff6a19fde69a8a8b25b991798e98252765a887118ba61218f473a2000000000000000000f84efeab77224af8959301a7185597a7cfbfbc9a4d99cb021af62f3714feb9d36635656138373761333131636564393063663435323463623438396539373266
53 | ```
54 |
--------------------------------------------------------------------------------
/docs/fixtures/type_9_multi_sign.json:
--------------------------------------------------------------------------------
1 | {
2 | "data": {
3 | "version": 2,
4 | "network": 23,
5 | "typeGroup": 1,
6 | "type": 9,
7 | "nonce": "1",
8 | "senderPublicKey": "03fb92a2c3efaa177d8a51fc0cdf41905098d8b2cd900cbac94617492827e5f015",
9 | "fee": "0",
10 | "amount": "0",
11 | "asset": {
12 | "claim": {
13 | "lockTransactionId": "943c220691e711c39c79d437ce185748a0018940e1a4144293af9d05627d2eb4",
14 | "unlockSecret": "my secret that should be 32bytes"
15 | }
16 | },
17 | "signatures": [
18 | "0078149337d8a903cff63fe39063c47a50fa211c53f03b9dec98e8ffaf001149f89aefbbe7a363296ce273744a96d2a09cd2a90563375866d5ba6bbaf4a7fe0de5",
19 | "015cf52ebd07ad63de9670b0d9176aadb1e6bce4fd533141af4bc8ec87d7998e442b7021849b12a043d66bff1bf9b47f5b1970a0468d32c6a9fdec1f0b988ca7c9",
20 | "026d20540724e00ff1e07a905ed9339e6f4e07f0a0fffc2c4bbe4f200fa5c77538ab3b1479e2d4666227bd8f79ba9148597347f916b6ce17af2e23a13da7433978"
21 | ],
22 | "id": "834fc082dc698f2703ad1f1d48111ab52433d4d7ae27b59ff68abf651c706144"
23 | },
24 | "serialized": "ff0217010000000900010000000000000003fb92a2c3efaa177d8a51fc0cdf41905098d8b2cd900cbac94617492827e5f015000000000000000000943c220691e711c39c79d437ce185748a0018940e1a4144293af9d05627d2eb46d792073656372657420746861742073686f756c6420626520333262797465730078149337d8a903cff63fe39063c47a50fa211c53f03b9dec98e8ffaf001149f89aefbbe7a363296ce273744a96d2a09cd2a90563375866d5ba6bbaf4a7fe0de5015cf52ebd07ad63de9670b0d9176aadb1e6bce4fd533141af4bc8ec87d7998e442b7021849b12a043d66bff1bf9b47f5b1970a0468d32c6a9fdec1f0b988ca7c9026d20540724e00ff1e07a905ed9339e6f4e07f0a0fffc2c4bbe4f200fa5c77538ab3b1479e2d4666227bd8f79ba9148597347f916b6ce17af2e23a13da7433978"
25 | }
26 |
--------------------------------------------------------------------------------
/examples/README.md:
--------------------------------------------------------------------------------
1 |
2 | # ARK Ledger Example Tests
3 |
4 | ## Requirements
5 |
6 | * Ledger Nano S Hardware Wallet
7 | * Python
8 | * [Ledger-Vagrant](https://github.com/sleepdefic1t/ledger-vagrant).
9 |
10 | ## Running all examples
11 |
12 | ```shell
13 | sh ./examples/all.sh
14 | ```
15 |
16 | ## Running individual examples
17 |
18 | ```shell
19 | sh ./examples/v1.sh # DEPRECATED
20 | sh ./examples/v2.sh
21 | sh ./examples/message.sh
22 | ```
23 |
--------------------------------------------------------------------------------
/examples/all.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | NANOX='0'
4 | if [ "$1" == "-x" ]; then
5 | NANOX='1'
6 | fi
7 |
8 | TEST_DIR="$(dirname "$0")"
9 |
10 | printf "\n\n%s\n\n" "Running all ARK Ledger Examples.."
11 | bash ./"${TEST_DIR}"/v1.sh # (DEPRECATED)
12 | bash ./"${TEST_DIR}"/v2.sh
13 | if [[ "$NANOX" == '1' ]]; then
14 | bash ./"${TEST_DIR}"/multi_signature.sh
15 | fi
16 | bash ./"${TEST_DIR}"/message.sh
17 | printf "\n"
18 |
--------------------------------------------------------------------------------
/examples/v1.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | printf "\n\n%s\n" "v1 (DEPRECATED) Examples"
4 |
5 | printf "\n%s\n" "Testing a v1 (DEPRECATED) Transfer Transaction."
6 | python3 "$(dirname "$0")"/example_helper.py --tx ff011e0007627802034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000000000c2eb0b00000000000000001e0995750207ecaf0ccf251c1265b92ad84f553662 --ecdsa
7 |
8 | printf "\n%s\n" "Testing a v1 (DEPRECATED) Transfer Transaction with a VendorField."
9 | python3 "$(dirname "$0")"/example_helper.py --tx ff011e0007627802034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19280969800000000000b48656c6c6f20576f726c6400c2eb0b00000000000000001e0995750207ecaf0ccf251c1265b92ad84f553662 --ecdsa
10 |
11 | printf "\n%s\n" "Testing a v1 (DEPRECATED) Vote Transaction."
12 | python3 "$(dirname "$0")"/example_helper.py --tx ff011e0376b87502034151a3ec46b5670a682b0a63394f863587d1bc97483b1b6c70eb58e7f0aed19200e1f50500000000000101022cca9529ec97a772156c152a00aad155ee6708243e65c9d211a589cb5d43234d --ecdsa
13 |
--------------------------------------------------------------------------------
/glyphs/badge_ark.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/badge_ark.gif
--------------------------------------------------------------------------------
/glyphs/badge_ripple.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/badge_ripple.gif
--------------------------------------------------------------------------------
/glyphs/badge_transaction.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/badge_transaction.gif
--------------------------------------------------------------------------------
/glyphs/icon.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon.gif
--------------------------------------------------------------------------------
/glyphs/icon_ark.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_ark.gif
--------------------------------------------------------------------------------
/glyphs/icon_back.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_back.gif
--------------------------------------------------------------------------------
/glyphs/icon_back_x.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_back_x.gif
--------------------------------------------------------------------------------
/glyphs/icon_certificate.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_certificate.gif
--------------------------------------------------------------------------------
/glyphs/icon_coggle.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_coggle.gif
--------------------------------------------------------------------------------
/glyphs/icon_crossmark.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_crossmark.gif
--------------------------------------------------------------------------------
/glyphs/icon_dashboard.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_dashboard.gif
--------------------------------------------------------------------------------
/glyphs/icon_dashboard_x.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_dashboard_x.gif
--------------------------------------------------------------------------------
/glyphs/icon_down.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_down.gif
--------------------------------------------------------------------------------
/glyphs/icon_eye.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_eye.gif
--------------------------------------------------------------------------------
/glyphs/icon_left.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_left.gif
--------------------------------------------------------------------------------
/glyphs/icon_right.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_right.gif
--------------------------------------------------------------------------------
/glyphs/icon_toggle_reset.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_toggle_reset.gif
--------------------------------------------------------------------------------
/glyphs/icon_toggle_set.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_toggle_set.gif
--------------------------------------------------------------------------------
/glyphs/icon_up.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_up.gif
--------------------------------------------------------------------------------
/glyphs/icon_validate_14.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_validate_14.gif
--------------------------------------------------------------------------------
/glyphs/icon_warning.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/glyphs/icon_warning.gif
--------------------------------------------------------------------------------
/icons/ark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/icons/ark.png
--------------------------------------------------------------------------------
/icons/icon.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/icons/icon.gif
--------------------------------------------------------------------------------
/icons/nanos_app_ark.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/icons/nanos_app_ark.gif
--------------------------------------------------------------------------------
/icons/nanox_app_ark.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/icons/nanox_app_ark.gif
--------------------------------------------------------------------------------
/nanox_app_ark.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArkEcosystem/ledger/7cf1d4588e35ea19355a66ba72b2a41e11064a51/nanox_app_ark.gif
--------------------------------------------------------------------------------
/scripts/provision.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | printf "\n\n%s\n\n" "Provisioning virtual machine..."
4 |
5 | printf "\n%s\n" "Installing Utilities"
6 | dpkg --add-architecture i386
7 | apt-get update > /dev/null
8 | apt-get install git curl python-dev python3-pip python-setuptools zlib1g-dev libjpeg-dev libudev-dev build-essential libusb-1.0-0-dev -y > /dev/null
9 | apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 libc6-dev-i386 -y > /dev/null
10 | pip3 install --upgrade setuptools
11 | pip3 install ledgerblue
12 | pip3 install Pillow
13 |
14 | if [ ! -d "/opt/bolos" ]; then
15 | printf "\n%s\n" "Setting up BOLOS environment"
16 | mkdir /opt/bolos
17 | mkdir /opt/bolos/CC
18 | mkdir /opt/bolos/SDK
19 |
20 | printf "\n%s\n" "Installing ARM compilers, this will take a few minutes..."
21 | cd /opt/bolos/CC || exit
22 | wget -q https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q1-update/+download/gcc-arm-none-eabi-5_3-2016q1-20160330-linux.tar.bz2
23 | tar xjf gcc-arm-none-eabi-5_3-2016q1-20160330-linux.tar.bz2
24 | ln -s /opt/bolos/CC/gcc-arm-none-eabi-5_3-2016q1/bin/arm-none-eabi-gcc /usr/bin/arm-none-eabi-gcc
25 |
26 | printf "\n%s\n" "Installing Clang compilers, this will take a few minutes..."
27 | wget -q http://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz
28 | tar xvf clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz
29 | mv clang+llvm-7.0.0-x86_64-linux-gnu-ubuntu-16.04 clang-arm-fropi
30 | chmod 757 -R clang-arm-fropi/
31 | chmod +x clang-arm-fropi/bin/clang
32 | ln -s /opt/bolos/CC/clang-arm-fropi/bin/clang /usr/bin/clang
33 | fi
34 |
35 | if [ ! -d "/opt/bolos/SDK/nanos-secure-sdk" ]; then
36 | printf "\n%s\n" "Fetching the Nano S SDK 1.6.1"
37 | cd /opt/bolos/SDK || exit
38 | git clone https://github.com/LedgerHQ/nanos-secure-sdk.git
39 | cd nanos-secure-sdk/ || exit
40 | git -c advice.detachedHead=false checkout tags/nanos-161
41 | fi
42 |
43 | # The NanoX SDK is not currently available to the public.
44 | # Contact LedgerHQ for more information about obtaining a copy.
45 | # - https://ledger-dev.slack.com/
46 | # if [ ! -d "/opt/bolos/SDK/nanox-secure-sdk" ]; then
47 | # printf "\n%s\n" "Fetching the Nano X SDK"
48 | # cd /opt/bolos/
49 | # # git clone https://github.com/LedgerHQ/nanox-secure-sdk.git
50 | # fi
51 |
52 | printf "\n\n%s\n\n" "Finetuning rights for USB access"
53 | sudo bash /vagrant/scripts/udev.sh
54 | usermod -a -G plugdev vagrant
55 |
56 | printf "\n\n%s\n" "Setting up bash profile"
57 | echo "" >> /home/vagrant/.bashrc
58 | echo "# Custom variables for Ledger Development" >> /home/vagrant/.bashrc
59 | echo "export BOLOS_ENV=/opt/bolos/CC" >> /home/vagrant/.bashrc
60 | echo "export ARM_HOME=/opt/bolos/CC/gcc-arm-none-eabi-5_3-2016q1" >> /home/vagrant/.bashrc
61 | echo "" >> /home/vagrant/.bashrc
62 | echo "export PATH=\$PATH:\$ARM_HOME/bin" >> /home/vagrant/.bashrc
63 | echo "" >> /home/vagrant/.bashrc
64 |
--------------------------------------------------------------------------------
/scripts/rebuild.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | NANOX='0'
4 | if [ "$1" == "-x" ]; then
5 | NANOX='1'
6 | fi
7 |
8 | if [[ "$NANOX" == '0' ]]; then
9 | export BOLOS_SDK=/opt/bolos/SDK/nanos-secure-sdk
10 | exec /usr/bin/env bash "$(dirname "$0")"/rebuild_nanos.sh
11 | else
12 | export BOLOS_SDK=/opt/bolos/SDK/nanox-secure-sdk
13 | exec /usr/bin/env bash "$(dirname "$0")"/rebuild_nanox.sh
14 | fi
15 |
--------------------------------------------------------------------------------
/scripts/rebuild_nanos.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | printf "\n%s\n\n" "Building for the Nano S..."
4 |
5 | make clean
6 | make
7 | make delete
8 | make load
9 |
--------------------------------------------------------------------------------
/scripts/rebuild_nanox.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Linker doesn't play nice with Vagrants directory mapping when building for the NanoX.
4 | # credit to @patriksletmo for the tip.
5 |
6 | printf "\n%s\n\n" "Building for the Nano X..."
7 |
8 | # clean the current project, in case a build was made in-source
9 | make clean
10 |
11 | # name the build dir after the project dir
12 | BUILD_DIR=/home/ubuntu/"${PWD##*/}"
13 |
14 | # clear the build dir if this project was already built here
15 | if [[ -d "$BUILD_DIR" ]]; then
16 | sudo rm -rf "$BUILD_DIR"
17 | fi
18 |
19 | # copy the project recursively and take ownership of the build directory
20 | sudo cp -R "$PWD" "$BUILD_DIR"
21 | sudo chown "$USER" -R "$BUILD_DIR"
22 |
23 | # move to the build directory
24 | cd "$BUILD_DIR" || exit
25 |
26 | make
27 |
28 | make delete
29 |
30 | make load
31 |
--------------------------------------------------------------------------------
/scripts/udev.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cat < /etc/udev/rules.d/20-hw1.rules
4 | # HW.1 / Nano
5 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="2581", ATTRS{idProduct}=="1b7c|2b7c|3b7c|4b7c", TAG+="uaccess", TAG+="udev-acl"
6 | # Blue
7 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0000|0000|0001|0002|0003|0004|0005|0006|0007|0008|0009|000a|000b|000c|000d|000e|000f|0010|0011|0012|0013|0014|0015|0016|0017|0018|0019|001a|001b|001c|001d|001e|001f", TAG+="uaccess", TAG+="udev-acl", MODE="0660", GROUP="plugdev"
8 | # Nano S
9 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0001|1000|1001|1002|1003|1004|1005|1006|1007|1008|1009|100a|100b|100c|100d|100e|100f|1010|1011|1012|1013|1014|1015|1016|1017|1018|1019|101a|101b|101c|101d|101e|101f", TAG+="uaccess", TAG+="udev-acl", MODE="0660", GROUP="plugdev"
10 | # Aramis
11 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0002|2000|2001|2002|2003|2004|2005|2006|2007|2008|2009|200a|200b|200c|200d|200e|200f|2010|2011|2012|2013|2014|2015|2016|2017|2018|2019|201a|201b|201c|201d|201e|201f", TAG+="uaccess", TAG+="udev-acl", MODE="0660", GROUP="plugdev"
12 | # HW2
13 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0003|3000|3001|3002|3003|3004|3005|3006|3007|3008|3009|300a|300b|300c|300d|300e|300f|3010|3011|3012|3013|3014|3015|3016|3017|3018|3019|301a|301b|301c|301d|301e|301f", TAG+="uaccess", TAG+="udev-acl", MODE="0660", GROUP="plugdev"
14 | # Nano X
15 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0004|4000|4001|4002|4003|4004|4005|4006|4007|4008|4009|400a|400b|400c|400d|400e|400f|4010|4011|4012|4013|4014|4015|4016|4017|4018|4019|401a|401b|401c|401d|401e|401f", TAG+="uaccess", TAG+="udev-acl", MODE="0660", GROUP="plugdev"
16 | EOF
17 |
18 | udevadm trigger
19 | udevadm control --reload-rules
20 |
--------------------------------------------------------------------------------
/src/approval.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *
26 | ******************************************************************************/
27 |
28 | #ifndef ARK_APPROVAL_H
29 | #define ARK_APPROVAL_H
30 |
31 | #include
32 | #include
33 |
34 | ////////////////////////////////////////////////////////////////////////////////
35 | unsigned int ioApprove(const bagl_element_t *e);
36 | unsigned int ioCancel(const bagl_element_t *e);
37 | unsigned int ioExit(const bagl_element_t *e);
38 |
39 | #endif // #define ARK_APPROVAL_H
40 |
--------------------------------------------------------------------------------
/src/crypto/hashing.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "crypto/hashing.h"
28 |
29 | #include
30 | #include
31 |
32 | #include
33 | #include
34 |
35 | ////////////////////////////////////////////////////////////////////////////////
36 | void hash256(uint8_t *in, size_t inSize, uint8_t *out) {
37 | cx_sha256_t ctx;
38 | cx_sha256_init(&ctx);
39 | cx_hash(&ctx.header, CX_LAST, in, inSize, out, CX_SHA256_SIZE);
40 | }
41 |
--------------------------------------------------------------------------------
/src/crypto/hashing.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_CRYPTO_HASHING_H
28 | #define ARK_CRYPTO_HASHING_H
29 |
30 | #include
31 | #include
32 |
33 | void hash256(uint8_t *in, size_t inSize, uint8_t *out);
34 |
35 | #endif // #define ARK_CRYPTO_HASHING_H
36 |
--------------------------------------------------------------------------------
/src/crypto/keys.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "crypto/keys.h"
28 |
29 | #include
30 | #include
31 |
32 | #include "constants.h"
33 |
34 | #include "utils/utils.h"
35 |
36 | ////////////////////////////////////////////////////////////////////////////////
37 | // Uncompressed Key must be 65-bytes. (0x04 + (x,y))
38 | // Compressed output buffer must be 33-bytes. (0x02/0x03 + (x))
39 | //
40 | // returns the compressed publicKey length if successful.
41 | //
42 | // ---
43 | size_t compressPublicKey(const uint8_t *uncompressed, uint8_t *compressed) {
44 | if (uncompressed == NULL || compressed == NULL) {
45 | return 0;
46 | }
47 |
48 | const uint8_t EC_PUBLICKEY_EVEN_PREFIX = 0x02;
49 | const uint8_t EC_PUBLICKEY_ODD_PREFIX = 0x03;
50 | const uint8_t EC_PUBLICKEY_UNCOMPRESSED_PREFIX = 0x04;
51 |
52 | if (uncompressed[0] != EC_PUBLICKEY_UNCOMPRESSED_PREFIX) {
53 | return 0;
54 | }
55 |
56 | // prepend the 'x'-value to represent whether 'y' is odd or even.
57 | compressed[0] = ((uncompressed[HASH_64_LEN] & 1)
58 | ? EC_PUBLICKEY_ODD_PREFIX
59 | : EC_PUBLICKEY_EVEN_PREFIX);
60 |
61 | MEMCOPY(&compressed[1], &uncompressed[1], HASH_32_LEN);
62 |
63 | return PUBLICKEY_COMPRESSED_LEN;
64 | }
65 |
--------------------------------------------------------------------------------
/src/crypto/keys.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_CRYPTO_KEYS_H
28 | #define ARK_CRYPTO_KEYS_H
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | #include "constants.h"
35 |
36 | ////////////////////////////////////////////////////////////////////////////////
37 | typedef struct public_key_context_t {
38 | uint8_t data[PUBLICKEY_UNCOMPRESSED_LEN];
39 | uint8_t chainCode[HASH_32_LEN];
40 | bool needsChainCode;
41 | } PublicKeyContext;
42 |
43 | ////////////////////////////////////////////////////////////////////////////////
44 | size_t compressPublicKey(const uint8_t *uncompressed, uint8_t *compressed);
45 |
46 | #endif // #define ARK_CRYPTO_KEYS_H
47 |
--------------------------------------------------------------------------------
/src/crypto/schnorr_bcrypto_410.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *
26 | ******************************************************************************/
27 |
28 | #ifndef ARK_CRYPTO_SCHNORR_BCRYPTO_410_H
29 | #define ARK_CRYPTO_SCHNORR_BCRYPTO_410_H
30 |
31 | #include
32 |
33 | ////////////////////////////////////////////////////////////////////////////////
34 | uint32_t schnorr_sign_bcrypto_410(const uint8_t *privateKey,
35 | const uint8_t *hash,
36 | uint8_t *signature);
37 |
38 | #endif // ARK_CRYPTO_SCHNORR_BCRYPTO_410_H
39 |
--------------------------------------------------------------------------------
/src/crypto/signing.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "crypto/signing.h"
28 |
29 | #include
30 |
31 | #include
32 | #include
33 |
34 | #include "constants.h"
35 |
36 | #include "schnorr_bcrypto_410.h"
37 |
38 | ////////////////////////////////////////////////////////////////////////////////
39 | uint32_t signEcdsa(const cx_ecfp_private_key_t *privateKey,
40 | const uint8_t *hash,
41 | uint8_t *signature,
42 | size_t signatureSize) {
43 | if (privateKey == NULL || hash == NULL || signature == NULL ||
44 | signatureSize < SIG_ECDSA_MIN_LEN ||
45 | signatureSize > SIG_ECDSA_MAX_LEN) {
46 | return 0;
47 | }
48 |
49 | return cx_ecdsa_sign(privateKey,
50 | CX_RND_RFC6979 | CX_LAST, CX_SHA256,
51 | hash, HASH_32_LEN,
52 | signature, signatureSize,
53 | NULL);
54 | }
55 |
56 | ////////////////////////////////////////////////////////////////////////////////
57 | uint32_t signSchnorr(const cx_ecfp_private_key_t *privateKey,
58 | const uint8_t *hash,
59 | uint8_t *signature) {
60 | if (privateKey == NULL || hash == NULL || signature == NULL) {
61 | return 0;
62 | }
63 |
64 | return schnorr_sign_bcrypto_410(privateKey->d, hash, signature);
65 | }
66 |
--------------------------------------------------------------------------------
/src/crypto/signing.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_CRYPTO_SIGNING_H
28 | #define ARK_CRYPTO_SIGNING_H
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | #include
35 | #include
36 |
37 | #include "constants.h"
38 |
39 | ////////////////////////////////////////////////////////////////////////////////
40 | typedef struct signing_context_t {
41 | cx_curve_t curve;
42 | uint8_t pathLength;
43 | uint32_t bip32Path[ADDRESS_MAX_BIP32_PATH];
44 | uint8_t data[MAX_RAW_OPERATION];
45 | uint32_t dataLength;
46 | bool isSchnorr;
47 | } SigningContext;
48 |
49 | ////////////////////////////////////////////////////////////////////////////////
50 | uint32_t signEcdsa(const cx_ecfp_private_key_t *privateKey,
51 | const uint8_t *hash,
52 | uint8_t *signature,
53 | size_t signatureSize);
54 |
55 | ////////////////////////////////////////////////////////////////////////////////
56 | uint32_t signSchnorr(const cx_ecfp_private_key_t *privateKey,
57 | const uint8_t *hash,
58 | uint8_t *signature);
59 |
60 | #endif // #define ARK_CRYPTO_SIGNING_H
61 |
--------------------------------------------------------------------------------
/src/display/context.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "display/context.h"
28 |
29 | ////////////////////////////////////////////////////////////////////////////////
30 | // Global DisplayContext instance
31 | DisplayContext displayCtx;
32 |
--------------------------------------------------------------------------------
/src/display/context.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_DISPLAY_CONTEXT_H
28 | #define ARK_DISPLAY_CONTEXT_H
29 |
30 | #include
31 |
32 | #include "platform.h"
33 |
34 | ////////////////////////////////////////////////////////////////////////////////
35 | static const size_t DISPLAY_CTX_TEXT_SIZE_EXT = 256;
36 |
37 | #if defined(SUPPORTS_LARGE_OPERATIONS)
38 | static const size_t DISPLAY_CTX_OP_SIZE = 21;
39 | static const size_t DISPLAY_CTX_STEP_COUNT = 40;
40 | static const size_t DISPLAY_CTX_TITLE_SIZE = DISPLAY_CTX_OP_SIZE - 1;
41 | static const size_t DISPLAY_CTX_TEXT_SIZE = 130;
42 | #else
43 | static const size_t DISPLAY_CTX_OP_SIZE = 18;
44 | static const size_t DISPLAY_CTX_STEP_COUNT = 5;
45 | static const size_t DISPLAY_CTX_TITLE_SIZE = DISPLAY_CTX_OP_SIZE - 3;
46 | static const size_t DISPLAY_CTX_TEXT_SIZE = 68;
47 | #endif
48 |
49 | ////////////////////////////////////////////////////////////////////////////////
50 | typedef struct display_context_t {
51 | char operation [DISPLAY_CTX_OP_SIZE];
52 | char title [DISPLAY_CTX_STEP_COUNT] [DISPLAY_CTX_TITLE_SIZE];
53 | char text [DISPLAY_CTX_STEP_COUNT] [DISPLAY_CTX_TEXT_SIZE];
54 |
55 | // For large display texts.
56 | // Should always be the last step in a UX display flow.
57 | //
58 | // e.g. Message, VendorField, IPFS DAG
59 | char title_ext [DISPLAY_CTX_TITLE_SIZE];
60 | char text_ext [DISPLAY_CTX_TEXT_SIZE_EXT];
61 | } DisplayContext;
62 |
63 | ////////////////////////////////////////////////////////////////////////////////
64 | extern DisplayContext displayCtx;
65 |
66 | #endif // ARK_DISPLAY_CONTEXT_H
--------------------------------------------------------------------------------
/src/display/display.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_DISPLAY_H
28 | #define ARK_DISPLAY_H
29 |
30 | #include "platform.h"
31 |
32 | #if defined(TARGET_NANOS) || defined(TARGET_NANOX)
33 | #include "display/nano.h"
34 | #endif // TARGET_NANOS || TARGET_NANOX
35 |
36 | #endif // #define ARK_DISPLAY_H
37 |
--------------------------------------------------------------------------------
/src/display/nano.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *
26 | * -----
27 | *
28 | * Parts of this software are based on Ledger Nano SDK
29 | *
30 | * (c) 2017 Ledger
31 | *
32 | * Licensed under the Apache License, Version 2.0 (the "License");
33 | * you may not use this file except in compliance with the License.
34 | * You may obtain a copy of the License at
35 | *
36 | * http://www.apache.org/licenses/LICENSE-2.0
37 | *
38 | * Unless required by applicable law or agreed to in writing, software
39 | * distributed under the License is distributed on an "AS IS" BASIS,
40 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41 | * See the License for the specific language governing permissions and
42 | * limitations under the License.
43 | ******************************************************************************/
44 |
45 | #ifndef ARK_DISPLAY_NANO_H
46 | #define ARK_DISPLAY_NANO_H
47 |
48 | #include
49 |
50 | ////////////////////////////////////////////////////////////////////////////////
51 | void SetUxDisplay(size_t steps, size_t extendedStep);
52 |
53 | ////////////////////////////////////////////////////////////////////////////////
54 | void ui_idle(void);
55 |
56 | #endif // #define ARK_DISPLAY_NANO_H
57 |
--------------------------------------------------------------------------------
/src/io.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *
26 | * -----
27 | *
28 | * Parts of this software are based on Ledger Nano SDK
29 | *
30 | * (c) 2017 Ledger
31 | *
32 | * Licensed under the Apache License, Version 2.0 (the "License");
33 | * you may not use this file except in compliance with the License.
34 | * You may obtain a copy of the License at
35 | *
36 | * http://www.apache.org/licenses/LICENSE-2.0
37 | *
38 | * Unless required by applicable law or agreed to in writing, software
39 | * distributed under the License is distributed on an "AS IS" BASIS,
40 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41 | * See the License for the specific language governing permissions and
42 | * limitations under the License.
43 | ******************************************************************************/
44 |
45 | #ifndef ARK_IO_H
46 | #define ARK_IO_H
47 |
48 | #include
49 | #include
50 |
51 | ////////////////////////////////////////////////////////////////////////////////
52 | uint8_t io_event(unsigned char channel);
53 | uint16_t io_exchange_al(unsigned char channel, unsigned short tx_len);
54 | void io_seproxyhal_display(const bagl_element_t *element);
55 |
56 | #endif // #define ARK_IO_H
57 |
--------------------------------------------------------------------------------
/src/operations.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_H
28 | #define ARK_OPERATIONS_H
29 |
30 | ////////////////////////////////////////////////////////////////////////////////
31 | void handleOperation(volatile unsigned int *flags, volatile unsigned int *tx);
32 |
33 | #endif // #define ARK_OPERATIONS_H
34 |
--------------------------------------------------------------------------------
/src/operations/message_op.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_MESSAGE_H
28 | #define ARK_OPERATIONS_MESSAGE_H
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | #include "constants.h"
35 |
36 | #include "utils/print.h"
37 | #include "utils/str.h"
38 | #include "utils/utils.h"
39 |
40 | #include "display/context.h"
41 | #include "display/display.h"
42 |
43 | ////////////////////////////////////////////////////////////////////////////////
44 | static const char *const UX_MESSAGE_LABELS[] = { "Message", "Length" };
45 | static const size_t UX_MESSAGE_STEPS = 2;
46 |
47 | ////////////////////////////////////////////////////////////////////////////////
48 | extern void SetUxDisplay(size_t steps, size_t extendedStep);
49 |
50 | ////////////////////////////////////////////////////////////////////////////////
51 | // Prepare a Message Operation for Display.
52 | //
53 | // - UTF8 Encoded
54 | // - 255 Byte Max
55 | //
56 | // ---
57 | bool handleMessage(const uint8_t *buffer, size_t length) {
58 | MEMSET_TYPE_BZERO(&displayCtx, DisplayContext);
59 |
60 | if (length == 0 || length > MAX_TEXT_LEN) {
61 | return false;
62 | }
63 |
64 | SPRINTF(displayCtx.operation, "%s", UX_MESSAGE_LABELS[0]);
65 | SPRINTF(displayCtx.title[0], "%s:", UX_MESSAGE_LABELS[1]);
66 | SPRINTF(displayCtx.title_ext, "%s:", UX_MESSAGE_LABELS[0]);
67 |
68 | // Message Length
69 | UintToString(length, displayCtx.text[0], sizeof(displayCtx.text[0]));
70 |
71 | // Message Text
72 | if (!IsPrintableAscii((const char*)buffer, length, false)) {
73 | return false;
74 | }
75 |
76 | SNPRINTF(displayCtx.text_ext, length + 1, "%.*s", (int)length, buffer);
77 |
78 | SetUxDisplay(UX_MESSAGE_STEPS, UX_MESSAGE_STEPS);
79 |
80 | return true;
81 | }
82 |
83 | #endif // #define ARK_OPERATIONS_MESSAGE_H
84 |
--------------------------------------------------------------------------------
/src/operations/transaction_op.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTION_H
28 | #define ARK_OPERATIONS_TRANSACTION_H
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | #include "transactions/deserializer.h"
35 |
36 | ////////////////////////////////////////////////////////////////////////////////
37 | bool handleTransaction(const uint8_t *buffer, size_t size) {
38 | return deserialize(buffer, size);
39 | }
40 |
41 | #endif // #ifndef ARK_OPERATIONS_TRANSACTION_H
42 |
--------------------------------------------------------------------------------
/src/operations/transactions/deserializer.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_DESERIALIZER_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_DESERIALIZER_H
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | ////////////////////////////////////////////////////////////////////////////////
35 | bool deserialize(const uint8_t *buffer, size_t size);
36 |
37 | #endif // #define ARK_OPERATIONS_TRANSACTIONS_DESERIALIZER_H
38 |
--------------------------------------------------------------------------------
/src/operations/transactions/deserializer_v1.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_DESERIALIZER_V1_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_DESERIALIZER_V1_H
29 |
30 | #include
31 | #include
32 |
33 | #include "transactions/transaction.h"
34 |
35 | ////////////////////////////////////////////////////////////////////////////////
36 | // !DEPRECATED
37 | size_t deserializeHeaderV1(Transaction *transaction,
38 | const uint8_t *buffer,
39 | size_t size);
40 |
41 | #endif // #define ARK_OPERATIONS_TRANSACTIONS_DESERIALIZER_V1_H
42 |
--------------------------------------------------------------------------------
/src/operations/transactions/offsets.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_TRANSACTIONS_DEFAULTS_OFFSETS_HPP
28 | #define ARK_TRANSACTIONS_DEFAULTS_OFFSETS_HPP
29 |
30 | #include
31 |
32 | ////////////////////////////////////////////////////////////////////////////////
33 | // v2 Transaction Offsets
34 | static const size_t HEADER_OFFSET = 0;
35 | static const size_t VERSION_OFFSET = 1;
36 | static const size_t NETWORK_OFFSET = 2;
37 | static const size_t TYPEGROUP_OFFSET = 3;
38 | static const size_t TYPE_OFFSET = 7;
39 | static const size_t SENDER_PUBLICKEY_OFFSET = 17;
40 | static const size_t FEE_OFFSET = 50;
41 | static const size_t VF_LEN_OFFSET = 58;
42 | static const size_t VF_OFFSET = 59;
43 |
44 | ////////////////////////////////////////////////////////////////////////////////
45 | // !DEPRECATED
46 | // v1 Transaction Offsets
47 | static const size_t TYPE_OFFSET_V1 = 3;
48 | static const size_t SENDER_PUBLICKEY_OFFSET_V1 = 8;
49 | static const size_t FEE_OFFSET_V1 = 41;
50 | static const size_t VF_LEN_OFFSET_V1 = 49;
51 | static const size_t VF_OFFSET_V1 = 50;
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/src/operations/transactions/transaction.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTION_H
28 | #define ARK_OPERATIONS_TRANSACTION_H
29 |
30 | #include
31 | #include
32 |
33 | #include "platform.h"
34 |
35 | #include "constants.h"
36 |
37 | #include "transactions/types/assets.h"
38 |
39 | #include "transactions/types/signatures.h"
40 |
41 | ////////////////////////////////////////////////////////////////////////////////
42 | typedef struct transaction_t {
43 | uint8_t header;
44 | uint8_t version;
45 | uint8_t network;
46 | uint32_t typeGroup;
47 | uint16_t type;
48 | uint8_t senderPublicKey[PUBLICKEY_COMPRESSED_LEN];
49 | uint64_t fee;
50 | size_t vendorFieldLength;
51 | uint8_t *vendorField;
52 | tx_asset_t asset;
53 | #if defined(SUPPORTS_MULTISIGNATURE)
54 | Signatures signatures;
55 | #endif // SUPPORTS_MULTISIGNATURE
56 | } Transaction;
57 |
58 | #endif // #define ARK_OPERATIONS_TRANSACTION_H
59 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/assets.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_TYPES_ASSETS_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_TYPES_ASSETS_H
29 |
30 | #include "transactions/types/transfer.h"
31 | #include "transactions/types/vote.h"
32 | #include "transactions/types/multi_signature.h"
33 | #include "transactions/types/ipfs.h"
34 | #include "transactions/types/htlc_lock.h"
35 | #include "transactions/types/htlc_claim.h"
36 | #include "transactions/types/htlc_refund.h"
37 |
38 | #include "platform.h"
39 |
40 | ////////////////////////////////////////////////////////////////////////////////
41 | typedef union tx_asset_t {
42 | // TypeGroup 1: Core
43 | Transfer transfer; // Type 0
44 | /* SecondSignatureRegistration secondSignature; // Type 1 */
45 | /* Delegate Registration // Type 2 */
46 | Vote vote; // Type 3
47 | #if defined(SUPPORTS_MULTISIGNATURE)
48 | MultiSignature multiSignature; // Type 4 */
49 | #endif // SUPPORTS_MULTISIGNATURE
50 | Ipfs ipfs; // Type 5
51 | /* MultiPayment // Type 6 */
52 | /* Delegate Resignation // Type 7 */
53 | HtlcLock htlcLock; // Type 8
54 | HtlcClaim htlcClaim; // Type 9
55 | HtlcRefund htlcRefund; // Type 10
56 | } tx_asset_t;
57 |
58 | #endif // ARK_OPERATIONS_TRANSACTIONS_TYPES_ASSETS_H
59 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/htlc_claim.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "transactions/types/htlc_claim.h"
28 |
29 | #include
30 | #include
31 |
32 | #include "constants.h"
33 |
34 | #include "utils/utils.h"
35 |
36 | ////////////////////////////////////////////////////////////////////////////////
37 | // Htlc Claim (Type 8) - 64 Bytes
38 | //
39 | // @param HtlcClaim *claim
40 | // @param uint8_t *buffer: The serialized buffer beginning at the Assets offset.
41 | // @param size_t size: The Asset Buffer Size.
42 | //
43 | // @return 0: error
44 | // @return > 0: asset size
45 | //
46 | // ---
47 | // Internals:
48 | //
49 | // Lock Transaction Id - 32 Bytes:
50 | // - MEMCOPY(claim->id, &buffer[0], 32);
51 | //
52 | // Unlock Secret - 32 Bytes
53 | // - MEMCOPY(claim->secret, &buffer[32], 32);
54 | //
55 | // ---
56 | size_t deserializeHtlcClaim(HtlcClaim *claim,
57 | const uint8_t *buffer,
58 | size_t size) {
59 | if (size < 2U * HASH_32_LEN) {
60 | return 0U;
61 | }
62 |
63 | MEMCOPY(claim->id, &buffer[0], HASH_32_LEN); // 32 Bytes
64 | MEMCOPY(claim->secret, &buffer[HASH_32_LEN], HASH_32_LEN); // 32 Bytes
65 |
66 | return 2U * HASH_32_LEN;
67 | }
68 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/htlc_claim.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_TYPES_HTLC_CLAIM_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_TYPES_HTLC_CLAIM_H
29 |
30 | #include
31 | #include
32 |
33 | #include "constants.h"
34 |
35 | ////////////////////////////////////////////////////////////////////////////////
36 | typedef struct htlc_claim_asset_t {
37 | uint8_t id[HASH_32_LEN];
38 | uint8_t secret[HASH_32_LEN];
39 | } HtlcClaim;
40 |
41 | ////////////////////////////////////////////////////////////////////////////////
42 | size_t deserializeHtlcClaim(HtlcClaim *claim, const uint8_t *buffer, size_t size);
43 |
44 | #endif // #define ARK_OPERATIONS_TRANSACTIONS_TYPES_HTLC_CLAIM_H
45 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/htlc_lock.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "transactions/types/htlc_lock.h"
28 |
29 | #include
30 | #include
31 |
32 | #include "constants.h"
33 |
34 | #include "utils/unpack.h"
35 | #include "utils/utils.h"
36 |
37 | ////////////////////////////////////////////////////////////////////////////////
38 | // Htlc Lock (Type 8) - 66 Bytes
39 | //
40 | // @param HtlcLock *lock
41 | // @param uint8_t *buffer: The serialized buffer at the Assets offset.
42 | // @param size_t size: The Asset Buffer Size.
43 | //
44 | // @return 0: error
45 | // @return > 0: asset size
46 | //
47 | // ---
48 | // Internals:
49 | //
50 | // Amount - 8 Bytes:
51 | // - lock->amount = U4LE(buffer, 0);
52 | //
53 | // Secret Hash - 32 Bytes
54 | // - MEMCOPY(lock->secretHash, &buffer[8], 32);
55 | //
56 | // Expiration Type- 1 Byte
57 | // - lock->expirationType = buffer[40];
58 | //
59 | // Expiration Value - 4 Bytes
60 | // - lock->expirationValue = U4LE(buffer, 41);
61 | //
62 | // RecipientId - 21 Bytes
63 | // - MEMCOPY(lock->recipientId, &buffer[45], 21);
64 | //
65 | // ---
66 | size_t deserializeHtlcLock(HtlcLock *lock, const uint8_t *buffer, size_t size) {
67 | if (size < TRANSACTION_TYPE_HTLC_LOCK_SIZE) {
68 | return 0U;
69 | }
70 |
71 | size_t offset = 0;
72 |
73 | lock->amount = U8LE(buffer, offset); // 8 Bytes
74 | offset += sizeof(uint64_t);
75 |
76 | MEMCOPY(lock->secretHash, &buffer[offset], HASH_32_LEN); // 32 Bytes
77 | offset += HASH_32_LEN;
78 |
79 | lock->expirationType = buffer[offset]; // 1 Byte
80 | offset += sizeof(uint8_t);
81 |
82 | lock->expiration = U4LE(buffer, offset); // 4 Bytes
83 | offset += sizeof(uint32_t);
84 |
85 | MEMCOPY(lock->recipientId, &buffer[offset], ADDRESS_HASH_LEN); // 21 Bytes
86 |
87 | return TRANSACTION_TYPE_HTLC_LOCK_SIZE;
88 | }
89 |
90 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/htlc_lock.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_ASSETS_HTLC_LOCK_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_ASSETS_HTLC_LOCK_H
29 |
30 | #include
31 | #include
32 |
33 | #include "constants.h"
34 |
35 | ////////////////////////////////////////////////////////////////////////////////
36 | static const size_t TRANSACTION_TYPE_HTLC_LOCK_SIZE = 66;
37 |
38 | ////////////////////////////////////////////////////////////////////////////////
39 | typedef struct htlc_lock_asset_t {
40 | uint64_t amount;
41 | uint8_t expirationType;
42 | uint32_t expiration;
43 | uint8_t secretHash[HASH_32_LEN];
44 | uint8_t recipientId[ADDRESS_HASH_LEN];
45 | } HtlcLock;
46 |
47 | ////////////////////////////////////////////////////////////////////////////////
48 | size_t deserializeHtlcLock(HtlcLock *lock, const uint8_t *buffer, size_t size);
49 |
50 | #endif // #define ARK_OPERATIONS_TRANSACTIONS_ASSETS_HTLC_LOCK_H
51 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/htlc_refund.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "transactions/types/htlc_refund.h"
28 |
29 | #include
30 | #include
31 |
32 | #include "constants.h"
33 |
34 | #include "utils/utils.h"
35 |
36 | ////////////////////////////////////////////////////////////////////////////////
37 | // Htlc Refund (Type 10) - 32 Bytes
38 | //
39 | // @param HtlcRefund *refund
40 | // @param uint8_t *buffer: The serialized buffer at the Assets offset.
41 | // @param size_t size: The Asset Buffer Size.
42 | //
43 | // @return 0: error
44 | // @return > 0: asset size
45 | //
46 | // ---
47 | // Internals:
48 | //
49 | // Lock Transaction Id - 32 Bytes:
50 | // - MEMCOPY(refund->id, &buffer[0], 32);
51 | //
52 | // ---
53 | size_t deserializeHtlcRefund(HtlcRefund *refund,
54 | const uint8_t *buffer,
55 | size_t size) {
56 | if (size < HASH_32_LEN) {
57 | return 0U;
58 | }
59 |
60 | MEMCOPY(refund->id, &buffer[0], HASH_32_LEN); // 32 Bytes
61 |
62 | return HASH_32_LEN;
63 | }
64 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/htlc_refund.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_TYPES_HTLC_REFUND_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_TYPES_HTLC_REFUND_H
29 |
30 | #include
31 | #include
32 |
33 | #include "constants.h"
34 |
35 | ////////////////////////////////////////////////////////////////////////////////
36 | typedef struct htlc_refund_asset_t {
37 | uint8_t id[HASH_32_LEN];
38 | } HtlcRefund;
39 |
40 | ////////////////////////////////////////////////////////////////////////////////
41 | size_t deserializeHtlcRefund(HtlcRefund *refund,
42 | const uint8_t *buffer,
43 | size_t size);
44 |
45 | #endif // #define ARK_OPERATIONS_TRANSACTIONS_TYPES_HTLC_REFUND_H
46 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/ipfs.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "transactions/types/ipfs.h"
28 |
29 | #include
30 | #include
31 |
32 | #include "constants.h"
33 |
34 | #include "utils/utils.h"
35 |
36 | ////////////////////////////////////////////////////////////////////////////////
37 | // IPFS (Type 5) - 0 <=> 64 Bytes
38 | //
39 | // @param Ipfs *ipfs
40 | // @param uint8_t *buffer: The serialized buffer at the Assets offset.
41 | // @param size_t size: The Asset Buffer Size.
42 | //
43 | // @return 0: error
44 | // @return > 0: asset size
45 | //
46 | // ---
47 | // Internals:
48 | //
49 | // Length - 1 Byte
50 | // - ipfs->length = buffer[1] + 2U;
51 | //
52 | // Dag - 0 <=> 64 Bytes
53 | // - MEMCOPY(ipfs->dag, buffer, ipfs->length);
54 | //
55 | // ---
56 | size_t deserializeIpfs(Ipfs *ipfs, const uint8_t *buffer, size_t size) {
57 | // 2nd byte of IPFS hash contains its len.
58 | //
59 | // byte[0] == hash-type (sha256).
60 | // byte[1] == hash-type length (32-bytes).
61 | // byte[[2...]] == 32-byte hash.
62 | ipfs->length = buffer[sizeof(uint8_t)] + 2;
63 |
64 | // Let's make sure the length isn't > 64,
65 | // and that the lengths match.
66 | if (size < ipfs->length) {
67 | return 0U;
68 | }
69 |
70 | MEMCOPY(ipfs->dag, buffer, ipfs->length); // 0 <=> 64 Bytes
71 |
72 | return ipfs->length;
73 | }
74 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/ipfs.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_TYPES_IPFS_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_TYPES_IPFS_H
29 |
30 | #include
31 | #include
32 |
33 | #include "constants.h"
34 |
35 | ////////////////////////////////////////////////////////////////////////////////
36 | typedef struct ipfs_asset_t {
37 | size_t length;
38 | uint8_t dag[HASH_64_LEN];
39 | } Ipfs;
40 |
41 | ////////////////////////////////////////////////////////////////////////////////
42 | size_t deserializeIpfs(Ipfs *ipfs, const uint8_t *buffer, size_t size);
43 |
44 | #endif // #define ARK_OPERATIONS_TRANSACTIONS_TYPES_IPFS_H
45 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/multi_signature.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_TYPES_MULTI_SIGNATURE_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_TYPES_MULTI_SIGNATURE_H
29 |
30 | #include "platform.h"
31 |
32 | #if defined(SUPPORTS_MULTISIGNATURE)
33 |
34 | #include
35 | #include
36 |
37 | #include "constants.h"
38 |
39 | ////////////////////////////////////////////////////////////////////////////////
40 | static const size_t MULTI_SIG_MIN = 2U;
41 | static const size_t MULTI_SIG_MAX = 16U;
42 | static const size_t MULTI_SIG_MAX_LEN = MULTI_SIG_MAX * PUBLICKEY_COMPRESSED_LEN;
43 |
44 | ////////////////////////////////////////////////////////////////////////////////
45 | typedef struct multi_signature_asset_t {
46 | uint8_t min;
47 | uint8_t count;
48 | uint8_t keys[MULTI_SIG_MAX][PUBLICKEY_COMPRESSED_LEN];
49 | } MultiSignature;
50 |
51 | ////////////////////////////////////////////////////////////////////////////////
52 | size_t deserializeMultiSignature(MultiSignature *multiSig,
53 | const uint8_t *buffer,
54 | size_t size);
55 |
56 | #endif // SUPPORTS_MULTISIGNATURE
57 | #endif // ARK_OPERATIONS_TRANSACTIONS_TYPES_MULTI_SIGNATURE_H
58 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/signatures.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "platform.h"
28 |
29 | #if defined(SUPPORTS_MULTISIGNATURE)
30 |
31 | #include "transactions/types/signatures.h"
32 |
33 | #include
34 | #include
35 |
36 | #include "utils/utils.h"
37 |
38 | ////////////////////////////////////////////////////////////////////////////////
39 | // Deserialize Signatures - 65N bytes
40 | //
41 | // @param Signatures *signatures
42 | // @param uint8_t *buffer: The serialized buffer beginning at Signatures.
43 | // @param size_t size: The Asset Size.
44 | //
45 | // @return 0: error
46 | // @return > 0: asset size
47 | //
48 | // ---
49 | // Internals:
50 | //
51 | // Counts:
52 | // - signatures->count = size / TRANSACTION_SIGNATURES_SIZE;
53 | //
54 | // Signatures - 64N Bytes:
55 | // - MEMCOPY(transfer->signatures.data, &buffer[N], 64);
56 | //
57 | // ---
58 | size_t deserializeSignatures(Signatures *signatures,
59 | const uint8_t *buffer,
60 | size_t size) {
61 | if (signatures == NULL ||
62 | buffer == NULL ||
63 | size % TRANSACTION_SIGNATURES_SIZE != 0) {
64 | return 0U;
65 | }
66 |
67 | signatures->count = size / TRANSACTION_SIGNATURES_SIZE;
68 | if (signatures->count > MULTI_SIG_MAX) {
69 | return 0U;
70 | }
71 |
72 | for (size_t i = 0; i < signatures->count; ++i) {
73 | MEMCOPY(signatures->data[i],
74 | &buffer[sizeof(uint8_t) + (i * TRANSACTION_SIGNATURES_SIZE)],
75 | SIG_SCHNORR_LEN);
76 | }
77 |
78 | return signatures->count * TRANSACTION_SIGNATURES_SIZE;
79 | }
80 |
81 | #endif // SUPPORTS_MULTISIGNATURE
82 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/signatures.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_TYPES_SIGNATURES_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_TYPES_SIGNATURES_H
29 |
30 | #include "platform.h"
31 |
32 | #if defined(SUPPORTS_MULTISIGNATURE)
33 |
34 | #include
35 | #include
36 |
37 | #include "transactions/types/multi_signature.h"
38 |
39 | #include "constants.h"
40 |
41 | ////////////////////////////////////////////////////////////////////////////////
42 | static const size_t TRANSACTION_SIGNATURES_SIZE = 1U + SIG_SCHNORR_LEN;
43 |
44 | ////////////////////////////////////////////////////////////////////////////////
45 | typedef struct signatures_t {
46 | uint8_t count;
47 | uint8_t data [MULTI_SIG_MAX] [SIG_SCHNORR_LEN];
48 | } Signatures;
49 |
50 | ////////////////////////////////////////////////////////////////////////////////
51 | size_t deserializeSignatures(Signatures *signatures,
52 | const uint8_t *buffer,
53 | size_t size);
54 |
55 | #endif // SUPPORTS_MULTISIGNATURE
56 | #endif // #define ARK_OPERATIONS_TRANSACTIONS_TYPES_SIGNATURES_H
57 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/transfer.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "transactions/types/transfer.h"
28 |
29 | #include
30 | #include
31 |
32 | #include "constants.h"
33 |
34 | #include "utils/unpack.h"
35 | #include "utils/utils.h"
36 |
37 | ////////////////////////////////////////////////////////////////////////////////
38 | // Deserialize Transfer (Type 0) - 33 bytes
39 | //
40 | // @param Transfer *transfer
41 | // @param uint8_t *buffer: The serialized buffer beginning at the Assets offset.
42 | // @param size_t size: The Asset Size.
43 | //
44 | // @return 0: error
45 | // @return > 0: asset size
46 | //
47 | // ---
48 | // Internals:
49 | //
50 | // Amount - 8 Bytes:
51 | // - transfer->amount = U8LE(buffer, 0U);
52 | //
53 | // Expiration - 4 Bytes:
54 | // - transfer->expiration = U4LE(buffer, 8);
55 | //
56 | // RecipientId - 21 Bytes:
57 | // - MEMCOPY(transfer->recipientId, &buffer[12], 21);
58 | //
59 | // ---
60 | size_t deserializeTransfer(Transfer *transfer,
61 | const uint8_t *buffer,
62 | size_t size) {
63 | if (transfer == NULL ||
64 | buffer == NULL ||
65 | size < TRANSACTION_TYPE_TRANSFER_SIZE) {
66 | return 0U;
67 | }
68 |
69 | transfer->amount = U8LE(buffer, 0); // 8 Bytes
70 | transfer->expiration = U4LE(buffer, sizeof(uint64_t)); // 4 Bytes
71 | MEMCOPY(transfer->recipientId, // 21 Bytes
72 | &buffer[sizeof(uint64_t) + sizeof(uint32_t)],
73 | ADDRESS_HASH_LEN);
74 |
75 | return TRANSACTION_TYPE_TRANSFER_SIZE;
76 | }
77 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/transfer.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_TYPES_TRANSFER_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_TYPES_TRANSFER_H
29 |
30 | #include
31 | #include
32 |
33 | #include "constants.h"
34 |
35 | ////////////////////////////////////////////////////////////////////////////////
36 | static const size_t TRANSACTION_TYPE_TRANSFER_SIZE = 33;
37 |
38 | ////////////////////////////////////////////////////////////////////////////////
39 | typedef struct transfer_asset_t {
40 | uint64_t amount;
41 | uint32_t expiration;
42 | uint8_t recipientId[ADDRESS_HASH_LEN];
43 | } Transfer;
44 |
45 | ////////////////////////////////////////////////////////////////////////////////
46 | size_t deserializeTransfer(Transfer *transfer, const uint8_t *buffer, size_t size);
47 |
48 | #endif // #define ARK_OPERATIONS_TRANSACTIONS_TYPES_TRANSFER_H
49 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/types.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_ASSETS_TYPES_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_ASSETS_TYPES_H
29 |
30 | ////////////////////////////////////////////////////////////////////////////////
31 | // ARK Transaction Types
32 | enum TransactionTypes {
33 | TRANSFER_TYPE = 0,
34 | /* SECOND_SIGNATURE_TYPE = 1, */
35 | /* DELEGATE_REGISTRATION_TYPE = 2, */
36 | VOTE_TYPE = 3,
37 | MULTI_SIG_REGISTRATION_TYPE = 4,
38 | IPFS_TYPE = 5,
39 | /* MULTI_PAYMENT_TYPE = 6, */
40 | /* DELEGATE_RESIGNATION_TYPE = 7, */
41 | HTLC_LOCK_TYPE = 8,
42 | HTLC_CLAIM_TYPE = 9,
43 | HTLC_REFUND_TYPE = 10
44 | };
45 |
46 | #endif // ARK_OPERATIONS_TRANSACTIONS_ASSETS_TYPES_H
47 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/vote.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "transactions/types/vote.h"
28 |
29 | #include
30 | #include
31 |
32 | #include "constants.h"
33 |
34 | #include "utils/utils.h"
35 |
36 | ////////////////////////////////////////////////////////////////////////////////
37 | // Vote (Type 3) - 35 <=> 69 Bytes
38 | //
39 | // @param Vote *vote
40 | // @param const uint8_t *buffer: The serialized buffer at the Assets offset.
41 | // @param size_t size: The Asset Buffer Size.
42 | //
43 | // @return 0: error
44 | // @return > 0: asset size
45 | //
46 | // ---
47 | // Internals:
48 | //
49 | // Number of Votes - 1 Byte
50 | // - vote->count = buffer[0];
51 | //
52 | // Vote - 1 + 33(Compressed PublicKey) Bytes:
53 | // - MEMCOPY(vote->data, &buffer[1 + 34N], 34);
54 | //
55 | // ---
56 | size_t deserializeVote(Vote *vote, const uint8_t *buffer, size_t size) {
57 | vote->count = buffer[0];
58 | const size_t expectedLen = sizeof(uint8_t) + (vote->count * VOTE_LEN);
59 |
60 | if (vote->count == 0U || vote->count > VOTE_MAX_COUNT ||
61 | size < expectedLen) {
62 | return 0U;
63 | }
64 |
65 | for (uint8_t i = 0U; i < vote->count; ++i) {
66 | MEMCOPY(vote->data[i], // 34 Bytes
67 | &buffer[sizeof(uint8_t) + (i * VOTE_LEN)],
68 | VOTE_LEN);
69 | }
70 |
71 | return expectedLen;
72 | }
73 |
--------------------------------------------------------------------------------
/src/operations/transactions/types/vote.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_TYPES_VOTE_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_TYPES_VOTE_H
29 |
30 | #include
31 | #include
32 |
33 | #include "constants.h"
34 |
35 | ////////////////////////////////////////////////////////////////////////////////
36 | static const size_t VOTE_LEN = sizeof(uint8_t) + PUBLICKEY_COMPRESSED_LEN;
37 | static const size_t VOTE_MAX_COUNT = 2U;
38 |
39 | ////////////////////////////////////////////////////////////////////////////////
40 | typedef struct vote_asset_t {
41 | uint8_t count;
42 | uint8_t data[VOTE_MAX_COUNT] [VOTE_LEN]; // ('0x00/0x01' + pubKey[33])
43 | } Vote;
44 |
45 | ////////////////////////////////////////////////////////////////////////////////
46 | size_t deserializeVote(Vote *vote, const uint8_t *buffer, size_t size);
47 |
48 | #endif // #define ARK_OPERATIONS_TRANSACTIONS_TYPES_VOTE_H
49 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/display_ux.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_UX_DISPLAY_UX_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_UX_DISPLAY_UX_H
29 |
30 | #include "transactions/transaction.h"
31 |
32 | ////////////////////////////////////////////////////////////////////////////////
33 | void SetUx(const Transaction *transaction);
34 |
35 | #endif // #define ARK_OPERATIONS_TRANSACTIONS_UX_DISPLAY_UX_H
36 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/htlc_claim_ux.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "transactions/ux/htlc_claim_ux.h"
28 |
29 | #include "constants.h"
30 |
31 | #include "operations/transactions/transaction.h"
32 |
33 | #include "utils/hex.h"
34 | #include "utils/print.h"
35 | #include "utils/utils.h"
36 |
37 | #include "display/context.h"
38 |
39 | ////////////////////////////////////////////////////////////////////////////////
40 | void SetUxHtlcClaim(const Transaction *transaction) {
41 | SPRINTF(displayCtx.operation, "%s", UX_HTLC_CLAIM_LABELS[0]);
42 | SPRINTF(displayCtx.title[0], "%s:", UX_HTLC_CLAIM_LABELS[1]);
43 | SPRINTF(displayCtx.title[1], "%s:", UX_HTLC_CLAIM_LABELS[2]);
44 |
45 | // Id
46 | BytesToHex(transaction->asset.htlcClaim.id, HASH_32_LEN,
47 | displayCtx.text[0], sizeof(displayCtx.text[0]));
48 |
49 | // Secret
50 | MEMCOPY(displayCtx.text[1],
51 | transaction->asset.htlcClaim.secret,
52 | HASH_32_LEN);
53 | }
54 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/htlc_claim_ux.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTION_UX_HTLC_CLAIM_UX_H
28 | #define ARK_OPERATIONS_TRANSACTION_UX_HTLC_CLAIM_UX_H
29 |
30 | #include
31 |
32 | #include "operations/transactions/transaction.h"
33 |
34 | ////////////////////////////////////////////////////////////////////////////////
35 | static const char *const UX_HTLC_CLAIM_LABELS[] = { "HTLC Claim",
36 | "Lock Id",
37 | "Secret" };
38 | static const size_t UX_HTLC_CLAIM_STEPS = 2U;
39 |
40 | ////////////////////////////////////////////////////////////////////////////////
41 | void SetUxHtlcClaim(const Transaction *transaction);
42 |
43 | #endif // #define ARK_OPERATIONS_TRANSACTION_UX_HTLC_CLAIM_UX_H
44 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/htlc_lock_ux.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTION_UX_HTLC_LOCK_UX_H
28 | #define ARK_OPERATIONS_TRANSACTION_UX_HTLC_LOCK_UX_H
29 |
30 | #include
31 |
32 | #include "operations/transactions/transaction.h"
33 |
34 | ////////////////////////////////////////////////////////////////////////////////
35 | static const char *const UX_HTLC_LOCK_LABELS[] = { "HTLC Lock",
36 | "Secret Hash" };
37 | static const char *const UX_HTLC_LOCK_SUB_LABELS[] = { "Time", "Height" };
38 | static const size_t UX_HTLC_LOCK_STEPS = 5U;
39 |
40 | ////////////////////////////////////////////////////////////////////////////////
41 | void SetUxHtlcLock(const Transaction *transaction);
42 |
43 | #endif // #define ARK_OPERATIONS_TRANSACTION_UX_HTLC_LOCK_UX_H
44 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/htlc_refund_ux.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "transactions/ux/htlc_refund_ux.h"
28 |
29 | #include "constants.h"
30 |
31 | #include "operations/transactions/transaction.h"
32 |
33 | #include "utils/hex.h"
34 | #include "utils/print.h"
35 | #include "utils/utils.h"
36 |
37 | #include "display/context.h"
38 |
39 | ////////////////////////////////////////////////////////////////////////////////
40 | void SetUxHtlcRefund(const Transaction *transaction) {
41 | SPRINTF(displayCtx.operation, "%s", UX_HTLC_REFUND_LABELS[0]);
42 | SPRINTF(displayCtx.title[0], "%s:", UX_HTLC_REFUND_LABELS[1]);
43 |
44 | // Lock Id
45 | BytesToHex(transaction->asset.htlcRefund.id, HASH_32_LEN,
46 | displayCtx.text[0], sizeof(displayCtx.text[0]));
47 | }
48 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/htlc_refund_ux.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTION_UX_HTLC_REFUND_UX_H
28 | #define ARK_OPERATIONS_TRANSACTION_UX_HTLC_REFUND_UX_H
29 |
30 | #include
31 |
32 | #include "operations/transactions/transaction.h"
33 |
34 | ////////////////////////////////////////////////////////////////////////////////
35 | static const char *const UX_HTLC_REFUND_LABELS[] = { "HTLC Refund", "Lock Id" };
36 | static const size_t UX_HTLC_REFUND_STEPS = 1U;
37 |
38 | ////////////////////////////////////////////////////////////////////////////////
39 | void SetUxHtlcRefund(const Transaction *transaction);
40 |
41 | #endif // #define ARK_OPERATIONS_TRANSACTION_UX_HTLC_REFUND_UX_H
42 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/ipfs_ux.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "transactions/ux/ipfs_ux.h"
28 |
29 | #include
30 | #include
31 |
32 | #include "constants.h"
33 |
34 | #include "operations/transactions/transaction.h"
35 |
36 | #include "utils/base58.h"
37 | #include "utils/print.h"
38 | #include "utils/str.h"
39 | #include "utils/utils.h"
40 |
41 | #include "display/context.h"
42 |
43 | ////////////////////////////////////////////////////////////////////////////////
44 | void SetUxIpfs(const Transaction *transaction) {
45 | SPRINTF(displayCtx.operation, "%s", UX_IPFS_LABELS[0]);
46 | SPRINTF(displayCtx.title[0], "%s:", UX_LABEL_FEE);
47 | SPRINTF(displayCtx.title_ext, "%s:", UX_IPFS_LABELS[1]);
48 |
49 | // Fee
50 | TokenAmountToString(TOKEN_NAME, TOKEN_NAME_LEN, TOKEN_DECIMALS,
51 | transaction->fee,
52 | displayCtx.text[0], sizeof(displayCtx.text[0]));
53 |
54 | // DAG
55 | size_t dagLen = MAX_TEXT_LEN;
56 | Base58Encode(transaction->asset.ipfs.dag, transaction->asset.ipfs.length,
57 | displayCtx.text_ext, &dagLen);
58 | }
59 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/ipfs_ux.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTION_UX_IPFS_UX_H
28 | #define ARK_OPERATIONS_TRANSACTION_UX_IPFS_UX_H
29 |
30 | #include
31 |
32 | #include "operations/transactions/transaction.h"
33 |
34 | ////////////////////////////////////////////////////////////////////////////////
35 | static const char *const UX_IPFS_LABELS[] = { "IPFS", "DAG" };
36 | static const size_t UX_IPFS_STEPS = 2U;
37 |
38 | ////////////////////////////////////////////////////////////////////////////////
39 | void SetUxIpfs(const Transaction *transaction);
40 |
41 | #endif // #define ARK_OPERATIONS_TRANSACTION_UX_IPFS_UX_H
42 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/multi_signature_ux.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_UX_MULTI_SIGNATURE_UX_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_UX_MULTI_SIGNATURE_UX_H
29 |
30 | #include "platform.h"
31 |
32 | #if defined(SUPPORTS_MULTISIGNATURE)
33 |
34 | #include
35 |
36 | #include "operations/transactions/transaction.h"
37 |
38 | ////////////////////////////////////////////////////////////////////////////////
39 | static const char *const MULTI_SIG_LABELS[] = { "MultiSig",
40 | "Reg.",
41 | "PublicKey" };
42 | static const size_t MULTI_SIG_BASE_STEPS = 1U;
43 |
44 | ////////////////////////////////////////////////////////////////////////////////
45 | size_t SetUxMultiSignature(const Transaction *transaction);
46 |
47 | #endif // SUPPORTS_MULTISIGNATURE
48 | #endif // ARK_OPERATIONS_TRANSACTIONS_UX_MULTI_SIGNATURE_UX_H
49 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/signatures_ux.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "platform.h"
28 |
29 | #if defined(SUPPORTS_MULTISIGNATURE)
30 |
31 | #include "transactions/ux/signatures_ux.h"
32 |
33 | #include "operations/transactions/transaction.h"
34 |
35 | #include "utils/hex.h"
36 | #include "utils/print.h"
37 |
38 | #include "constants.h"
39 |
40 | #include "display/context.h"
41 |
42 | ////////////////////////////////////////////////////////////////////////////////
43 | size_t SetUxSignatures(const Transaction *transaction, size_t offset) {
44 | const char *FMT = "%s: %d/%d";
45 | for (size_t i = 0; i < transaction->signatures.count; ++i) {
46 | SPRINTF(displayCtx.title[offset + i], FMT,
47 | UX_SIGNATURES_LABEL, i + 1U, transaction->signatures.count);
48 |
49 | BytesToHex(transaction->signatures.data[i], SIG_SCHNORR_LEN,
50 | displayCtx.text[offset + i],
51 | sizeof(displayCtx.text[offset + i]));
52 | }
53 |
54 | return transaction->signatures.count;
55 | }
56 |
57 | #endif // SUPPORTS_MULTISIGNATURE
58 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/signatures_ux.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_UX_SIGNATURES_UX_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_UX_SIGNATURES_UX_H
29 |
30 | #include "platform.h"
31 |
32 | #if defined(SUPPORTS_MULTISIGNATURE)
33 |
34 | #include
35 |
36 | #include "transactions/transaction.h"
37 |
38 | ////////////////////////////////////////////////////////////////////////////////
39 | static const char *const UX_SIGNATURES_LABEL = "Signature";
40 |
41 | ////////////////////////////////////////////////////////////////////////////////
42 | size_t SetUxSignatures(const Transaction *transaction, size_t offset);
43 |
44 | #endif // SUPPORTS_MULTISIGNATURE
45 | #endif // #define ARK_OPERATIONS_TRANSACTIONS_UX_SIGNATURES_UX_H
46 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/transfer_ux.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "transactions/ux/transfer_ux.h"
28 |
29 | #include "constants.h"
30 |
31 | #include "operations/transactions/transaction.h"
32 |
33 | #include "transactions/ux/vendorfield_ux.h"
34 |
35 | #include "utils/base58.h"
36 | #include "utils/print.h"
37 | #include "utils/str.h"
38 | #include "utils/utils.h"
39 |
40 | #include "display/context.h"
41 |
42 | ////////////////////////////////////////////////////////////////////////////////
43 | void SetUxTransfer(const Transaction *transaction) {
44 | SPRINTF(displayCtx.operation, "%s", UX_TRANSFER_LABEL);
45 | SPRINTF(displayCtx.title[0], "%s:", UX_LABEL_RECIPIENT);
46 | SPRINTF(displayCtx.title[1], "%s:", UX_LABEL_EXPIRATION);
47 | SPRINTF(displayCtx.title[2], "%s:", UX_LABEL_AMOUNT);
48 | SPRINTF(displayCtx.title[3], "%s:", UX_LABEL_FEE);
49 |
50 | // RecipientId
51 | Base58CheckEncode(transaction->asset.transfer.recipientId, ADDRESS_HASH_LEN,
52 | displayCtx.text[0], sizeof(displayCtx.text[0]));
53 |
54 | // Expiration
55 | UintToString(transaction->asset.transfer.expiration,
56 | displayCtx.text[1], sizeof(displayCtx.text[1]));
57 |
58 | // Amount
59 | TokenAmountToString(TOKEN_NAME, TOKEN_NAME_LEN, TOKEN_DECIMALS,
60 | transaction->asset.transfer.amount,
61 | displayCtx.text[2], sizeof(displayCtx.text[2]));
62 |
63 | // Fee
64 | TokenAmountToString(TOKEN_NAME, TOKEN_NAME_LEN, TOKEN_DECIMALS,
65 | transaction->fee,
66 | displayCtx.text[3], sizeof(displayCtx.text[3]));
67 |
68 | // VendorField
69 | if (transaction->vendorFieldLength > 0U) {
70 | setVendorField(transaction);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/transfer_ux.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_UX_TRANSFER_UX_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_UX_TRANSFER_UX_H
29 |
30 | #include
31 |
32 | #include "operations/transactions/transaction.h"
33 |
34 | ////////////////////////////////////////////////////////////////////////////////
35 | static const char *const UX_TRANSFER_LABEL = "Transfer";
36 | static const size_t UX_TRANSFER_STEPS = 4U;
37 |
38 | ////////////////////////////////////////////////////////////////////////////////
39 | void SetUxTransfer(const Transaction *transaction);
40 |
41 | #endif // #define ARK_OPERATIONS_TRANSACTIONS_UX_TRANSFER_UX_H
42 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/vendorfield_ux.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "transactions/ux/vendorfield_ux.h"
28 |
29 | #include "constants.h"
30 |
31 | #include "operations/transactions/transaction.h"
32 |
33 | #include "utils/print.h"
34 | #include "utils/utils.h"
35 |
36 | #include "display/context.h"
37 |
38 | ////////////////////////////////////////////////////////////////////////////////
39 | void setVendorField(const Transaction *transaction) {
40 | SPRINTF(displayCtx.title_ext, "%s:", UX_VENDORFIELD_LABEL);
41 |
42 | SNPRINTF(displayCtx.text_ext, sizeof(displayCtx.text_ext), "%.*s",
43 | (int)transaction->vendorFieldLength, transaction->vendorField);
44 | }
45 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/vendorfield_ux.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_UX_VENDORFIELD_UX_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_UX_VENDORFIELD_UX_H
29 |
30 | #include
31 |
32 | #include "transactions/transaction.h"
33 |
34 | ////////////////////////////////////////////////////////////////////////////////
35 | static const char *const UX_VENDORFIELD_LABEL = "VendorField";
36 |
37 | ////////////////////////////////////////////////////////////////////////////////
38 | void setVendorField(const Transaction *transaction);
39 |
40 | #endif // #define ARK_OPERATIONS_TRANSACTIONS_UX_VENDORFIELD_UX_H
41 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/vote_ux.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "transactions/ux/vote_ux.h"
28 |
29 | #include
30 |
31 | #include "constants.h"
32 |
33 | #include "operations/transactions/transaction.h"
34 |
35 | #include "utils/hex.h"
36 | #include "utils/print.h"
37 | #include "utils/str.h"
38 | #include "utils/utils.h"
39 |
40 | #include "display/context.h"
41 |
42 | ////////////////////////////////////////////////////////////////////////////////
43 | void SetUxVote(const Transaction *transaction) {
44 | SPRINTF(displayCtx.operation, "%s", UX_VOTE_LABELS[1]);
45 |
46 | // Fee
47 | SPRINTF(displayCtx.title[0], "%s:", UX_LABEL_FEE);
48 | TokenAmountToString(TOKEN_NAME, TOKEN_NAME_LEN, TOKEN_DECIMALS,
49 | transaction->fee,
50 | displayCtx.text[0], sizeof(displayCtx.text[0]));
51 |
52 | // Vote(s)
53 | for (uint8_t i = 0U; i < transaction->asset.vote.count; ++i) {
54 | const char* voteTag = transaction->asset.vote.data[i][0] == 1U
55 | ? UX_VOTE_LABELS[1] // vote
56 | : UX_VOTE_LABELS[0]; // unvote
57 |
58 | SPRINTF(displayCtx.title[UX_VOTE_BASE_STEPS + i], "%s: ", voteTag);
59 | BytesToHex(&transaction->asset.vote.data[i][1], PUBLICKEY_COMPRESSED_LEN,
60 | displayCtx.text[UX_VOTE_BASE_STEPS + i],
61 | sizeof(displayCtx.text[UX_VOTE_BASE_STEPS + i]));
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/operations/transactions/ux/vote_ux.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_OPERATIONS_TRANSACTIONS_UX_VOTE_UX_H
28 | #define ARK_OPERATIONS_TRANSACTIONS_UX_VOTE_UX_H
29 |
30 | #include
31 |
32 | #include "operations/transactions/transaction.h"
33 |
34 | ////////////////////////////////////////////////////////////////////////////////
35 | static const char *const UX_VOTE_LABELS[] = { "Unvote", "Vote" };
36 | static const size_t UX_VOTE_BASE_STEPS = 1U;
37 |
38 | ////////////////////////////////////////////////////////////////////////////////
39 | void SetUxVote(const Transaction *transaction);
40 |
41 | #endif // #define ARK_OPERATIONS_TRANSACTIONS_UX_VOTE_UX_H
42 |
--------------------------------------------------------------------------------
/src/platform.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_PLATFORM_H
28 | #define ARK_PLATFORM_H
29 |
30 | // This file detects available features and improves portability.
31 | //
32 | // Use this file (vs including '') before detecting platform variables,
33 | // such as 'TARGET_NANOS' or 'TARGET_NANOX'.
34 | //
35 | // 'HAVE_BOLOS_SDK' is a variable unique to this app;
36 | // use it in instances where we only need to detect the BOLOS environment.
37 | //
38 | // ---
39 | #if defined(HAVE_BOLOS_SDK)
40 | #include
41 |
42 | #if defined(TARGET_NANOX)
43 | #define SUPPORTS_LARGE_OPERATIONS
44 | #define SUPPORTS_MULTISIGNATURE
45 | #endif
46 | #endif // HAVE_BOLOS_SDK
47 | #endif // ARK_PLATFORM_H
48 |
--------------------------------------------------------------------------------
/src/utils/base58.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | *
26 | * -----
27 | *
28 | * Parts of this software are based on the Ledger Bitcoin Wallet App
29 | *
30 | * Ledger App - Bitcoin Wallet
31 | * (c) 2016-2019 Ledger
32 | *
33 | * Licensed under the Apache License, Version 2.0 (the "License");
34 | * you may not use this file except in compliance with the License.
35 | * You may obtain a copy of the License at
36 | *
37 | * http://www.apache.org/licenses/LICENSE-2.0
38 | *
39 | * Unless required by applicable law or agreed to in writing, software
40 | * distributed under the License is distributed on an "AS IS" BASIS,
41 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42 | * See the License for the specific language governing permissions and
43 | * limitations under the License.
44 | ******************************************************************************/
45 |
46 | #ifndef ARK_UTILS_BASE58_H
47 | #define ARK_UTILS_BASE58_H
48 |
49 | #include
50 | #include
51 |
52 | int Base58Encode(const uint8_t *in, size_t length, char *out, size_t *outlen);
53 |
54 | int Base58CheckEncode(const uint8_t *in, size_t length,
55 | char *out, size_t outLen);
56 |
57 | #endif // ARK_UTILS_BASE58_H
58 |
--------------------------------------------------------------------------------
/src/utils/hex.c:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #include "utils/hex.h"
28 |
29 | #include
30 | #include
31 |
32 | ////////////////////////////////////////////////////////////////////////////////
33 | // Convert Bytes to a Hex string, with null-terminator at N+1.
34 | //
35 | // @param const uint8_t *src: source byte-array.
36 | // @param size_t srcLen: length of the byte-array.
37 | // @param char *dst: destination hex-string buffer.
38 | // @param size_t dstMax: max length of writable space.
39 | //
40 | // @return size_t: final length w/null-terminator if successful, otherwise '0'.
41 | //
42 | // ---
43 | size_t BytesToHex(const uint8_t *src, size_t srcLen, char *dst, size_t dstMax) {
44 | if (src == NULL || dst == NULL || (srcLen * 2U) + 1U > dstMax) {
45 | return 0U;
46 | }
47 |
48 | const char *const HEX_DIGITS = "0123456789abcdef";
49 |
50 | size_t len = srcLen;
51 |
52 | do {
53 | *dst++ = HEX_DIGITS[(*src >> 4U) & 0xF];
54 | *dst++ = HEX_DIGITS[*src & 0xF];
55 | ++src;
56 | } while (len-- > 1U);
57 |
58 | *dst = '\0';
59 |
60 | return (srcLen * 2U) + 1U;
61 | }
62 |
--------------------------------------------------------------------------------
/src/utils/hex.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_UTILS_HEX_H
28 | #define ARK_UTILS_HEX_H
29 |
30 | #include
31 | #include
32 |
33 | size_t BytesToHex(const uint8_t *src, size_t srcLen, char *dst, size_t dstMax);
34 |
35 | #endif // ARK_UTILS_HEX_H
36 |
--------------------------------------------------------------------------------
/src/utils/print.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_UTILS_PRINT_H
28 | #define ARK_UTILS_PRINT_H
29 |
30 | #if defined(HAVE_BOLOS_SDK)
31 | #include
32 | #include
33 |
34 | #undef SPRINTF // redefine BOLOS version as 'SPRINTF_'
35 | #define SPRINTF_(strbuf, ...) snprintf(strbuf, sizeof(strbuf), __VA_ARGS__)
36 |
37 | #define SNPRINTF_ snprintf
38 | #else // BOLOS NOT detected
39 | #include
40 |
41 | #define SPRINTF_ sprintf
42 | #define SNPRINTF_ snprintf
43 | #endif // HAS_BOLOS_SDK
44 |
45 | ////////////////////////////////////////////////////////////////////////////////
46 | // A platform wrapper for 'sprintf'.
47 | //
48 | // @param char *s: pointer to the destination buffer.
49 | // @param const char *format: string print format.
50 | // @param ...: variadic arguments.
51 | //
52 | // ---
53 | #define SPRINTF SPRINTF_
54 |
55 | ////////////////////////////////////////////////////////////////////////////////
56 | // A platform wrapper for 'snprintf'.
57 | //
58 | // @param char *s: pointer to the destination buffer.
59 | // @param size_t size: maximum number of bytes to be written.
60 | // @param const char *format: string print format.
61 | // @param ...: variadic arguments.
62 | //
63 | // ---
64 | #define SNPRINTF SNPRINTF_
65 |
66 | #endif // ARK_UTILS_PRINT_H
67 |
--------------------------------------------------------------------------------
/src/utils/str.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * This file is part of the ARK Ledger App.
3 | *
4 | * Copyright (c) ARK Ecosystem
5 | *
6 | * The MIT License (MIT)
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to
10 | * deal in the Software without restriction, including without limitation the
11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 | * sell copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 | * SOFTWARE.
25 | ******************************************************************************/
26 |
27 | #ifndef ARK_UTILS_STR_H
28 | #define ARK_UTILS_STR_H
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | bool IsPrintableAscii(const char *str, size_t length, bool isNullTerminated);
35 |
36 | size_t UintToString(uint64_t value, char *dst, size_t maxLen);
37 |
38 | size_t TokenAmountToString(const char *token, size_t tokenLen, size_t decimals,
39 | uint64_t amount,
40 | char *dst, size_t maxLen);
41 |
42 | #endif // ARK_UTILS_STR_H
43 |
--------------------------------------------------------------------------------