What changed, and why it matters
This is a large routine firmware release (version 3.1.4) for the Keystone 3 hardware wallet. The visible changes add support for signing Bitcoin Cash, Dash and Dogecoin PSBTs, improve Solana and Tron transaction parsing, add Zcash shielded-address verification, update wallet branding, and make low-level build/FreeRTOS/MPU hardening changes. The commit itself is a release rollup rather than a focused security patch, so it is difficult to tell from the diff alone whether any of the changes fix an active vulnerability or are purely feature work. The changelog does not describe any issue as a security fix, and no CVE or independent researcher is mentioned.
Treat this as a normal firmware release until Keystone publishes release notes or a security advisory identifying specific vulnerabilities. Users should install 3.1.4 through the normal update channel. Security reviewers should separately inspect the new BCH/DASH/DOGE PSBT modules and the Solana overflow fixture for parsing/signature bugs, and verify that the MPU change does not break any unprivileged task that legitimately needs peripheral access.
Security signals we found
FreeRTOS MPU peripheral region narrowed to PSRAM-only and unprivileged peripheral access now disallowed by compile-time error
New PSBT signing paths for BCH/DASH/DOGE with custom validation and sighash rules
Solana parser changes and addition of an overflow test fixture (squads-overflow.hex)
Cardano advanced JSON serialization now enforces a 64 KiB output limit and uses lazy CBOR fallback
Production builds strip file/line from cryptoauthlib trace messages
ur-registry dependency bumped from 1.0.8 to 1.0.9
Evidence from the diff
The commit rolls up ~18k added and ~6k removed lines across 240 files. Notable technical changes observed in the diff include: (1) new Rust modules for PSBT-Extend handling of BCH, DASH and DOGE with custom deserialization, sighash validation and derivation-path enforcement; (2) extension of address derivation support for coins 3/5/145 in wrapped_psbt; (3) Solana parser additions including Squads V4 and Jupiter V6 resolvers plus a new overflow test fixture; (4) Tron transaction parsing/signer updates; (5) Cardano advanced-data JSON serialization refactor with a 64 KiB size limit and lazy CBOR fallback; (6) FreeRTOS MPU port changes that replace the broad peripheral region with a PSRAM-only region and require privileged-only peripheral access; (7) build flag rename CYBERPUNK→CYPHERPUNK; (8) ur-registry bump 1.0.8→1.0.9; (9) production-only cryptoauthlib trace macro; (10) diagnostic_location wrapper for asserts. Because the diff is a release rollup, individual security fixes are not isolated or labeled.
Changed components
Bitcoin transaction signer (rust/apps/bitcoin)Solana transaction parser (rust/apps/solana)Tron transaction parser/signer (rust/apps/tron)Cardano transaction parser (rust/apps/cardano)Zcash address verification (rust/apps/zcash, UI widgets)FreeRTOS MPU/port layer (external/FreeRTOS)Secure-element trace logging (external/cryptoauthlib)UR registry / QR code decoding (rust/Cargo.toml, rust/rust_c/src/common/ur*)Inspect captured patch +18413 / −6376
### .github/workflows/rust-monero-checks.yml
@@ -27,4 +27,4 @@ jobs:
uses: taiki-e/install-action@cargo-llvm-cov
- name: Run rust/apps/monero
- run: cd rust/apps/monero && cargo +$RUST_TOOLCHAIN llvm-cov --fail-under-regions 53 --fail-under-functions 50 --fail-under-lines 50 --ignore-filename-regex 'keystore/*'
+ run: cd rust/apps/monero && cargo +$RUST_TOOLCHAIN llvm-cov --fail-under-regions 43 --fail-under-functions 45 --fail-under-lines 43 --ignore-filename-regex 'keystore/*'
### CHANGELOG-ZH.md
@@ -1,3 +1,34 @@
+## 3.1.4(2026-10-15)
+
+**Web3:**
+
+### 优化
+
+1. SOL 交易解析优化
+2. TRON 交易解析优化
+3. Keeper 钱包 icon 及名称修改
+4. 钱包设置流程优化
+
+
+**Cypherpunk:**
+
+### 优化
+
+1. 钱包设置流程优化
+
+### 新增
+
+1. 新增 Zcash 隐私地址验证功能
+
+
+
+**BTC Only:**
+
+### 优化
+
+1. 钱包设置流程优化
+
+
## 3.1.2 (2026-10-9)
**Web3:**
### CHANGELOG.md
@@ -1,3 +1,31 @@
+## 3.1.4(2026-10-15)
+
+**Web3:**
+
+### Improvements
+
+1. Optimized SOL transaction parsing
+2. Optimized TRON transaction parsing
+3. Updated Keeper wallet icon and name
+4. Improved the wallet setup flow
+
+**Cypherpunk:**
+
+### What’s New
+
+1. Added Zcash shielded address verification
+
+### Improvements
+
+1. Improved the wallet setup flow
+
+**BTC Only:**
+
+### Improvements
+
+1. Improved the wallet setup flow
+
+
## 3.1.2 (2026-10-9)
**Web3:**
### build.sh
@@ -74,7 +74,7 @@ execute_build() {
cmake_parm="${cmake_parm} -DBTC_ONLY=true"
fi
if [[ "${build_options[cypherpunk]}" == true ]]; then
- cmake_parm="${cmake_parm} -DCYBERPUNK=true"
+ cmake_parm="${cmake_parm} -DCYPHERPUNK=true"
fi
if [[ "${build_options[screen]}" == true ]]; then
cmake_parm="${cmake_parm} -DENABLE_SCREEN_SHOT=true"
### external/FreeRTOS/FreeRTOSConfig.h
@@ -147,6 +147,7 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
/* Normal assert() semantics without relying on the provision of an assert.h
header file. */
/* USER CODE BEGIN 1 */
+#include "diagnostic_location.h"
#define configASSERT( x ) \
do { \
if( ( x ) == 0 ) { \
@@ -160,7 +161,7 @@ header file. */
} \
printf( "assert file=%s, line=%d, ipsr=%lu, irq=%ld, " \
"prio=0x%02lX, max_syscall=0x%02X, aircr=0x%08lX\r\n", \
- __FILE__, __LINE__, ( unsigned long ) ulAssertIpsr, \
+ DIAGNOSTIC_FILE, DIAGNOSTIC_LINE, ( unsigned long ) ulAssertIpsr, \
( long ) lAssertIrq, ( unsigned long ) ulAssertPriority, \
( unsigned int ) configMAX_SYSCALL_INTERRUPT_PRIORITY, \
( unsigned long ) ( *( ( volatile uint32_t * ) 0xE000ED0CUL ) ) ); \
### external/FreeRTOS/Source/portable/GCC/ARM_CM4_MPU/port.c
@@ -41,6 +41,7 @@
#include "FreeRTOS.h"
#include "task.h"
#include "mpu_syscall_numbers.h"
+#include "mhscpu.h"
#ifndef __ARM_FP
#error This port can only be used when the project options are configured to enable hardware floating point support.
@@ -93,11 +94,8 @@ typedef void ( * portISR_t )( void );
#define portPRIVILEGED_EXECUTION_START_ADDRESS ( 0UL )
#define portMPU_REGION_VALID ( 0x10UL )
#define portMPU_REGION_ENABLE ( 0x01UL )
-#define portPERIPHERALS_START_ADDRESS 0x40000000UL
-#define portPERIPHERALS_END_ADDRESS 0x5FFFFFFFUL
-
-#ifndef configALLOW_UNPRIVILEGED_PERIPHERAL_ACCESS
- #define configALLOW_UNPRIVILEGED_PERIPHERAL_ACCESS 1
+#if !defined( configALLOW_UNPRIVILEGED_PERIPHERAL_ACCESS ) || ( configALLOW_UNPRIVILEGED_PERIPHERAL_ACCESS != 0 )
+ #error PSRAM protection requires privileged-only default peripheral access.
#endif
/* Constants required to access and manipulate the SysTick. */
@@ -1379,19 +1377,14 @@ static void prvSetupMPU( void )
prvGetMPURegionSizeSetting( ( uint32_t ) __privileged_data_end__ - ( uint32_t ) __privileged_data_start__ ) |
( portMPU_REGION_ENABLE );
- /* Configure the general peripheral window. This project keeps it
- * privileged-only and grants narrower task regions when required. */
- portMPU_REGION_BASE_ADDRESS_REG = ( portPERIPHERALS_START_ADDRESS ) |
+ portMPU_REGION_BASE_ADDRESS_REG = ( MHSCPU_PSRAM_BASE ) |
( portMPU_REGION_VALID ) |
- ( portGENERAL_PERIPHERALS_REGION );
+ ( portPSRAM_REGION );
- portMPU_REGION_ATTRIBUTE_REG =
- #if ( configALLOW_UNPRIVILEGED_PERIPHERAL_ACCESS == 1 )
- ( portMPU_REGION_READ_WRITE | portMPU_REGION_EXECUTE_NEVER ) |
- #else
- ( portMPU_REGION_PRIVILEGED_READ_WRITE | portMPU_REGION_EXECUTE_NEVER ) |
- #endif
- ( prvGetMPURegionSizeSetting( portPERIPHERALS_END_ADDRESS - portPERIPHERALS_START_ADDRESS ) ) |
+ portMPU_REGION_ATTRIBUTE_REG = ( portMPU_REGION_PRIVILEGED_READ_WRITE ) |
+ ( portMPU_REGION_EXECUTE_NEVER ) |
+ ( 0x02UL << portMPU_RASR_TEX_S_C_B_LOCATION ) |
+ ( prvGetMPURegionSizeSetting( MHSCPU_PSRAM_END - MHSCPU_PSRAM_BASE + 1UL ) ) |
( portMPU_REGION_ENABLE );
/* Enable the memory fault exception. */
### external/FreeRTOS/Source/portable/GCC/ARM_CM4_MPU/portmacro.h
@@ -181,7 +181,7 @@ typedef unsigned long UBaseType_t;
#endif
#define portSTACK_REGION ( configTOTAL_MPU_REGIONS - 5UL )
-#define portGENERAL_PERIPHERALS_REGION ( configTOTAL_MPU_REGIONS - 4UL )
+#define portPSRAM_REGION ( configTOTAL_MPU_REGIONS - 4UL )
#define portUNPRIVILEGED_FLASH_REGION ( configTOTAL_MPU_REGIONS - 3UL )
#define portPRIVILEGED_FLASH_REGION ( configTOTAL_MPU_REGIONS - 2UL )
#define portPRIVILEGED_RAM_REGION ( configTOTAL_MPU_REGIONS - 1UL )
### external/cryptoauthlib/lib/cryptoauthlib.h
@@ -95,7 +95,11 @@
#define ATCA_PRINTF
#ifdef ATCA_PRINTF
+#ifdef BUILD_PRODUCTION
+#define ATCA_TRACE(s, m) atca_trace_msg(s, "%x:" m "\n")
+#else
#define ATCA_TRACE(s, m) atca_trace_msg(s, __FILE__ ":" ATCA_TOSTRING(__LINE__) ":%x:" m "\n")
+#endif
#else
#define ATCA_TRACE(s, m) atca_trace(s)
#endif
### external/mh1903_lib/MHSCPU_Driver/src/mhscpu_qspi.c
@@ -1127,4 +1127,4 @@ static bool EncryptedFlash(void)
}
/*********************** (C) COPYRIGHT Megahunt *****END OF FILE****/
-#endif
\ No newline at end of file
+#endif
### external/mh1903_lib/USB-ESL/USBESL.h
@@ -31,10 +31,11 @@ extern "C" {
/* Common Macro Start */
#if CONFIG_DEBUG
+#include "diagnostic_location.h"
#define printf_dbg(...) printf(__VA_ARGS__)
#define util_assert(expression) \
if (!(expression)) { \
- printf_dbg("Asserted %s, %d\n", __FILE__, __LINE__); \
+ printf_dbg("Asserted %s, %d\n", DIAGNOSTIC_FILE, DIAGNOSTIC_LINE); \
volatile uint32_t assertTimeout = 0x80000000; \
while (assertTimeout--) {} \
}
### external/sqlite3/sqlite3.c
@@ -16183,14 +16183,15 @@ struct TreeView {
SQLITE_PRIVATE int sqlite3CorruptError(int);
SQLITE_PRIVATE int sqlite3MisuseError(int);
SQLITE_PRIVATE int sqlite3CantopenError(int);
-#define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__)
-#define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__)
-#define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__)
+#include "diagnostic_location.h"
+#define SQLITE_CORRUPT_BKPT sqlite3CorruptError(DIAGNOSTIC_LINE)
+#define SQLITE_MISUSE_BKPT sqlite3MisuseError(DIAGNOSTIC_LINE)
+#define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(DIAGNOSTIC_LINE)
#ifdef SQLITE_DEBUG
SQLITE_PRIVATE int sqlite3NomemError(int);
SQLITE_PRIVATE int sqlite3IoerrnomemError(int);
-# define SQLITE_NOMEM_BKPT sqlite3NomemError(__LINE__)
-# define SQLITE_IOERR_NOMEM_BKPT sqlite3IoerrnomemError(__LINE__)
+# define SQLITE_NOMEM_BKPT sqlite3NomemError(DIAGNOSTIC_LINE)
+# define SQLITE_IOERR_NOMEM_BKPT sqlite3IoerrnomemError(DIAGNOSTIC_LINE)
#else
# define SQLITE_NOMEM_BKPT SQLITE_NOMEM
# define SQLITE_IOERR_NOMEM_BKPT SQLITE_IOERR_NOMEM
### firmware.cmake
@@ -39,7 +39,7 @@ file(GLOB_RECURSE USB_DRIVER
"external/mh1903_lib/SCPU_USB_Lib/SCPU_USB_Device_Library/Class/msc/src/*.c"
"external/mh1903_lib/SCPU_USB_Lib/SCPU_USB_Device_Library/Class/cdc/src/*.c"
"external/mh1903_lib/SCPU_USB_Lib/SCPU_USB_OTG_Driver/src/*.c"
- "external/mh1903_lib/USB-ESL/CircularBuffer.c"
+ "external/mh1903_lib/USB-ESL/CircularBuffer.c"
)
set(TASKS
@@ -73,19 +73,19 @@ file(GLOB_RECURSE SRC
"src/firmware/*.c"
"src/msg/*.c"
"src/ram/*.c"
- "src/hardware_interface/*.c"
+ "src/hardware_interface/*.c"
"src/config/*"
)
file(GLOB_RECURSE EXCLUDED_FILES
"src/managers/btc_only/*"
)
-
+
if(NOT BTC_ONLY)
list(REMOVE_ITEM SRC ${EXCLUDED_FILES})
list(APPEND WEBUSB_PROTOCOL ${WEBUSB_PROTOCOL_GENERAL})
endif()
-
+
file(GLOB_RECURSE FREERTOS
"external/FreeRTOS/Source/croutine.c"
"external/FreeRTOS/Source/event_groups.c"
### images/img/imgVerifyAddress.png
[binary or diff unavailable]
### images/wallet/walletKeeper.png
[binary or diff unavailable]
### images/wallet/walletTonkeeper.png
[binary or diff unavailable]
### keystone3-firmware-release
@@ -1 +1 @@
-Subproject commit 359b58a3f01282d17a4b8599bf40af003b316722
+Subproject commit ce9cd037b459ce647bf92ab365900b8fa7bf471e
### rust/Cargo.lock
@@ -4831,9 +4831,9 @@ dependencies = [
[[package]]
name = "ur-registry"
-version = "1.0.8"
+version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f3e5fdee1510fe809ceaecdf7e3ab75b58b4c578e3f436217cd03132f0596698"
+checksum = "e20351479cae2f2f28771f1c8f6b9532209c054cd39e5c754edef0247d6dbfe8"
dependencies = [
"bs58",
"hex",
### rust/Cargo.toml
@@ -78,7 +78,7 @@ core2 = { version = "0.9.4", package = "no_std_io2", default-features = false }
thiserror = { version = "1.0", package = "thiserror-core", default-features = false }
rsa = { version = "0.8.2", default-features = false }
sha1 = { version = "0.10.5", default-features = false }
-ur-registry = "=1.0.8"
+ur-registry = "=1.0.9"
ur-parse-lib = "1.0.8"
ur = { package = "keystone-ur", version = "0.1.1", default-features = false }
sui-transaction-types-core = { git = "https://github.com/KeystoneHQ/sui.git", tag = "mainnet-nostd-v1.69.2.1", default-features = false, features = ["alloc"] }
### rust/apps/bitcoin/src/addresses/address.rs
@@ -154,6 +154,11 @@ impl Address {
payload: Payload::P2sh { script_hash: hash },
})
} else if script.is_witness_program() {
+ if matches!(network, Network::Dogecoin | Network::Dash) {
+ return Err(BitcoinError::AddressError(
+ "no witness address format for this network".to_string(),
+ ));
+ }
let opcode = script
.first_opcode()
.expect("is_witness_program guarantees len > 4");
### rust/apps/bitcoin/src/addresses/cashaddr.rs
@@ -9,7 +9,7 @@ use alloc::format;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use bitcoin::address::AddressData as Payload;
-use bitcoin::PubkeyHash;
+use bitcoin::{PubkeyHash, ScriptHash};
use bitcoin_hashes::Hash;
use core::{fmt, str};
@@ -216,8 +216,15 @@ impl CashAddrCodec {
}
pub fn encode(raw: Vec<u8>) -> Result<String> {
+ Self::encode_with_type(raw, version_byte_flags::TYPE_P2PKH)
+ }
+
+ pub fn encode_p2sh(raw: Vec<u8>) -> Result<String> {
+ Self::encode_with_type(raw, version_byte_flags::TYPE_P2SH)
+ }
+
+ fn encode_with_type(raw: Vec<u8>, hash_flag: u8) -> Result<String> {
// Calculate version byte
- let hash_flag = version_byte_flags::TYPE_P2PKH;
let length = raw.len();
let version_byte = match length {
20 => version_byte_flags::SIZE_160,
@@ -327,17 +334,24 @@ impl CashAddrCodec {
// Extract the hash type and return
let version_type = version & version_byte_flags::TYPE_MASK;
- if version_type != version_byte_flags::TYPE_P2PKH {
- return Err(BitcoinError::AddressError(format!(
- "invalid version {version_type:?}"
- )));
+ let payload = match version_type {
+ version_byte_flags::TYPE_P2PKH => Payload::P2pkh {
+ pubkey_hash: PubkeyHash::from_slice(body).map_err(|_| {
+ BitcoinError::AddressError("invalid public key hash".to_string())
+ })?,
+ },
+ version_byte_flags::TYPE_P2SH => Payload::P2sh {
+ script_hash: ScriptHash::from_slice(body)
+ .map_err(|_| BitcoinError::AddressError("invalid script hash".to_string()))?,
+ },
+ _ => {
+ return Err(BitcoinError::AddressError(format!(
+ "invalid version {version_type:?}"
+ )))
+ }
};
- let publickey_hash = PubkeyHash::from_slice(body)
- .map_err(|_| BitcoinError::AddressError("invalid public key hash".to_string()))?;
Ok(Address {
- payload: Payload::P2pkh {
- pubkey_hash: publickey_hash,
- },
+ payload,
network: Network::BitcoinCash,
})
}
### rust/apps/bitcoin/src/addresses/encoding.rs
@@ -101,6 +101,11 @@ impl<'a> fmt::Display for BCHAddressEncoding<'a> {
Err(_) => write!(fmt, "invalid addresses"),
}
}
+ Payload::P2sh { script_hash } => {
+ let address =
+ CashAddrCodec::encode_p2sh(script_hash[..].to_vec()).map_err(|_| fmt::Error)?;
+ write!(fmt, "{address}")
+ }
_ => {
write!(fmt, "invalid payload")
}
### rust/apps/bitcoin/src/lib.rs
@@ -49,14 +49,35 @@ pub fn sign_psbt(psbt_hex: Vec<u8>, seed: &[u8], mfp: Fingerprint) -> Result<Vec
sign_psbt_no_serialize(psbt_hex, seed, mfp).map(|v| v.serialize())
}
+pub fn sign_psbt_extend(
+ psbt: Vec<u8>,
+ seed: &[u8],
+ mfp: Fingerprint,
+ coin_id: Option<i128>,
+) -> Result<Vec<u8>> {
+ if coin_id == Some(5) {
+ return transactions::psbt::dash::sign(&psbt, seed, mfp);
+ }
+ let decoded = decode_psbt_extend(&psbt, coin_id)?;
+ transactions::psbt::extend::validate(&decoded, coin_id)?;
+ if coin_id == Some(145) {
+ return transactions::psbt::bch::sign(&psbt, seed, mfp);
+ }
+ sign_psbt(psbt, seed, mfp)
+}
+
pub fn sign_psbt_no_serialize(psbt_hex: Vec<u8>, seed: &[u8], mfp: Fingerprint) -> Result<Psbt> {
- let psbt = deserialize_psbt(psbt_hex)?;
+ let psbt =
+ Psbt::deserialize(&psbt_hex).map_err(|e| BitcoinError::InvalidPsbt(e.to_string()))?;
let mut wpsbt = WrappedPsbt { psbt };
wpsbt.sign(seed, mfp)
}
pub fn parse_psbt_hex_sign_status(psbt: &[u8]) -> Result<PsbtSignStatus> {
- let psbt = deserialize_psbt(psbt.to_vec())?;
+ let psbt = match deserialize_psbt(psbt.to_vec()) {
+ Ok(decoded) => decoded,
+ Err(error) => return transactions::psbt::dash::sign_status(psbt).map_err(|_| error),
+ };
let wpsbt = WrappedPsbt { psbt };
Ok(PsbtSignStatus {
sign_status: wpsbt.get_overall_sign_status(),
@@ -89,6 +110,41 @@ pub fn sign_msg(msg: &str, seed: &[u8], path: &String) -> Result<Vec<u8>> {
})
}
+fn decode_psbt_extend(bytes: &[u8], coin_id: Option<i128>) -> Result<Psbt> {
+ transactions::psbt::extend::network_for_coin(coin_id)?;
+ if coin_id == Some(145) {
+ return transactions::psbt::bch::deserialize(bytes);
+ }
+ Psbt::deserialize(bytes).map_err(|e| BitcoinError::InvalidPsbt(e.to_string()))
+}
+
+pub fn parse_psbt_extend(
+ bytes: Vec<u8>,
+ context: ParseContext,
+ coin_id: Option<i128>,
+) -> Result<ParsedTx> {
+ if coin_id == Some(5) {
+ return transactions::psbt::dash::parse(&bytes, &context);
+ }
+ let psbt = decode_psbt_extend(&bytes, coin_id)?;
+ let network = transactions::psbt::extend::validate(&psbt, coin_id)?;
+ let wrapper = WrappedPsbt { psbt };
+ wrapper.parse_in_network(Some(&context), network, false)
+}
+
+pub fn check_psbt_extend(
+ bytes: Vec<u8>,
+ context: ParseContext,
+ coin_id: Option<i128>,
+) -> Result<()> {
+ if coin_id == Some(5) {
+ return transactions::psbt::dash::check(&bytes, &context);
+ }
+ let psbt = decode_psbt_extend(&bytes, coin_id)?;
+ transactions::psbt::extend::validate(&psbt, coin_id)?;
+ WrappedPsbt { psbt }.check(Left(&context))
+}
+
pub fn parse_psbt(psbt_hex: Vec<u8>, context: ParseContext) -> Result<ParsedTx> {
let psbt = deserialize_psbt(psbt_hex)?;
let wpsbt = WrappedPsbt { psbt };
@@ -125,7 +181,23 @@ pub fn check_raw_tx(raw_tx: protoc::Payload, context: keystone::ParseContext) ->
}
fn deserialize_psbt(psbt_hex: Vec<u8>) -> Result<Psbt> {
- Psbt::deserialize(&psbt_hex).map_err(|e| BitcoinError::InvalidPsbt(e.to_string()))
+ match Psbt::deserialize(&psbt_hex) {
+ Ok(psbt) => Ok(psbt),
+ Err(error) => {
+ if let Ok(psbt) = transactions::psbt::bch::deserialize(&psbt_hex) {
+ let has_key_origin = !psbt.xpub.is_empty()
+ || psbt
+ .inputs
+ .iter()
+ .any(|input| !input.bip32_derivation.is_empty());
+ if has_key_origin && transactions::psbt::extend::validate(&psbt, Some(145)).is_ok()
+ {
+ return Ok(psbt);
+ }
+ }
+ Err(BitcoinError::InvalidPsbt(error.to_string()))
+ }
+ }
}
#[cfg(test)]
### rust/apps/bitcoin/src/transactions/psbt/bch.rs
@@ -0,0 +1,561 @@
+use crate::errors::{BitcoinError, Result};
+use alloc::{string::ToString, vec::Vec};
+use bitcoin::{
+ bip32::{ChildNumber, Fingerprint},
+ consensus::{deserialize_partial, encode::VarInt, serialize, Encodable},
+ hashes::{sha256d, Hash},
+ psbt::Psbt,
+ secp256k1::{Message, Secp256k1},
+ PublicKey, ScriptBuf, Transaction, TxOut,
+};
+
+const ALL_FORKID: u32 = 0x41;
+struct SigningKey(bitcoin::secp256k1::SecretKey);
+impl Drop for SigningKey {
+ fn drop(&mut self) {
+ self.0.non_secure_erase();
+ }
+}
+
+pub(crate) fn validate_outputs(psbt: &Psbt) -> Result<()> {
+ if psbt.unsigned_tx.output.is_empty() {
+ return Err(BitcoinError::NoOutputs);
+ }
+ for output in &psbt.unsigned_tx.output {
+ if !output.script_pubkey.is_p2pkh() && !output.script_pubkey.is_p2sh() {
+ return Err(invalid(
+ "unsupported BCH output: cannot display a recipient address",
+ ));
+ }
+ }
+ Ok(())
+}
+
+fn invalid(message: &str) -> BitcoinError {
+ BitcoinError::InvalidPsbt(message.to_string())
+}
+
+fn rewrite_signatures(bytes: &mut [u8], from: u8, to: u8) -> Result<()> {
+ if !bytes.starts_with(b"psbt\xff") {
+ return Err(invalid("invalid PSBT magic"));
+ }
+ let mut pos = 5;
+ let mut map = 0;
+ let mut input_count = None;
+ while pos < bytes.len() {
+ let key = field(bytes, &mut pos)?;
+ if key.is_empty() {
+ map += 1;
+ continue;
+ }
+ let value = field(bytes, &mut pos)?;
+ if map == 0 && bytes[key.clone()] == [0] {
+ let tx: Transaction = bitcoin::consensus::deserialize(&bytes[value.clone()])
+ .map_err(|_| invalid("invalid unsigned transaction"))?;
+ input_count = Some(tx.input.len());
+ }
+ if map > 0
+ && map <= input_count.ok_or_else(|| invalid("missing unsigned transaction"))?
+ && bytes[key.start] == 2
+ {
+ let last = value
+ .end
+ .checked_sub(1)
+ .filter(|_| !value.is_empty())
+ .ok_or_else(|| invalid("empty BCH signature"))?;
+ if bytes[last] != from {
+ return Err(invalid("BCH requires SIGHASH_ALL | FORKID signatures"));
+ }
+ bytes[last] = to;
+ }
+ }
+ Ok(())
+}
+
+fn field(bytes: &[u8], pos: &mut usize) -> Result<core::ops::Range<usize>> {
+ let (size, consumed) = deserialize_partial::<VarInt>(&bytes[*pos..])
+ .map_err(|_| invalid("invalid PSBT field length"))?;
+ *pos += consumed;
+ let size = usize::try_from(size.0).map_err(|_| invalid("PSBT field too large"))?;
+ let end = pos
+ .checked_add(size)
+ .filter(|end| *end <= bytes.len())
+ .ok_or_else(|| invalid("truncated PSBT field"))?;
+ let range = *pos..end;
+ *pos = end;
+ Ok(range)
+}
+
+pub(crate) fn deserialize(bytes: &[u8]) -> Result<Psbt> {
+ let mut normalized = bytes.to_vec();
+ rewrite_signatures(&mut normalized, 0x41, 0x01)?;
+ let psbt = Psbt::deserialize(&normalized).map_err(|e| invalid(&e.to_string()))?;
+ if psbt.inputs.is_empty() {
+ return Err(BitcoinError::NoInputs);
+ }
+ validate_outputs(&psbt)?;
+ for (index, input) in psbt.inputs.iter().enumerate() {
+ let output = prevout(&psbt, index)?;
+ for key in input.bip32_derivation.keys() {
+ if ScriptBuf::new_p2pkh(&PublicKey::new(*key).pubkey_hash()) != output.script_pubkey {
+ return Err(invalid(
+ "BCH input public key does not match previous output",
+ ));
+ }
+ }
+ if input.sighash_type.is_some_and(|t| t.to_u32() != ALL_FORKID) {
+ return Err(invalid("BCH supports only SIGHASH_ALL | FORKID"));
+ }
+ for (_, path) in input.bip32_derivation.values() {
+ let components = path.as_ref();
+ if components.len() != 5
+ || components[0] != (ChildNumber::Hardened { index: 44 })
+ || components[1] != (ChildNumber::Hardened { index: 145 })
+ {
+ return Err(invalid("unsupported BCH derivation path"));
+ }
+ }
+ }
+ Ok(psbt)
+}
+
+fn prevout(psbt: &Psbt, index: usize) -> Result<&TxOut> {
+ let input = &psbt.inputs[index];
+ let outpoint = psbt.unsigned_tx.input[index].previous_output;
+ let previous = input
+ .non_witness_utxo
+ .as_ref()
+ .ok_or_else(|| invalid("BCH signing requires non_witness_utxo"))?;
+ if previous.compute_txid() != outpoint.txid {
+ return Err(invalid("BCH previous transaction ID mismatch"));
+ }
+ let output = previous
+ .output
+ .get(outpoint.vout as usize)
+ .ok_or(BitcoinError::InvalidInput)?;
+ if input
+ .witness_utxo
+ .as_ref()
+ .is_some_and(|witness| witness != output)
+ {
+ return Err(invalid("BCH UTXO data mismatch"));
+ }
+ if !output.script_pubkey.is_p2pkh() {
+ return Err(invalid("BCH supports only P2PKH inputs"));
+ }
+ Ok(output)
+}
+
+fn signature_hash(tx: &Transaction, index: usize, output: &TxOut) -> Result<sha256d::Hash> {
+ let mut prevouts = Vec::new();
+ let mut sequences = Vec::new();
+ let mut outputs = Vec::new();
+ for input in &tx.input {
+ input.previous_output.consensus_encode(&mut prevouts)?;
+ input.sequence.consensus_encode(&mut sequences)?;
+ }
+ for output in &tx.output {
+ output.consensus_encode(&mut outputs)?;
+ }
+ let mut data = serialize(&tx.version);
+ data.extend_from_slice(sha256d::Hash::hash(&prevouts).as_byte_array());
+ data.extend_from_slice(sha256d::Hash::hash(&sequences).as_byte_array());
+ tx.input[index]
+ .previous_output
+ .consensus_encode(&mut data)?;
+ output.script_pubkey.consensus_encode(&mut data)?;
+ output.value.consensus_encode(&mut data)?;
+ tx.input[index].sequence.consensus_encode(&mut data)?;
+ data.extend_from_slice(sha256d::Hash::hash(&outputs).as_byte_array());
+ tx.lock_time.consensus_encode(&mut data)?;
+ ALL_FORKID.consensus_encode(&mut data)?;
+ Ok(sha256d::Hash::hash(&data))
+}
+
+pub(crate) fn sign(bytes: &[u8], seed: &[u8], fingerprint: Fingerprint) -> Result<Vec<u8>> {
+ let mut psbt = deserialize(bytes)?;
+ let secp = Secp256k1::new();
+ let mut owned = false;
+ for index in 0..psbt.inputs.len() {
+ let input = &psbt.inputs[index];
+ if input.final_script_sig.is_some()
+ || input.final_script_witness.is_some()
+ || input.redeem_script.is_some()
+ || input.witness_script.is_some()
+ {
+ return Err(invalid("unsupported BCH input script fields"));
+ }
+ let output = prevout(&psbt, index)?;
+ let script = output.script_pubkey.clone();
+ let message =
+ Message::from_digest(signature_hash(&psbt.unsigned_tx, index, output)?.to_byte_array());
+ for (key, sig) in &input.partial_sigs {
+ if ScriptBuf::new_p2pkh(&key.pubkey_hash()) != script {
+ return Err(invalid("BCH signature public key mismatch"));
+ }
+ secp.verify_ecdsa(&message, &sig.signature, &key.inner)
+ .map_err(|_| invalid("invalid existing BCH signature"))?;
+ }
+ let derivations = input.bip32_derivation.clone();
+ for (key, (fp, path)) in derivations {
+ if fp != fingerprint {
+ continue;
+ }
+ let secret = SigningKey(
+ keystore::algorithms::secp256k1::get_private_key_by_seed(seed, &path.to_string())
+ .map_err(|e| BitcoinError::GetKeyError(e.to_string()))?,
+ );
+ let public = PublicKey::new(secret.0.public_key(&secp));
+ if public.inner != key || ScriptBuf::new_p2pkh(&public.pubkey_hash()) != script {
+ return Err(invalid("BCH derived public key does not match input"));
+ }
+ let signature = secp.sign_ecdsa(&message, &secret.0);
+ psbt.inputs[index]
+ .partial_sigs
+ .insert(public, bitcoin::ecdsa::Signature::sighash_all(signature));
+ owned = true;
+ }
+ psbt.inputs[index].sighash_type =
+ Some(bitcoin::psbt::PsbtSighashType::from_u32(ALL_FORKID));
+ }
+ if !owned {
+ return Err(BitcoinError::NoMyInputs);
+ }
+ let mut result = psbt.serialize();
+ rewrite_signatures(&mut result, 0x01, 0x41)?;
+ Ok(result)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use core::str::FromStr;
+ const BCH: &str = "70736274ff0100770100000001df92cf31d578229fa876e7bf2f5696798f4d18d28e0066010e67feb6f5fb00b90000000000ffffffff02005a6202000000001976a9144f04b6e897c1a3dfe2b74bfc40cbc4d9c64daf3088ac18839303000000001976a914cfdcdfa3e0483ddd3c7b6ab6ee13c5087c26d5f188ac0000000000010057010000000153ef901d37f8bfee6f9453ff7b8dc3e0672ee715498dae97db9dca73261f9a3300000000020101ffffffff0100e1f505000000001976a914086a977c7dad32a56996af2ce90a727238d4899888ac0000000001030441000000220602bbe7dbcdf8b2261530a867df7180b17a90b482f74f2736b8a30d3f756e42e2171873c5da0a2c000080910000800000008000000000000000000000220202f178b9410d11e47e10bef8a8e4bc53e48d9ae15864a024a54f87a802dad5f5141873c5da0a2c0000809100008000000080010000000000000000";
+ fn seed() -> Vec<u8> {
+ hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap()
+ }
+ fn fp() -> Fingerprint {
+ Fingerprint::from_str("73c5da0a").unwrap()
+ }
+ fn fixture() -> Psbt {
+ Psbt::deserialize(&hex::decode(BCH).unwrap()).unwrap()
+ }
+ fn sign_psbt(psbt: &Psbt) -> Result<Vec<u8>> {
+ crate::sign_psbt_extend(psbt.serialize(), &seed(), fp(), Some(145))
+ }
+
+ #[test]
+ #[allow(deprecated)]
+ fn bch_matches_legacy_digest_signature_and_final_transaction() {
+ use crate::transactions::legacy::{input::TxIn, sign_legacy_tx, TxData};
+ for variant in 0..3 {
+ let mut psbt = fixture();
+ if variant > 0 {
+ psbt.unsigned_tx.version = bitcoin::transaction::Version::TWO;
+ psbt.unsigned_tx.lock_time = bitcoin::absolute::LockTime::from_consensus(800_000);
+ psbt.unsigned_tx.input[0].sequence = bitcoin::Sequence(0xfffffffe);
+ psbt.unsigned_tx.output[0].value = bitcoin::Amount::from_sat(12_345_678);
+ }
+ if variant == 2 {
+ let mut input = psbt.inputs[0].clone();
+ let previous = input.non_witness_utxo.as_mut().unwrap();
+ previous.output[0].value = bitcoin::Amount::from_sat(50_000_000);
+ let mut txin = psbt.unsigned_tx.input[0].clone();
+ txin.previous_output.txid = previous.compute_txid();
+ txin.sequence = bitcoin::Sequence(0xfffffffd);
+ psbt.inputs.push(input);
+ psbt.unsigned_tx.input.push(txin);
+ }
+ let mut legacy = TxData {
+ inputs: psbt
+ .inputs
+ .iter()
+ .enumerate()
+ .map(|(index, input)| {
+ let (key, (_, path)) = input.bip32_derivation.first_key_value().unwrap();
+ let outpoint = psbt.unsigned_tx.input[index].previous_output;
+ TxIn {
+ previous_output: outpoint.txid.to_string(),
+ vout: outpoint.vout,
+ value: prevout(&psbt, index).unwrap().value.to_sat(),
+ pubkey: key.to_string(),
+ hd_path: path.to_string(),
+ }
+ })
+ .collect(),
+ outputs: vec![],
+ script_type: "P2PKH".to_string(),
+ network: "BCH".to_string(),
+ extended_pubkey: alloc::string::String::new(),
+ xfp: fp().to_string(),
+ transaction: psbt.unsigned_tx.clone(),
+ };
+ for index in 0..psbt.inputs.len() {
+ let old_hash = match legacy.signature_hash(index).unwrap() {
+ either::Right(hash) => hash.to_byte_array(),
+ _ => panic!("BCH must use ForkID"),
+ };
+ assert_eq!(
+ old_hash,
+ signature_hash(&psbt.unsigned_tx, index, prevout(&psbt, index).unwrap())
+ .unwrap()
+ .to_byte_array()
+ );
+ }
+ let signed = deserialize(&sign_psbt(&psbt).unwrap()).unwrap();
+ let mut finalized = signed.unsigned_tx.clone();
+ for (index, input) in signed.inputs.iter().enumerate() {
+ let (key, signature) = input.partial_sigs.first_key_value().unwrap();
+ let mut bytes = signature.signature.serialize_der().to_vec();
+ bytes.push(0x41);
+ finalized.input[index].script_sig = bitcoin::script::Builder::new()
+ .push_slice(bitcoin::script::PushBytesBuf::try_from(bytes).unwrap())
+ .push_key(key)
+ .into_script();
+ }
+ let legacy_bytes = sign_legacy_tx(&mut legacy, &seed()).unwrap();
+ assert_eq!(serialize(&finalized), legacy_bytes, "variant {variant}");
+ assert_eq!(finalized.compute_txid(), legacy.transaction.compute_txid());
+ }
+ }
+
+ #[test]
+ fn bch_psbt_does_not_hide_mismatched_change_and_rejects_no_outputs() {
+ let mut psbt = fixture();
+ let path = bitcoin::bip32::DerivationPath::from_str("m/44'/145'/0'").unwrap();
+ let xpub = keystore::algorithms::secp256k1::get_extended_public_key_by_seed(
+ &seed(),
+ &path.to_string(),
+ )
+ .unwrap();
+ let context = || {
+ crate::parsed_tx::ParseContext::new(
+ fp(),
+ alloc::collections::BTreeMap::from([(path.clone(), xpub)]),
+ None,
+ None,
+ )
+ };
+ crate::check_psbt(psbt.serialize(), context()).unwrap();
+ psbt.unsigned_tx.output[1].script_pubkey = psbt.unsigned_tx.output[0].script_pubkey.clone();
+ let display = crate::parse_psbt(psbt.serialize(), context()).unwrap();
+ assert!(!display.detail.to[1].is_mine);
+ assert_eq!(display.overview.total_output_sat, "99999000 sats");
+ psbt.outputs[1]
+ .bip32_derivation
+ .values_mut()
+ .next()
+ .unwrap()
+ .1 = bitcoin::bip32::DerivationPath::from_str("m/44'/145'/0'/1/1").unwrap();
+ let display = crate::parse_psbt(psbt.serialize(), context()).unwrap();
+ assert!(!display.detail.to[1].is_mine);
+ assert_eq!(display.overview.total_output_sat, "99999000 sats");
+ psbt.unsigned_tx.output.clear();
+ psbt.outputs.clear();
+ assert!(matches!(sign_psbt(&psbt), Err(BitcoinError::NoOutputs)));
+ }
+
+ #[test]
+ fn bch_forkid_signature_and_wire_roundtrip() {
+ let psbt = fixture();
+ let expected =
+ hex::decode("f292551b43d5fcc05ac26707d02303ff280513a489daf31f476b7ee1c326134a")
+ .unwrap();
+ assert_eq!(
+ signature_hash(&psbt.unsigned_tx, 0, prevout(&psbt, 0).unwrap())
+ .unwrap()
+ .as_byte_array(),
+ expected.as_slice()
+ );
+ let signed = sign_psbt(&psbt).unwrap();
+ let parsed = deserialize(&signed).unwrap();
+ assert_eq!(parsed.inputs[0].sighash_type.unwrap().to_u32(), 0x41);
+ assert_eq!(parsed.inputs[0].partial_sigs.len(), 1);
+ let (key, signature) = parsed.inputs[0].partial_sigs.first_key_value().unwrap();
+ Secp256k1::verification_only()
+ .verify_ecdsa(
+ &Message::from_digest_slice(&expected).unwrap(),
+ &signature.signature,
+ &key.inner,
+ )
+ .unwrap();
+ let mut wire = signature.signature.serialize_der().to_vec();
+ wire.push(0x41);
+ assert!(signed.windows(wire.len()).any(|value| value == wire));
+ assert_eq!(parsed.unsigned_tx, psbt.unsigned_tx);
+ assert!(
+ crate::parse_psbt_hex_sign_status(&signed)
+ .unwrap()
+ .is_completed
+ );
+ let account_path = bitcoin::bip32::DerivationPath::from_str("m/44'/145'/0'").unwrap();
+ let xpub = keystore::algorithms::secp256k1::get_extended_public_key_by_seed(
+ &seed(),
+ &account_path.to_string(),
+ )
+ .unwrap();
+ let context = crate::parsed_tx::ParseContext::new(
+ fp(),
+ alloc::collections::BTreeMap::from([(account_path, xpub)]),
+ None,
+ None,
+ );
+ crate::check_psbt(
+ psbt.serialize(),
+ crate::parsed_tx::ParseContext::new(
+ fp(),
+ context.extended_public_keys.clone(),
+ None,
+ None,
+ ),
+ )
+ .unwrap();
+ let display = crate::parse_psbt(signed.clone(), context).unwrap();
+ assert_eq!(
+ display.overview.from,
+ vec!["qqyx49mu0kkn9ftfj6hje6g2wfer34yfnq5tahq3q6".to_string()]
+ );
+ assert!(!display.overview.need_sign);
+ let request =
+ ur_registry::crypto_psbt_extend::CryptoPSBTExtend::new(signed.clone(), Some(145))
+ .unwrap();
+ let cbor: Vec<u8> = request.try_into().unwrap();
+ let decoded = ur_registry::crypto_psbt_extend::CryptoPSBTExtend::try_from(cbor).unwrap();
+ assert_eq!(decoded.get_coin_id(), Some(145));
+ assert_eq!(decoded.get_psbt(), signed);
+ assert_eq!(
+ crate::sign_psbt_extend(signed.clone(), &seed(), fp(), Some(145)).unwrap(),
+ signed
+ );
+ assert!(crate::sign_psbt(signed, &seed(), fp()).is_err());
+ }
+
+ #[test]
+ fn bch_multiple_inputs_preserve_external_signatures() {
+ let mut p = fixture();
+ let second_txin = p.unsigned_tx.input[0].clone();
+ let second_input = p.inputs[0].clone();
+ p.unsigned_tx.input.push(second_txin);
+ p.inputs.push(second_input);
+ let previous = p.inputs[1].non_witness_utxo.as_mut().unwrap();
+ previous.lock_time = bitcoin::absolute::LockTime::from_consensus(1);
+ p.unsigned_tx.input[1].previous_output.txid = previous.compute_txid();
+ let signed = sign_psbt(&p).unwrap();
+ let mut parsed = deserialize(&signed).unwrap();
+ for index in 0..2 {
+ let (key, signature) = parsed.inputs[index].partial_sigs.first_key_value().unwrap();
+ let msg = Message::from_digest(
+ signature_hash(&parsed.unsigned_tx, index, prevout(&parsed, index).unwrap())
+ .unwrap()
+ .to_byte_array(),
+ );
+ Secp256k1::verification_only()
+ .verify_ecdsa(&msg, &signature.signature, &key.inner)
+ .unwrap();
+ }
+ parsed.inputs[1]
+ .bip32_derivation
+ .values_mut()
+ .next()
+ .unwrap()
+ .0 = Fingerprint::default();
+ let mut external = parsed.serialize();
+ rewrite_signatures(&mut external, 1, 0x41).unwrap();
+ let resigned = crate::sign_psbt_extend(external, &seed(), fp(), Some(145)).unwrap();
+ assert_eq!(
+ deserialize(&resigned).unwrap().inputs[1].partial_sigs,
+ parsed.inputs[1].partial_sigs
+ );
+ }
+
+ #[test]
+ fn bch_defaults_to_all_forkid_but_rejects_other_sighashes() {
+ let mut psbt = fixture();
+ psbt.inputs[0].sighash_type = None;
+ let result = deserialize(&sign_psbt(&psbt).unwrap()).unwrap();
+ assert_eq!(result.inputs[0].sighash_type.unwrap().to_u32(), 0x41);
+ for value in [0, 1, 2, 3, 0x42, 0x43, 0xc1] {
+ psbt.inputs[0].sighash_type = Some(bitcoin::psbt::PsbtSighashType::from_u32(value));
+ assert!(sign_psbt(&psbt).is_err(), "{value}");
+ }
+ }
+
+ #[test]
+ fn bch_rejects_wrong_utxo_key_path_and_script() {
+ let original = fixture();
+ let mut p = original.clone();
+ p.inputs[0].non_witness_utxo.as_mut().unwrap().output[0].value =
+ bitcoin::Amount::from_sat(1);
+ assert!(sign_psbt(&p).is_err());
+ let mut p = original.clone();
+ p.inputs[0].witness_utxo = Some(TxOut {
+ value: bitcoin::Amount::from_sat(1),
+ ..prevout(&original, 0).unwrap().clone()
+ });
+ assert!(sign_psbt(&p).is_err());
+ p.inputs[0].non_witness_utxo = None;
+ assert!(sign_psbt(&p).is_err());
+ let mut p = original.clone();
+ p.inputs[0].bip32_derivation.values_mut().next().unwrap().1 =
+ bitcoin::bip32::DerivationPath::from_str("m/44'/145'/0'/0/1").unwrap();
+ assert!(sign_psbt(&p).is_err());
+ p.inputs[0].bip32_derivation.values_mut().next().unwrap().1 =
+ bitcoin::bip32::DerivationPath::from_str("m/44'/5'/0'/0/0").unwrap();
+ assert!(sign_psbt(&p).is_err());
+ assert!(crate::sign_psbt_extend(
+ original.serialize(),
+ &seed(),
+ Fingerprint::default(),
+ Some(145)
+ )
+ .is_err());
+ let mut p = original.clone();
+ let prev = p.inputs[0].non_witness_utxo.as_mut().unwrap();
+ prev.output[0].script_pubkey = ScriptBuf::new();
+ p.unsigned_tx.input[0].previous_output.txid = prev.compute_txid();
+ assert!(sign_psbt(&p).is_err());
+ }
+
+ #[test]
+ fn bch_preserves_unknown_fields_and_rejects_truncated_psbt() {
+ let mut p = fixture();
+ let key = bitcoin::psbt::raw::Key {
+ type_value: 0xee,
+ key: vec![1, 2],
+ };
+ p.inputs[0].unknown.insert(key.clone(), vec![2, 0x41, 0x01]);
+ p.outputs[0].unknown.insert(key.clone(), vec![2, 0x41]);
+ let signed = sign_psbt(&p).unwrap();
+ let parsed = deserialize(&signed).unwrap();
+ assert_eq!(parsed.inputs[0].unknown, p.inputs[0].unknown);
+ assert_eq!(parsed.outputs[0].unknown, p.outputs[0].unknown);
+ for end in 0..signed.len() {
+ assert!(deserialize(&signed[..end]).is_err(), "{end}");
+ }
+ let mut changed = parsed;
+ changed.unsigned_tx.output[0].value = bitcoin::Amount::from_sat(1);
+ let mut changed_bytes = changed.serialize();
+ rewrite_signatures(&mut changed_bytes, 1, 0x41).unwrap();
+ assert!(crate::sign_psbt_extend(changed_bytes, &seed(), fp(), Some(145)).is_err());
+ }
+
+ #[test]
+ fn other_psbt_extend_chains_keep_standard_signatures() {
+ for (coin, data) in [
+ (2, "70736274ff01007101000000011bfed2d08a2b45c790930953230bdc406eca13e579b5049eb751086b3ed369420000000000ffffffff02005a62020000000016001477f2208e272bef80e98ce956e05d5ed8f596f5a3f05f930300000000160014267f2c10ac39e483c00c982efdd0112bcc3e62830000000000010054010000000130297791cbb43ddbe1b17406f92f79b653a585f061213749fb069644b7f7ffbb00000000020101ffffffff0100e1f5050000000016001496cd3178f3de0f307bcee1aeaa4d5987862dd30a0000000001011f00e1f5050000000016001496cd3178f3de0f307bcee1aeaa4d5987862dd30a01030401000000220602e49c9b9b5d0f127235dc26a0c252814c52fb333d651a946773f59d72c2da99041873c5da0a540000800200008000000080000000000000000000002202029857513f0fe1dc125f219ffef22098e14c653c4bcb0a2aaeff47b3a252569f1a1873c5da0a540000800200008000000080010000000000000000"),
+ (3, "70736274ff0100770100000001faf994b04953ae7fbd735800e48605de15ded8126b9308556ad98962327ab3430000000000ffffffff02005a6202000000001976a9143bf96544e911ca728f5fabf5a4f3b65deab684c488acc0448403000000001976a91419115174dcc75cce4802aaec82e63b491274c2e288ac000000000001005701000000016f9512863e3f25696cc723f570d3c4077785f1944a895895a70750689453e48b00000000020101ffffffff0100e1f505000000001976a9144a483568665dcdfa68dd58a1f62893448a64333988ac0000000001030401000000220602cc6b0dc33aabcf3a23643e5e2919a80c50fb3dd2129ce409bbc5f0d4643d05e01873c5da0a2c0000800300008000000080000000000000000000002202020745c065a8b7cb03a843a57339cf9164d675a2e5010c6fbd61c09239bbb5f4df1873c5da0a2c0000800300008000000080010000000000000000"),
+ (5, "70736274ff010077010000000102754c72a9069560e14bf2faa47998f4442149e798cff5f8c953e7d92ab219d20000000000ffffffff02005a6202000000001976a9140a38ec3f3cc4c169c295ddb037c31c63bf2fa39188acf05f9303000000001976a914265a7d4ef63d643548a599c8fa53a0d9ef3fdca488ac0000000000010057010000000105d94a72185cf340264af0461c176c985bf0d55fef0026c94447f723ec03f90600000000020101ffffffff0100e1f505000000001976a9148a4f58c222cd5544c527bc66925652baa70b5e8088ac00000000010304010000002206026fa9a6f213b6ba86447965f6b4821264aaadd7521f049f00db9c43a770ea74051873c5da0a2c000080050000800000008000000000000000000000220202bd7b0ae9a8a0e67f82891d92545433e1b37074ab0bf5867b977f8c70b00f28671873c5da0a2c0000800500008000000080010000000000000000"),
+ ] {
+ let bytes = hex::decode(data).unwrap();
+ let result = crate::sign_psbt_extend(bytes.clone(), &seed(), fp(), Some(coin)).unwrap();
+ assert_eq!(result, crate::sign_psbt(bytes, &seed(), fp()).unwrap());
+ let parsed = Psbt::deserialize(&result).unwrap();
+ let (key, signature) = parsed.inputs[0].partial_sigs.first_key_value().unwrap();
+ let mut cache = bitcoin::sighash::SighashCache::new(&parsed.unsigned_tx);
+ let (message, _) = parsed.sighash_ecdsa(0, &mut cache).unwrap();
+ Secp256k1::verification_only().verify_ecdsa(&message, &signature.signature, &key.inner).unwrap();
+ assert_eq!(signature.to_vec().last(), Some(&1));
+ assert!(crate::sign_psbt_extend(hex::decode(data).unwrap(), &seed(), fp(), Some(145)).is_err());
+ }
+ }
+}
### rust/apps/bitcoin/src/transactions/psbt/dash.rs
@@ -0,0 +1,510 @@
+use super::{extend, wrapped_psbt::WrappedPsbt};
+use crate::{
+ errors::{BitcoinError, Result},
+ network::Network,
+ parsed_tx::{ParseContext, ParsedTx},
+ transactions::tx_checker::TxChecker,
+ PsbtSignStatus,
+};
+use alloc::{collections::BTreeMap, string::ToString, vec::Vec};
+use bitcoin::{
+ bip32::Fingerprint,
+ consensus::{deserialize, deserialize_partial, encode::VarInt, serialize},
+ hashes::{sha256d, Hash},
+ psbt::Psbt,
+ PublicKey, ScriptBuf, Transaction, TxOut, Txid,
+};
+use either::Left;
+
+type Map = BTreeMap<Vec<u8>, Vec<u8>>;
+fn invalid(message: &str) -> BitcoinError {
+ BitcoinError::InvalidPsbt(message.to_string())
+}
+
+fn field<'a>(bytes: &mut &'a [u8]) -> Result<&'a [u8]> {
+ let (length, used): (VarInt, usize) =
+ deserialize_partial(bytes).map_err(|_| invalid("invalid DASH PSBT length"))?;
+ *bytes = &bytes[used..];
+ let length = usize::try_from(length.0).map_err(|_| invalid("DASH PSBT field too large"))?;
+ if length > bytes.len() {
+ return Err(invalid("truncated DASH PSBT field"));
+ }
+ let (value, rest) = bytes.split_at(length);
+ *bytes = rest;
+ Ok(value)
+}
+fn read_map(bytes: &mut &[u8]) -> Result<Map> {
+ let mut map = Map::new();
+ loop {
+ let key = field(bytes)?;
+ if key.is_empty() {
+ return Ok(map);
+ }
+ let value = field(bytes)?;
+ if map.insert(key.to_vec(), value.to_vec()).is_some() {
+ return Err(invalid("duplicate DASH PSBT key"));
+ }
+ }
+}
+fn encode_maps(maps: &[Map]) -> Vec<u8> {
+ let mut bytes = b"psbt\xff".to_vec();
+ for map in maps {
+ for (key, value) in map {
+ bytes.extend(serialize(&VarInt(key.len() as u64)));
+ bytes.extend_from_slice(key);
+ bytes.extend(serialize(&VarInt(value.len() as u64)));
+ bytes.extend_from_slice(value);
+ }
+ bytes.push(0);
+ }
+ bytes
+}
+
+fn previous_transaction(raw: &[u8]) -> Result<(Transaction, Txid)> {
+ fn take<T: bitcoin::consensus::Decodable>(bytes: &mut &[u8]) -> Result<T> {
+ let (value, used) =
+ deserialize_partial(bytes).map_err(|_| invalid("invalid DASH previous transaction"))?;
+ *bytes = &bytes[used..];
+ Ok(value)
+ }
+ let mut suffix = raw;
+ let version: i32 = take(&mut suffix)?;
+ let inputs: Vec<bitcoin::TxIn> = take(&mut suffix)?;
+ let outputs: Vec<TxOut> = take(&mut suffix)?;
+ let lock_time: u32 = take(&mut suffix)?;
+ let tx = Transaction {
+ version: bitcoin::transaction::Version(version),
+ lock_time: bitcoin::absolute::LockTime::from_consensus(lock_time),
+ input: inputs,
+ output: outputs,
+ };
+ let version = version as u32;
+ if (version & 0xffff) >= 3 && version >> 16 != 0 {
+ let payload = field(&mut suffix)?;
+ if payload.len() > 10_000 {
+ return Err(invalid("DASH extra payload too large"));
+ }
+ } else if version >> 16 != 0 {
+ return Err(invalid("invalid DASH special transaction version"));
+ }
+ if !suffix.is_empty() {
+ return Err(invalid("unexpected trailing DASH transaction data"));
+ }
+ Ok((tx, Txid::from_raw_hash(sha256d::Hash::hash(raw))))
+}
+
+struct DashPsbt {
+ maps: Vec<Map>,
+ wrapper: WrappedPsbt,
+}
+impl DashPsbt {
+ fn decode(bytes: &[u8]) -> Result<Self> {
+ let mut rest = bytes
+ .strip_prefix(b"psbt\xff")
+ .ok_or_else(|| invalid("invalid DASH PSBT magic"))?;
+ let global = read_map(&mut rest)?;
+ let raw_tx = global
+ .get(&vec![0])
+ .ok_or_else(|| invalid("missing DASH unsigned transaction"))?;
+ let tx: Transaction =
+ deserialize(raw_tx).map_err(|_| invalid("invalid DASH unsigned transaction"))?;
+ if (tx.version.0 as u32) >> 16 != 0 {
+ return Err(invalid("signing DASH special transactions is unsupported"));
+ }
+ if tx.input.is_empty() {
+ return Err(BitcoinError::NoInputs);
+ }
+ if tx.output.is_empty() {
+ return Err(BitcoinError::NoOutputs);
+ }
+ let mut maps = vec![global];
+ for _ in 0..tx.input.len() + tx.output.len() {
+ maps.push(read_map(&mut rest)?);
+ }
+ if !rest.is_empty() {
+ return Err(invalid("trailing DASH PSBT data"));
+ }
+ let mut view_maps = maps.clone();
+ for (index, input) in tx.input.iter().enumerate() {
+ let map = &mut view_maps[index + 1];
+ let raw = map
+ .remove(&vec![0])
+ .ok_or_else(|| invalid("DASH signing requires non_witness_utxo"))?;
+ let (previous, txid) = previous_transaction(&raw)?;
+ if txid != input.previous_output.txid {
+ return Err(invalid("DASH previous transaction ID mismatch"));
+ }
+ let prevout = previous
+ .output
+ .get(input.previous_output.vout as usize)
+ .ok_or_else(|| invalid("DASH previous output index out of bounds"))?;
+ if !prevout.script_pubkey.is_p2pkh() {
+ return Err(invalid("DASH supports only P2PKH inputs"));
+ }
+ if let Some(raw_witness) = map.get(&vec![1]) {
+ let witness: TxOut =
+ deserialize(raw_witness).map_err(|_| invalid("invalid DASH witness UTXO"))?;
+ if witness != *prevout {
+ return Err(invalid("DASH witness and non-witness UTXO mismatch"));
+ }
+ }
+ map.insert(vec![1], serialize(prevout));
+ }
+ let psbt =
+ Psbt::deserialize(&encode_maps(&view_maps)).map_err(|e| invalid(&e.to_string()))?;
+ extend::validate(&psbt, Some(5))?;
+ for input in &psbt.inputs {
+ if input.redeem_script.is_some()
+ || input.witness_script.is_some()
+ || input.final_script_sig.is_some()
+ || input.final_script_witness.is_some()
+ {
+ return Err(invalid("unsupported DASH input script fields"));
+ }
+ input
+ .ecdsa_hash_ty()
+ .map_err(|_| invalid("unsupported DASH sighash type"))?;
+ let script = &input
+ .witness_utxo
+ .as_ref()
+ .ok_or_else(|| invalid("missing verified DASH output"))?
+ .script_pubkey;
+ for key in input.bip32_derivation.keys() {
+ if ScriptBuf::new_p2pkh(&PublicKey::new(*key).pubkey_hash()) != *script {
+ return Err(invalid("DASH public key does not match previous output"));
+ }
+ }
+ }
+ Ok(Self {
+ maps,
+ wrapper: WrappedPsbt { psbt },
+ })
+ }
+}
+
+pub(crate) fn parse(bytes: &[u8], context: &ParseContext) -> Result<ParsedTx> {
+ let decoded = DashPsbt::decode(bytes)?;
+ let mut parsed = decoded
+ .wrapper
+ .parse_in_network(Some(context), Network::Dash, false)?;
+ parsed.overview.has_witness_only_inputs = false;
+ Ok(parsed)
+}
+pub(crate) fn check(bytes: &[u8], context: &ParseContext) -> Result<()> {
+ DashPsbt::decode(bytes)?.wrapper.check(Left(context))
+}
+pub(crate) fn sign_status(bytes: &[u8]) -> Result<PsbtSignStatus> {
+ let decoded = DashPsbt::decode(bytes)?;
+ if decoded
+ .wrapper
+ .psbt
+ .inputs
+ .iter()
+ .all(|input| input.bip32_derivation.is_empty())
+ && decoded.wrapper.psbt.xpub.is_empty()
+ {
+ return Err(invalid("missing DASH key origins"));
+ }
+ Ok(PsbtSignStatus {
+ sign_status: decoded.wrapper.get_overall_sign_status(),
+ is_completed: decoded.wrapper.is_sign_completed(),
+ })
+}
+pub(crate) fn sign(bytes: &[u8], seed: &[u8], fingerprint: Fingerprint) -> Result<Vec<u8>> {
+ let mut decoded = DashPsbt::decode(bytes)?;
+ let mut owned = false;
+ for input in &decoded.wrapper.psbt.inputs {
+ for (key, (fp, path)) in &input.bip32_derivation {
+ if *fp != fingerprint {
+ continue;
+ }
+ let public =
+ keystore::algorithms::secp256k1::get_public_key_by_seed(seed, &path.to_string())
+ .map_err(|e| BitcoinError::GetKeyError(e.to_string()))?;
+ if public != *key {
+ return Err(invalid("DASH derived public key mismatch"));
+ }
+ owned = true;
+ }
+ }
+ if !owned {
+ return Err(BitcoinError::NoMyInputs);
+ }
+ let signed = decoded.wrapper.sign(seed, fingerprint)?;
+ for (index, input) in signed.inputs.iter().enumerate() {
+ for (key, signature) in &input.partial_sigs {
+ let mut raw_key = vec![2];
+ raw_key.extend(key.to_bytes());
+ decoded.maps[index + 1].insert(raw_key, signature.to_vec());
+ }
+ }
+ Ok(encode_maps(&decoded.maps))
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use bitcoin::{
+ bip32::DerivationPath,
+ secp256k1::{Message, Secp256k1},
+ };
+ use core::str::FromStr;
+ fn seed() -> Vec<u8> {
+ hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap()
+ }
+ fn fp() -> Fingerprint {
+ Fingerprint::from_str("73c5da0a").unwrap()
+ }
+ fn context() -> ParseContext {
+ let path = DerivationPath::from_str("m/44'/5'/0'").unwrap();
+ let xpub = keystore::algorithms::secp256k1::get_extended_public_key_by_seed(
+ &seed(),
+ &path.to_string(),
+ )
+ .unwrap();
+ ParseContext::new(fp(), BTreeMap::from([(path, xpub)]), None, None)
+ }
+ fn fixture() -> Psbt {
+ Psbt::deserialize(&hex::decode("70736274ff010077010000000102754c72a9069560e14bf2faa47998f4442149e798cff5f8c953e7d92ab219d20000000000ffffffff02005a6202000000001976a9140a38ec3f3cc4c169c295ddb037c31c63bf2fa39188acf05f9303000000001976a914265a7d4ef63d643548a599c8fa53a0d9ef3fdca488ac0000000000010057010000000105d94a72185cf340264af0461c176c985bf0d55fef0026c94447f723ec03f90600000000020101ffffffff0100e1f505000000001976a9148a4f58c222cd5544c527bc66925652baa70b5e8088ac00000000010304010000002206026fa9a6f213b6ba86447965f6b4821264aaadd7521f049f00db9c43a770ea74051873c5da0a2c000080050000800000008000000000000000000000220202bd7b0ae9a8a0e67f82891d92545433e1b37074ab0bf5867b977f8c70b00f28671873c5da0a2c0000800500008000000080010000000000000000").unwrap()).unwrap()
+ }
+ fn maps(bytes: &[u8]) -> Vec<Map> {
+ let mut rest = &bytes[5..];
+ let mut maps = Vec::new();
+ while !rest.is_empty() {
+ maps.push(read_map(&mut rest).unwrap());
+ }
+ maps
+ }
+ fn cbtx() -> Vec<u8> {
+ hex::decode("03000500010000000000000000000000000000000000000000000000000000000000000000ffffffff2703da5c1e04d04580650800007588782d01000fe4b883e5bda9e7a59ee4bb99e9b1bc04f09f909f88f581b80253640f03000000001976a9147c086eada12bdb10a265c16c08a7ae87366bd48188acf82c2e09000000001976a91453dc8bffae84a3851ab9fe296417da85d5e7185888aca0f04c20af0300da5c1e0054e04067fa61cef61f1e91b0d52c21b28cdc69cc9d0383f0bb88ba0129b973e2f67e47d5580e70c7e77af8b1a6670669c7424b896ab3d44d349a4988e9a8328d00b22fef542f5c630e4f2a67ad56d30cf2a3dac55848abcd2bac30bf780318792bcdf32f7729443846c9fdc57050a131cd12c0e54a16f6265e900f459e3b9dd43421a0bc3f61efd49ce752e440e5131a8d2758a280ad883b8eb902c49ee5b878b30000000000000000").unwrap()
+ }
+ fn special() -> Vec<Map> {
+ let mut p = fixture();
+ let mut previous = p.inputs[0].non_witness_utxo.clone().unwrap();
+ previous.version = bitcoin::transaction::Version(0x00050003);
+ previous.input[0].previous_output = bitcoin::OutPoint::null();
+ let mut raw = serialize(&previous);
+ let mut payload = vec![2, 0];
+ payload.extend_from_slice(&1989850u32.to_le_bytes());
+ payload.extend_from_slice(&[0x42; 64]);
+ raw.extend(serialize(&VarInt(payload.len() as u64)));
+ raw.extend(payload);
+ p.unsigned_tx.input[0].previous_output.txid =
+ Txid::from_raw_hash(sha256d::Hash::hash(&raw));
+ let mut result = maps(&p.serialize());
+ result[1].insert(vec![0], raw);
+ result[0].insert(vec![0xaa, 1], vec![0x99, 0x33]);
+ result[1].insert(vec![0xaa, 2], vec![0x22, 0x44]);
+ result
+ }
+ fn reject(maps: &[Map]) {
+ let bytes = encode_maps(maps);
+ assert!(crate::parse_psbt_extend(bytes.clone(), context(), Some(5)).is_err());
+ assert!(crate::check_psbt_extend(bytes.clone(), context(), Some(5)).is_err());
+ assert!(crate::sign_psbt_extend(bytes, &seed(), fp(), Some(5)).is_err());
+ }
+ fn verify_signed(signed: &[u8]) {
+ let decoded = DashPsbt::decode(signed).unwrap();
+ let p = &decoded.wrapper.psbt;
+ let mut tx = p.unsigned_tx.clone();
+ tx.input[0].script_sig = p.inputs[0]
+ .witness_utxo
+ .as_ref()
+ .unwrap()
+ .script_pubkey
+ .clone();
+ let mut preimage = serialize(&tx);
+ preimage.extend_from_slice(&1u32.to_le_bytes());
+ let message = Message::from_digest(sha256d::Hash::hash(&preimage).to_byte_array());
+ for (key, sig) in &p.inputs[0].partial_sigs {
+ assert_eq!(sig.sighash_type, bitcoin::sighash::EcdsaSighashType::All);
+ Secp256k1::verification_only()
+ .verify_ecdsa(&message, &sig.signature, &key.inner)
+ .unwrap();
+ }
+ assert_eq!(p.inputs[0].partial_sigs.len(), 1);
+ }
+ #[test]
+ fn dash_special_prevout_display_sign_and_preserve_wire_data() {
+ let original = special();
+ let bytes = encode_maps(&original);
+ let display = crate::parse_psbt_extend(bytes.clone(), context(), Some(5)).unwrap();
+ assert_eq!(display.overview.network, "Dash");
+ assert!(!display.overview.has_witness_only_inputs);
+ assert_eq!(
+ display.overview.from,
+ crate::parse_psbt_extend(fixture().serialize(), context(), Some(5))
+ .unwrap()
+ .overview
+ .from
+ );
+ crate::check_psbt_extend(bytes.clone(), context(), Some(5)).unwrap();
+ let signed = crate::sign_psbt_extend(bytes.clone(), &seed(), fp(), Some(5)).unwrap();
+ verify_signed(&signed);
+ assert!(
+ crate::parse_psbt_hex_sign_status(&signed)
+ .unwrap()
+ .is_completed
+ );
+ assert_eq!(
+ crate::parse_psbt_extend(signed.clone(), context(), Some(5))
+ .unwrap()
+ .overview
+ .to,
+ display.overview.to
+ );
+ let mut returned = maps(&signed);
+ returned[1].retain(|key, _| key[0] != 2);
+ assert_eq!(returned, original);
+ assert!(!returned[1].contains_key(&vec![1]));
+ assert_eq!(
+ crate::sign_psbt_extend(signed.clone(), &seed(), fp(), Some(5)).unwrap(),
+ signed
+ );
+ assert!(crate::sign_psbt(bytes.clone(), &seed(), fp()).is_err());
+ assert!(crate::parse_psbt(bytes.clone(), context()).is_err());
+ assert!(crate::check_psbt(bytes, context()).is_err());
+ }
+ #[test]
+ fn dash_real_cbtx_txid_and_mixed_input_spend() {
+ let raw = cbtx();
+ let (previous, txid) = previous_transaction(&raw).unwrap();
+ assert_eq!(
+ txid.to_string(),
+ "c550cae3f65d396a2f517a7220c7851cc3dc065e20141dadf9f19676348730f2"
+ );
+ assert_eq!(previous.output[1].value.to_sat(), 154021112);
+ assert_ne!(previous.compute_txid(), txid);
+ let mut p = fixture();
+ let mut external = p.unsigned_tx.input[0].clone();
+ external.previous_output = bitcoin::OutPoint::new(txid, 1);
+ p.unsigned_tx.input.push(external);
+ p.inputs.push(bitcoin::psbt::Input::default());
+ let mut original = maps(&p.serialize());
+ original[2].insert(vec![0], raw.clone());
+ let bytes = encode_maps(&original);
+ crate::parse_psbt_extend(bytes.clone(), context(), Some(5)).unwrap();
+ crate::check_psbt_extend(bytes.clone(), context(), Some(5)).unwrap();
+ let signed = crate::sign_psbt_extend(bytes, &seed(), fp(), Some(5)).unwrap();
+ verify_signed(&signed);
+ assert_eq!(maps(&signed)[2][&vec![0]], raw);
+ assert!(crate::parse_psbt_hex_sign_status(&signed).is_ok());
+ }
+ #[test]
+ fn dash_zero_input_special_prevout_and_global_xpub() {
+ let p = fixture();
+ let prevout = p.inputs[0].non_witness_utxo.as_ref().unwrap().output[0].clone();
+ let mut raw = serialize(&0x00090003i32);
+ raw.extend(serialize(&Vec::<bitcoin::TxIn>::new()));
+ raw.extend(serialize(&vec![prevout]));
+ raw.extend(serialize(&0u32));
+ raw.extend(serialize(&VarInt(4)));
+ raw.extend([1, 2, 3, 4]);
+ let (previous, txid) = previous_transaction(&raw).unwrap();
+ assert!(previous.input.is_empty());
+ let mut p = p;
+ p.unsigned_tx.input[0].previous_output.txid = txid;
+ let path = DerivationPath::from_str("m/44'/5'/0'").unwrap();
+ let xpub = keystore::algorithms::secp256k1::get_extended_public_key_by_seed(
+ &seed(),
+ &path.to_string(),
+ )
+ .unwrap();
+ p.xpub.insert(xpub, (fp(), path));
+ let mut wire = maps(&p.serialize());
+ wire[1].insert(vec![0], raw.clone());
+ let bytes = encode_maps(&wire);
+ crate::check_psbt_extend(bytes.clone(), context(), Some(5)).unwrap();
+ let signed = crate::sign_psbt_extend(bytes, &seed(), fp(), Some(5)).unwrap();
+ verify_signed(&signed);
+ assert_eq!(maps(&signed)[1][&vec![0]], raw);
+ assert_eq!(
+ crate::parse_psbt_extend(signed.clone(), context(), Some(5))
+ .unwrap()
+ .overview
+ .network,
+ "Dash"
+ );
+ assert!(
+ crate::parse_psbt_hex_sign_status(&signed)
+ .unwrap()
+ .is_completed
+ );
+ }
+
+ #[test]
+ fn dash_rejects_tampered_and_missing_previous_transactions() {
+ let original = special();
+ let mut p = original.clone();
+ *p[1].get_mut(&vec![0]).unwrap().last_mut().unwrap() ^= 1;
+ reject(&p);
+ let mut p = original.clone();
+ p[1].remove(&vec![0]);
+ reject(&p);
+ let mut p = original.clone();
+ let (_, used): (Transaction, usize) = deserialize_partial(&p[1][&vec![0]]).unwrap();
+ p[1].get_mut(&vec![0]).unwrap().truncate(used);
+ reject(&p);
+ for change_txid in [false, true] {
+ let mut p = original.clone();
+ let mut tx: Transaction = deserialize(&p[0][&vec![0]]).unwrap();
+ if change_txid {
+ tx.input[0].previous_output.txid = Txid::all_zeros();
+ } else {
+ tx.input[0].previous_output.vout = u32::MAX;
+ }
+ p[0].insert(vec![0], serialize(&tx));
+ reject(&p);
+ }
+ let prevout = fixture().inputs[0]
+ .non_witness_utxo
+ .as_ref()
+ .unwrap()
+ .output[0]
+ .clone();
+ let mut p = original.clone();
+ p[1].insert(vec![1], serialize(&prevout));
+ crate::check_psbt_extend(encode_maps(&p), context(), Some(5)).unwrap();
+ let mut wrong_value = prevout;
+ wrong_value.value = bitcoin::Amount::from_sat(1);
+ p[1].insert(vec![1], serialize(&wrong_value));
+ reject(&p);
+ let mut p = original;
+ let mut tx: Transaction = deserialize(&p[0][&vec![0]]).unwrap();
+ tx.version = bitcoin::transaction::Version(0x00050003);
+ p[0].insert(vec![0], serialize(&tx));
+ reject(&p);
+ }
+ #[test]
+ fn dash_rejects_truncation_duplicates_and_payload_length_errors() {
+ let original = special();
+ let bytes = encode_maps(&original);
+ for end in 0..bytes.len() {
+ assert!(DashPsbt::decode(&bytes[..end]).is_err(), "prefix {end}");
+ }
+ let mut trailing = bytes.clone();
+ trailing.push(0);
+ assert!(DashPsbt::decode(&trailing).is_err());
+ let mut duplicate = b"psbt\xff".to_vec();
+ for _ in 0..2 {
+ duplicate.extend([1, 0]);
+ let value = &original[0][&vec![0]];
+ duplicate.extend(serialize(&VarInt(value.len() as u64)));
+ duplicate.extend(value);
+ }
+ duplicate.push(0);
+ assert!(DashPsbt::decode(&duplicate).is_err());
+ let raw = &original[1][&vec![0]];
+ let (_, used): (Transaction, usize) = deserialize_partial(raw).unwrap();
+ for suffix in [
+ vec![],
+ vec![71],
+ vec![0xfd, 70, 0],
+ [serialize(&VarInt(10001)), vec![0; 10001]].concat(),
+ ] {
+ let mut broken = raw[..used].to_vec();
+ broken.extend(suffix);
+ assert!(previous_transaction(&broken).is_err());
+ }
+ }
+}
### rust/apps/bitcoin/src/transactions/psbt/extend.rs
@@ -0,0 +1,510 @@
+use crate::{
+ errors::{BitcoinError, Result},
+ network::Network,
+};
+use alloc::string::ToString;
+use bitcoin::{
+ bip32::{ChildNumber, DerivationPath},
+ psbt::Psbt,
+ NetworkKind,
+};
+
+fn invalid() -> BitcoinError {
+ BitcoinError::InvalidPsbt("PSBT metadata conflicts with the PSBT Extend coin ID".to_string())
+}
+
+pub(crate) fn network_for_coin(coin_id: Option<i128>) -> Result<Network> {
+ match coin_id {
+ Some(2) => Ok(Network::Litecoin),
+ Some(3) => Ok(Network::Dogecoin),
+ Some(5) => Ok(Network::Dash),
+ Some(145) => Ok(Network::BitcoinCash),
+ _ => Err(BitcoinError::InvalidPsbt(
+ "missing or unsupported PSBT Extend coin ID".to_string(),
+ )),
+ }
+}
+
+pub(crate) fn validate(psbt: &Psbt, coin_id: Option<i128>) -> Result<Network> {
+ let network = network_for_coin(coin_id)?;
+ let coin = coin_id.unwrap() as u32;
+ if psbt.unknown.keys().any(|key| key.key == b"chain") {
+ return Err(invalid());
+ }
+ let check_path = |path: &DerivationPath, account: bool| -> Result<()> {
+ let parts = path.as_ref();
+ if parts.len() != if account { 3 } else { 5 } {
+ return Err(invalid());
+ }
+ let purpose_ok = match parts[0] {
+ ChildNumber::Hardened { index } => {
+ if coin == 2 {
+ matches!(index, 49 | 84)
+ } else {
+ index == 44
+ }
+ }
+ _ => false,
+ };
+ if !purpose_ok
+ || parts[1] != (ChildNumber::Hardened { index: coin })
+ || !parts[2].is_hardened()
+ || parts[3..].iter().any(|part| part.is_hardened())
+ {
+ return Err(invalid());
+ }
+ Ok(())
+ };
+ for (xpub, (_, path)) in &psbt.xpub {
+ if xpub.network != NetworkKind::Main {
+ return Err(invalid());
+ }
+ check_path(path, true)?;
+ }
+ for input in &psbt.inputs {
+ for (_, path) in input.bip32_derivation.values() {
+ check_path(path, false)?;
+ }
+ if !input.tap_key_origins.is_empty()
+ || input.tap_internal_key.is_some()
+ || input.tap_merkle_root.is_some()
+ || !input.tap_scripts.is_empty()
+ || !input.tap_script_sigs.is_empty()
+ || input.tap_key_sig.is_some()
+ {
+ return Err(invalid());
+ }
+ }
+ for output in &psbt.outputs {
+ for (_, path) in output.bip32_derivation.values() {
+ check_path(path, false)?;
+ }
+ if !output.tap_key_origins.is_empty()
+ || output.tap_internal_key.is_some()
+ || output.tap_tree.is_some()
+ {
+ return Err(invalid());
+ }
+ }
+ if matches!(coin, 3 | 5) && psbt.unsigned_tx.output.is_empty() {
+ return Err(BitcoinError::NoOutputs);
+ }
+ if coin == 145 {
+ super::bch::validate_outputs(psbt)?;
+ }
+ Ok(network)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::{addresses::address::Address, parsed_tx::ParseContext};
+ use alloc::{collections::BTreeMap, vec::Vec};
+ use bitcoin::{
+ bip32::{Fingerprint, Xpub},
+ ScriptBuf,
+ };
+ use core::str::FromStr;
+ fn seed() -> Vec<u8> {
+ hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap()
+ }
+ fn fp() -> Fingerprint {
+ Fingerprint::from_str("73c5da0a").unwrap()
+ }
+ fn account(coin: i128) -> (DerivationPath, Xpub) {
+ let purpose = if coin == 2 { 84 } else { 44 };
+ let path = DerivationPath::from_str(&format!("m/{purpose}'/{coin}'/0'")).unwrap();
+ let xpub = keystore::algorithms::secp256k1::get_extended_public_key_by_seed(
+ &seed(),
+ &path.to_string(),
+ )
+ .unwrap();
+ (path, xpub)
+ }
+ fn context(coin: i128) -> ParseContext {
+ let (path, xpub) = account(coin);
+ ParseContext::new(fp(), BTreeMap::from([(path, xpub)]), None, None)
+ }
+ fn fixture(coin: i128) -> Psbt {
+ let data = match coin {
+ 2 => "70736274ff01007101000000011bfed2d08a2b45c790930953230bdc406eca13e579b5049eb751086b3ed369420000000000ffffffff02005a62020000000016001477f2208e272bef80e98ce956e05d5ed8f596f5a3f05f930300000000160014267f2c10ac39e483c00c982efdd0112bcc3e62830000000000010054010000000130297791cbb43ddbe1b17406f92f79b653a585f061213749fb069644b7f7ffbb00000000020101ffffffff0100e1f5050000000016001496cd3178f3de0f307bcee1aeaa4d5987862dd30a0000000001011f00e1f5050000000016001496cd3178f3de0f307bcee1aeaa4d5987862dd30a01030401000000220602e49c9b9b5d0f127235dc26a0c252814c52fb333d651a946773f59d72c2da99041873c5da0a540000800200008000000080000000000000000000002202029857513f0fe1dc125f219ffef22098e14c653c4bcb0a2aaeff47b3a252569f1a1873c5da0a540000800200008000000080010000000000000000",
+ 3 => "70736274ff0100770100000001faf994b04953ae7fbd735800e48605de15ded8126b9308556ad98962327ab3430000000000ffffffff02005a6202000000001976a9143bf96544e911ca728f5fabf5a4f3b65deab684c488acc0448403000000001976a91419115174dcc75cce4802aaec82e63b491274c2e288ac000000000001005701000000016f9512863e3f25696cc723f570d3c4077785f1944a895895a70750689453e48b00000000020101ffffffff0100e1f505000000001976a9144a483568665dcdfa68dd58a1f62893448a64333988ac0000000001030401000000220602cc6b0dc33aabcf3a23643e5e2919a80c50fb3dd2129ce409bbc5f0d4643d05e01873c5da0a2c0000800300008000000080000000000000000000002202020745c065a8b7cb03a843a57339cf9164d675a2e5010c6fbd61c09239bbb5f4df1873c5da0a2c0000800300008000000080010000000000000000",
+ 5 => "70736274ff010077010000000102754c72a9069560e14bf2faa47998f4442149e798cff5f8c953e7d92ab219d20000000000ffffffff02005a6202000000001976a9140a38ec3f3cc4c169c295ddb037c31c63bf2fa39188acf05f9303000000001976a914265a7d4ef63d643548a599c8fa53a0d9ef3fdca488ac0000000000010057010000000105d94a72185cf340264af0461c176c985bf0d55fef0026c94447f723ec03f90600000000020101ffffffff0100e1f505000000001976a9148a4f58c222cd5544c527bc66925652baa70b5e8088ac00000000010304010000002206026fa9a6f213b6ba86447965f6b4821264aaadd7521f049f00db9c43a770ea74051873c5da0a2c000080050000800000008000000000000000000000220202bd7b0ae9a8a0e67f82891d92545433e1b37074ab0bf5867b977f8c70b00f28671873c5da0a2c0000800500008000000080010000000000000000",
+ 145 => "70736274ff0100770100000001df92cf31d578229fa876e7bf2f5696798f4d18d28e0066010e67feb6f5fb00b90000000000ffffffff02005a6202000000001976a9144f04b6e897c1a3dfe2b74bfc40cbc4d9c64daf3088ac18839303000000001976a914cfdcdfa3e0483ddd3c7b6ab6ee13c5087c26d5f188ac0000000000010057010000000153ef901d37f8bfee6f9453ff7b8dc3e0672ee715498dae97db9dca73261f9a3300000000020101ffffffff0100e1f505000000001976a914086a977c7dad32a56996af2ce90a727238d4899888ac0000000001030441000000220602bbe7dbcdf8b2261530a867df7180b17a90b482f74f2736b8a30d3f756e42e2171873c5da0a2c000080910000800000008000000000000000000000220202f178b9410d11e47e10bef8a8e4bc53e48d9ae15864a024a54f87a802dad5f5141873c5da0a2c0000809100008000000080010000000000000000",
+ _ => unreachable!(),
+ };
+ Psbt::deserialize(&hex::decode(data).unwrap()).unwrap()
+ }
+ fn rejected_at_all_stages(psbt: &Psbt, coin: i128) {
+ assert!(crate::parse_psbt_extend(psbt.serialize(), context(coin), Some(coin)).is_err());
+ assert!(crate::check_psbt_extend(psbt.serialize(), context(coin), Some(coin)).is_err());
+ assert!(crate::sign_psbt_extend(psbt.serialize(), &seed(), fp(), Some(coin)).is_err());
+ }
+
+ #[test]
+ fn invalid_coin_ids_are_rejected_at_every_extend_entry() {
+ for coin_id in [
+ None,
+ Some(0),
+ Some(1),
+ Some(4),
+ Some(-1),
+ Some(146),
+ Some(i128::MIN),
+ Some(i128::MAX),
+ ] {
+ for bytes in [fixture(3).serialize(), Vec::new()] {
+ let expected = BitcoinError::InvalidPsbt(
+ "missing or unsupported PSBT Extend coin ID".to_string(),
+ );
+ assert_eq!(
+ crate::parse_psbt_extend(bytes.clone(), context(3), coin_id).unwrap_err(),
+ expected
+ );
+ assert_eq!(
+ crate::check_psbt_extend(bytes.clone(), context(3), coin_id).unwrap_err(),
+ expected
+ );
+ assert_eq!(
+ crate::sign_psbt_extend(bytes, &seed(), fp(), coin_id).unwrap_err(),
+ expected
+ );
+ }
+ }
+ }
+
+ #[test]
+ fn global_xpub_cannot_override_any_extend_network() {
+ for (coin, name) in [
+ (2, "Litecoin"),
+ (3, "Dogecoin"),
+ (5, "Dash"),
+ (145, "Bitcoin Cash"),
+ ] {
+ let mut p = fixture(coin);
+ let (path, xpub) = account(coin);
+ p.xpub.insert(xpub, (fp(), path));
+ let parsed =
+ crate::parse_psbt_extend(p.serialize(), context(coin), Some(coin)).unwrap();
+ assert_eq!(parsed.overview.network, name);
+ let original =
+ crate::parse_psbt_extend(fixture(coin).serialize(), context(coin), Some(coin))
+ .unwrap();
+ assert_eq!(parsed.overview.from, original.overview.from);
+ assert_eq!(parsed.overview.to, original.overview.to);
+ crate::check_psbt_extend(p.serialize(), context(coin), Some(coin)).unwrap();
+ let signed = crate::sign_psbt_extend(p.serialize(), &seed(), fp(), Some(coin)).unwrap();
+ assert!(
+ crate::parse_psbt_hex_sign_status(&signed)
+ .unwrap()
+ .is_completed
+ );
+ if coin == 145 {
+ assert!(crate::sign_psbt(signed.clone(), &seed(), fp()).is_err());
+ }
+ let signed_display =
+ crate::parse_psbt_extend(signed, context(coin), Some(coin)).unwrap();
+ assert_eq!(signed_display.overview.network, name);
+ assert_eq!(signed_display.overview.to, parsed.overview.to);
+ }
+ }
+
+ #[test]
+ fn bch_sign_status_rejects_conflicting_global_xpub_metadata() {
+ let (path, xpub) = account(145);
+ let mut testnet_xpub = xpub;
+ testnet_xpub.network = NetworkKind::Test;
+ for (key, origin) in [
+ (xpub, DerivationPath::from_str("m/44'/0'/0'").unwrap()),
+ (testnet_xpub, path),
+ (xpub, DerivationPath::default()),
+ ] {
+ let mut p = fixture(145);
+ p.xpub.insert(key, (fp(), origin));
+ let signed = super::super::bch::sign(&p.serialize(), &seed(), fp()).unwrap();
+ assert!(crate::parse_psbt_hex_sign_status(&signed).is_err());
+ }
+ }
+
+ #[test]
+ fn conflicting_metadata_is_rejected_before_approval_and_signing() {
+ for coin in [2, 3, 5, 145] {
+ let original = fixture(coin);
+ let (path, mut xpub) = account(coin);
+ let mut p = original.clone();
+ p.xpub.insert(
+ xpub,
+ (fp(), DerivationPath::from_str("m/44'/0'/0'").unwrap()),
+ );
+ rejected_at_all_stages(&p, coin);
+ let mut p = original.clone();
+ xpub.network = NetworkKind::Test;
+ p.xpub.insert(xpub, (fp(), path));
+ rejected_at_all_stages(&p, coin);
+ let mut p = original.clone();
+ p.inputs[0].bip32_derivation.values_mut().next().unwrap().1 =
+ DerivationPath::from_str("m/44'/0'/0'/0/0").unwrap();
+ rejected_at_all_stages(&p, coin);
+ let mut p = original.clone();
+ p.outputs[1].bip32_derivation.values_mut().next().unwrap().1 =
+ DerivationPath::from_str("m/44'/0'/0'/1/0").unwrap();
+ rejected_at_all_stages(&p, coin);
+ let mut p = original.clone();
+ p.inputs[0].bip32_derivation.values_mut().next().unwrap().1 = DerivationPath::default();
+ rejected_at_all_stages(&p, coin);
+ for marker in [b"fb".to_vec(), b"tfb".to_vec(), b"unknown".to_vec()] {
+ let mut p = original.clone();
+ p.unknown.insert(
+ bitcoin::psbt::raw::Key {
+ type_value: 0xfc,
+ key: b"chain".to_vec(),
+ },
+ marker,
+ );
+ rejected_at_all_stages(&p, coin);
+ }
+ }
+ }
+
+ #[test]
+ fn bch_foreign_input_display_keys_must_match_authenticated_prevout() {
+ let mut p = fixture(145);
+ let mut foreign = p.inputs[0].clone();
+ let (foreign_key, (_, foreign_path)) = p.outputs[1]
+ .bip32_derivation
+ .first_key_value()
+ .map(|(key, origin)| (*key, origin.clone()))
+ .unwrap();
+ foreign.bip32_derivation =
+ BTreeMap::from([(foreign_key, (Fingerprint::default(), foreign_path.clone()))]);
+ let previous = foreign.non_witness_utxo.as_mut().unwrap();
+ previous.output[0].script_pubkey =
+ ScriptBuf::new_p2pkh(&bitcoin::PublicKey::new(foreign_key).pubkey_hash());
+ let mut txin = p.unsigned_tx.input[0].clone();
+ txin.previous_output.txid = previous.compute_txid();
+ p.inputs.push(foreign);
+ p.unsigned_tx.input.push(txin);
+
+ let expected = Address::from_script(
+ &p.inputs[1].non_witness_utxo.as_ref().unwrap().output[0].script_pubkey,
+ Network::BitcoinCash,
+ )
+ .unwrap()
+ .to_string();
+ let parsed = crate::parse_psbt_extend(p.serialize(), context(145), Some(145)).unwrap();
+ assert!(parsed.overview.from.iter().any(|input| input == &expected));
+ crate::check_psbt_extend(p.serialize(), context(145), Some(145)).unwrap();
+ let signed = crate::sign_psbt_extend(p.serialize(), &seed(), fp(), Some(145)).unwrap();
+ let decoded = super::super::bch::deserialize(&signed).unwrap();
+ assert_eq!(decoded.inputs[0].partial_sigs.len(), 1);
+ assert!(decoded.inputs[1].partial_sigs.is_empty());
+
+ let mut forged = p.clone();
+ let fake_key = *p.inputs[0].bip32_derivation.keys().next().unwrap();
+ forged.inputs[1].bip32_derivation =
+ BTreeMap::from([(fake_key, (Fingerprint::default(), foreign_path.clone()))]);
+ let expected_error = BitcoinError::InvalidPsbt(
+ "BCH input public key does not match previous output".to_string(),
+ );
+ assert_eq!(
+ crate::parse_psbt_extend(forged.serialize(), context(145), Some(145)).unwrap_err(),
+ expected_error
+ );
+ assert_eq!(
+ crate::check_psbt_extend(forged.serialize(), context(145), Some(145)).unwrap_err(),
+ expected_error
+ );
+ assert_eq!(
+ crate::sign_psbt_extend(forged.serialize(), &seed(), fp(), Some(145)).unwrap_err(),
+ expected_error
+ );
+ forged.inputs[1]
+ .bip32_derivation
+ .extend(p.inputs[1].bip32_derivation.clone());
+ rejected_at_all_stages(&forged, 145);
+
+ let mut missing = p.clone();
+ missing.inputs[1].non_witness_utxo = None;
+ rejected_at_all_stages(&missing, 145);
+ let mut tampered = p.clone();
+ tampered.inputs[1].non_witness_utxo.as_mut().unwrap().output[0].value =
+ bitcoin::Amount::from_sat(1);
+ rejected_at_all_stages(&tampered, 145);
+ let mut out_of_bounds = p.clone();
+ out_of_bounds.unsigned_tx.input[1].previous_output.vout = u32::MAX;
+ rejected_at_all_stages(&out_of_bounds, 145);
+ let mut mismatch = p;
+ let mut witness = mismatch.inputs[1].non_witness_utxo.as_ref().unwrap().output[0].clone();
+ witness.value = bitcoin::Amount::from_sat(1);
+ mismatch.inputs[1].witness_utxo = Some(witness);
+ rejected_at_all_stages(&mismatch, 145);
+ }
+
+ #[test]
+ fn bch_p2sh_recipient_is_exact_cashaddr_and_signable() {
+ let script = ScriptBuf::from_bytes(
+ hex::decode("a91476a04053bda0a88bda5177b86a15c3b29f55987387").unwrap(),
+ );
+ let expected = "ppm2qsznhks23z7629mms6s4cwef74vcwvn0h829pq";
+ let address = Address::from_script(&script, Network::BitcoinCash)
+ .unwrap()
+ .to_string();
+ assert_eq!(address, expected);
+ assert_eq!(Address::from_str(expected).unwrap().script_pubkey(), script);
+ let mut p = fixture(145);
+ p.unsigned_tx.output[0].script_pubkey = script;
+ let display = crate::parse_psbt_extend(p.serialize(), context(145), Some(145)).unwrap();
+ assert_eq!(display.detail.to[0].address, expected);
+ assert!(display
+ .overview
+ .to
+ .iter()
+ .any(|output| output.address == expected));
+ crate::check_psbt_extend(p.serialize(), context(145), Some(145)).unwrap();
+ let signed = crate::sign_psbt_extend(p.serialize(), &seed(), fp(), Some(145)).unwrap();
+ let signed_display = crate::parse_psbt_extend(signed, context(145), Some(145)).unwrap();
+ assert_eq!(signed_display.detail.to[0].address, expected);
+ let mut different_script = p.unsigned_tx.output[0].script_pubkey.clone().into_bytes();
+ different_script[2] ^= 1;
+ let different_script = ScriptBuf::from_bytes(different_script);
+ let different_address = Address::from_script(&different_script, Network::BitcoinCash)
+ .unwrap()
+ .to_string();
+ assert_ne!(different_address, expected);
+ assert_eq!(
+ Address::from_str(&different_address)
+ .unwrap()
+ .script_pubkey(),
+ different_script
+ );
+ }
+
+ #[test]
+ fn doge_dash_non_address_outputs_display_scripts_and_sign() {
+ let mut witness_script_hash = vec![0x00, 0x20];
+ witness_script_hash.extend_from_slice(&[1; 32]);
+ let mut taproot = vec![0x51, 0x20];
+ taproot.extend_from_slice(&[1; 32]);
+ for coin in [3, 5] {
+ for script in [
+ ScriptBuf::new(),
+ ScriptBuf::from_bytes(vec![0x51]),
+ ScriptBuf::from_bytes(
+ hex::decode("001476a04053bda0a88bda5177b86a15c3b29f559873").unwrap(),
+ ),
+ ScriptBuf::from_bytes(witness_script_hash.clone()),
+ ScriptBuf::from_bytes(taproot.clone()),
+ ] {
+ for index in 0..fixture(coin).unsigned_tx.output.len() {
+ let mut p = fixture(coin);
+ p.unsigned_tx.output[index].script_pubkey = script.clone();
+ let display =
+ crate::parse_psbt_extend(p.serialize(), context(coin), Some(coin)).unwrap();
+ let expected = if script.is_empty() {
+ "(empty script)".to_string()
+ } else {
+ script.to_string()
+ };
+ assert_eq!(display.detail.to[index].address, expected);
+ assert!(!display.detail.to[index].is_mine);
+ assert!(display
+ .overview
+ .to
+ .iter()
+ .any(|output| output.address == expected));
+ crate::check_psbt_extend(p.serialize(), context(coin), Some(coin)).unwrap();
+ let signed =
+ crate::sign_psbt_extend(p.serialize(), &seed(), fp(), Some(coin)).unwrap();
+ assert_eq!(
+ Psbt::deserialize(&signed).unwrap().unsigned_tx.output,
+ p.unsigned_tx.output
+ );
+ }
+ }
+ let mut p = fixture(coin);
+ p.unsigned_tx.output.clear();
+ p.outputs.clear();
+ rejected_at_all_stages(&p, coin);
+ }
+ }
+
+ #[test]
+ fn doge_dash_op_return_displays_script_and_preserves_output_when_signing() {
+ for coin in [3, 5] {
+ for script in [
+ ScriptBuf::from_bytes(vec![0x6a]),
+ ScriptBuf::from_bytes(hex::decode("6a0568656c6c6f").unwrap()),
+ ScriptBuf::from_bytes(hex::decode("6a0300ff80").unwrap()),
+ ] {
+ for index in 0..fixture(coin).unsigned_tx.output.len() {
+ let mut p = fixture(coin);
+ p.unsigned_tx.output[index].script_pubkey = script.clone();
+ let display =
+ crate::parse_psbt_extend(p.serialize(), context(coin), Some(coin)).unwrap();
+ assert_eq!(display.detail.to[index].address, script.to_string());
+ assert_eq!(
+ display.detail.to[index].value,
+ p.unsigned_tx.output[index].value.to_sat()
+ );
+ assert!(!display.detail.to[index].is_mine);
+ assert!(display
+ .overview
+ .to
+ .iter()
+ .any(|output| output.address == script.to_string()));
+ crate::check_psbt_extend(p.serialize(), context(coin), Some(coin)).unwrap();
+ let signed =
+ crate::sign_psbt_extend(p.serialize(), &seed(), fp(), Some(coin)).unwrap();
+ let signed = Psbt::deserialize(&signed).unwrap();
+ assert_eq!(signed.unsigned_tx.output, p.unsigned_tx.output);
+ assert!(!signed.inputs[0].partial_sigs.is_empty());
+ }
+ }
+ }
+ }
+
+ #[test]
+ fn doge_dash_supported_outputs_display_and_sign() {
+ for coin in [3, 5] {
+ for script in [
+ fixture(coin).unsigned_tx.output[0].script_pubkey.clone(),
+ ScriptBuf::from_bytes(
+ hex::decode("a91476a04053bda0a88bda5177b86a15c3b29f55987387").unwrap(),
+ ),
+ ] {
+ let mut p = fixture(coin);
+ p.unsigned_tx.output[0].script_pubkey = script.clone();
+ let display =
+ crate::parse_psbt_extend(p.serialize(), context(coin), Some(coin)).unwrap();
+ let address = &display.detail.to[0].address;
+ assert_eq!(Address::from_str(address).unwrap().script_pubkey(), script);
+ assert!(display
+ .overview
+ .to
+ .iter()
+ .any(|output| &output.address == address));
+ crate::check_psbt_extend(p.serialize(), context(coin), Some(coin)).unwrap();
+ let signed =
+ crate::sign_psbt_extend(p.serialize(), &seed(), fp(), Some(coin)).unwrap();
+ let signed_display =
+ crate::parse_psbt_extend(signed, context(coin), Some(coin)).unwrap();
+ assert_eq!(signed_display.detail.to[0].address, *address);
+ }
+ }
+ }
+
+ #[test]
+ fn bch_unrenderable_outputs_rejected_at_all_stages() {
+ for script in [
+ ScriptBuf::new(),
+ ScriptBuf::from_bytes(vec![0x6a]),
+ ScriptBuf::from_bytes(
+ hex::decode("001476a04053bda0a88bda5177b86a15c3b29f559873").unwrap(),
+ ),
+ ] {
+ let mut p = fixture(145);
+ p.unsigned_tx.output[0].script_pubkey = script;
+ rejected_at_all_stages(&p, 145);
+ }
+ }
+}
### rust/apps/bitcoin/src/transactions/psbt/mod.rs
@@ -1,2 +1,5 @@
+pub(crate) mod bch;
+pub(crate) mod dash;
+pub(crate) mod extend;
pub mod parsed_psbt;
pub mod wrapped_psbt;
### rust/apps/bitcoin/src/transactions/psbt/parsed_psbt.rs
@@ -11,46 +11,7 @@ use core::ops::Index;
impl TxParser for WrappedPsbt {
fn parse(&self, context: Option<&ParseContext>) -> Result<ParsedTx> {
let network = self.determine_network()?;
- let context = context.ok_or(BitcoinError::InvalidParseContext(
- "empty context".to_string(),
- ))?;
- let inputs = self
- .psbt
- .inputs
- .iter()
- .enumerate()
- .map(|(i, input)| self.parse_input(input, i, context, &network))
- .collect::<Result<Vec<ParsedInput>>>()?;
- let outputs = self
- .psbt
- .outputs
- .iter()
- .enumerate()
- .map(|(i, output)| self.parse_output(output, i, context, &network))
- .collect::<Result<Vec<ParsedOutput>>>()?;
- let has_witness_only_inputs = self
- .psbt
- .inputs
- .iter()
- .any(|input| input.witness_utxo.is_some() && input.non_witness_utxo.is_none());
- let estimated_signed_vbytes = self.estimated_signed_vbytes();
-
- match self.identify_fractal_bitcoin_tx() {
- Some(custom_net) => self.normalize(
- inputs,
- outputs,
- &custom_net,
- has_witness_only_inputs,
- estimated_signed_vbytes,
- ),
- None => self.normalize(
- inputs,
- outputs,
- &network,
- has_witness_only_inputs,
- estimated_signed_vbytes,
- ),
- }
+ self.parse_in_network(context, network, true)
}
fn determine_network(&self) -> Result<Network> {
@@ -101,6 +62,60 @@ impl TxParser for WrappedPsbt {
}
}
+impl WrappedPsbt {
+ pub(crate) fn parse_in_network(
+ &self,
+ context: Option<&ParseContext>,
+ network: Network,
+ allow_custom_network: bool,
+ ) -> Result<ParsedTx> {
+ let context = context.ok_or(BitcoinError::InvalidParseContext(
+ "empty context".to_string(),
+ ))?;
+ let inputs = self
+ .psbt
+ .inputs
+ .iter()
+ .enumerate()
+ .map(|(i, input)| self.parse_input(input, i, context, &network))
+ .collect::<Result<Vec<ParsedInput>>>()?;
+ let outputs = self
+ .psbt
+ .outputs
+ .iter()
+ .enumerate()
+ .map(|(i, output)| self.parse_output(output, i, context, &network))
+ .collect::<Result<Vec<ParsedOutput>>>()?;
+ let has_witness_only_inputs = self
+ .psbt
+ .inputs
+ .iter()
+ .any(|input| input.witness_utxo.is_some() && input.non_witness_utxo.is_none());
+ let estimated_signed_vbytes = self.estimated_signed_vbytes();
+
+ match if allow_custom_network {
+ self.identify_fractal_bitcoin_tx()
+ } else {
+ None
+ } {
+ Some(custom_net) => self.normalize(
+ inputs,
+ outputs,
+ &custom_net,
+ has_witness_only_inputs,
+ estimated_signed_vbytes,
+ ),
+ None => self.normalize(
+ inputs,
+ outputs,
+ &network,
+ has_witness_only_inputs,
+ estimated_signed_vbytes,
+ ),
+ }
+ }
+}
+
#[cfg(test)]
mod tests {
extern crate std;
### rust/apps/bitcoin/src/transactions/psbt/wrapped_psbt.rs
@@ -872,7 +872,7 @@ impl WrappedPsbt {
ChildNumber::Hardened { index: _i } => match _i {
44 => match path.index(1) {
ChildNumber::Hardened { index: _i } => match _i {
- 0 | 3 => Ok(Some(
+ 0 | 3 | 5 | 145 => Ok(Some(
Address::p2pkh(&bitcoin::PublicKey::new(*pubkey), network.clone())?
.to_string(),
)),
@@ -950,6 +950,7 @@ impl WrappedPsbt {
) -> Result<String> {
match Address::from_script(&tx_out.script_pubkey, network.clone()) {
Ok(address) => Ok(address.to_string()),
+ Err(_) if tx_out.script_pubkey.is_empty() => Ok("(empty script)".to_string()),
Err(_) => Ok(tx_out.script_pubkey.to_string()),
}
}
@@ -1416,6 +1417,167 @@ mod tests {
secp256k1::PublicKey::from_secret_key(&Secp256k1::new(), &sk)
}
+ #[test]
+ fn test_psbt_extend_supported_single_sig_scripts() {
+ for (coin, purpose, network) in [
+ (2, 49, network::Network::Litecoin),
+ (2, 84, network::Network::Litecoin),
+ (5, 44, network::Network::Dash),
+ (145, 44, network::Network::BitcoinCash),
+ (3, 44, network::Network::Dogecoin),
+ ] {
+ let public_key = bitcoin::PublicKey::new(dummy_pubkey());
+ let witness_script = ScriptBuf::new_p2wpkh(&public_key.wpubkey_hash().unwrap());
+ let script_pubkey = match purpose {
+ 44 => ScriptBuf::new_p2pkh(&public_key.pubkey_hash()),
+ 49 => ScriptBuf::new_p2sh(&witness_script.script_hash()),
+ 84 => witness_script.clone(),
+ _ => unreachable!(),
+ };
+ let expected = Address::from_script(&script_pubkey, network)
+ .unwrap()
+ .to_string();
+ let mut previous_tx = empty_psbt().unsigned_tx;
+ previous_tx.output.push(TxOut {
+ value: bitcoin::Amount::from_sat(100_000),
+ script_pubkey: script_pubkey.clone(),
+ });
+ let mut unsigned_tx = empty_psbt().unsigned_tx;
+ unsigned_tx.input.push(bitcoin::TxIn {
+ previous_output: bitcoin::OutPoint::new(previous_tx.compute_txid(), 0),
+ ..Default::default()
+ });
+ unsigned_tx.output.push(TxOut {
+ value: bitcoin::Amount::from_sat(99_000),
+ script_pubkey,
+ });
+ let mut psbt = Psbt::from_unsigned_tx(unsigned_tx).unwrap();
+ psbt.inputs[0].non_witness_utxo = Some(previous_tx);
+ if purpose == 49 {
+ psbt.inputs[0].redeem_script = Some(witness_script);
+ }
+ let path = format!("m/{purpose}'/{coin}'/0'/0/0");
+ psbt.inputs[0].bip32_derivation.insert(
+ public_key.inner,
+ (
+ Fingerprint::from_str("73c5da0a").unwrap(),
+ DerivationPath::from_str(&path).unwrap(),
+ ),
+ );
+ let context = ParseContext::new(Fingerprint::default(), BTreeMap::new(), None, None);
+ let parsed = WrappedPsbt { psbt }.parse(Some(&context)).unwrap();
+ assert_eq!(
+ parsed.overview.from,
+ alloc::vec![expected.clone()],
+ "{path}"
+ );
+ assert_eq!(
+ parsed.detail.from[0].address.as_ref(),
+ Some(&expected),
+ "{path}"
+ );
+ assert_eq!(parsed.overview.to[0].address, expected, "{path}");
+ assert_eq!(parsed.detail.to[0].address, expected, "{path}");
+ }
+ }
+
+ #[test]
+ fn test_psbt_extend_script_hash_outputs() {
+ let wrapper = WrappedPsbt { psbt: empty_psbt() };
+ let redeem_script = bitcoin::script::Builder::new()
+ .push_int(1)
+ .push_key(&bitcoin::PublicKey::new(dummy_pubkey()))
+ .push_int(1)
+ .push_opcode(bitcoin::opcodes::all::OP_CHECKMULTISIG)
+ .into_script();
+ for network in [
+ network::Network::Litecoin,
+ network::Network::Dash,
+ network::Network::BitcoinCash,
+ network::Network::Dogecoin,
+ ] {
+ let script = ScriptBuf::new_p2sh(&redeem_script.script_hash());
+ let expected = Address::from_script(&script, network.clone())
+ .unwrap()
+ .to_string();
+ let output = TxOut {
+ value: bitcoin::Amount::from_sat(1000),
+ script_pubkey: script,
+ };
+ assert_eq!(
+ wrapper
+ .calculate_address_for_output(&output, &network)
+ .unwrap(),
+ expected
+ );
+ assert_eq!(
+ Address::from_str(&expected).unwrap().script_pubkey(),
+ output.script_pubkey
+ );
+ }
+ let script = ScriptBuf::new_p2wsh(&redeem_script.wscript_hash());
+ let output = TxOut {
+ value: bitcoin::Amount::from_sat(1000),
+ script_pubkey: script,
+ };
+ let address = wrapper
+ .calculate_address_for_output(&output, &network::Network::Litecoin)
+ .unwrap();
+ assert!(address.starts_with("ltc1q"));
+ assert_eq!(
+ Address::from_str(&address).unwrap().script_pubkey(),
+ output.script_pubkey
+ );
+ }
+
+ fn assert_demo_from_address(psbt_hex: &str, account_path: &str) {
+ let psbt = Psbt::deserialize(&hex::decode(psbt_hex).unwrap()).unwrap();
+ let wrapper = WrappedPsbt { psbt };
+ let network = wrapper.determine_network().unwrap();
+ let previous_output = &wrapper.psbt.inputs[0]
+ .non_witness_utxo
+ .as_ref()
+ .unwrap()
+ .output[wrapper.psbt.unsigned_tx.input[0].previous_output.vout as usize];
+ let expected = Address::from_script(&previous_output.script_pubkey, network)
+ .unwrap()
+ .to_string();
+ let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
+ let account_xpub = keystore::algorithms::secp256k1::get_extended_public_key_by_seed(
+ &seed,
+ &account_path.to_string(),
+ )
+ .unwrap();
+ let context = ParseContext::new(
+ Fingerprint::from_str("73c5da0a").unwrap(),
+ BTreeMap::from([(
+ DerivationPath::from_str(account_path).unwrap(),
+ account_xpub,
+ )]),
+ None,
+ None,
+ );
+ let parsed = wrapper.parse(Some(&context)).unwrap();
+ assert_eq!(parsed.overview.from, alloc::vec![expected.clone()]);
+ assert_eq!(parsed.detail.from[0].address.as_ref(), Some(&expected));
+ }
+
+ #[test]
+ fn test_bch_demo_from_address() {
+ assert_demo_from_address(
+ "70736274ff0100770100000001df92cf31d578229fa876e7bf2f5696798f4d18d28e0066010e67feb6f5fb00b90000000000ffffffff02005a6202000000001976a9144f04b6e897c1a3dfe2b74bfc40cbc4d9c64daf3088ac18839303000000001976a914cfdcdfa3e0483ddd3c7b6ab6ee13c5087c26d5f188ac0000000000010057010000000153ef901d37f8bfee6f9453ff7b8dc3e0672ee715498dae97db9dca73261f9a3300000000020101ffffffff0100e1f505000000001976a914086a977c7dad32a56996af2ce90a727238d4899888ac0000000001030441000000220602bbe7dbcdf8b2261530a867df7180b17a90b482f74f2736b8a30d3f756e42e2171873c5da0a2c000080910000800000008000000000000000000000220202f178b9410d11e47e10bef8a8e4bc53e48d9ae15864a024a54f87a802dad5f5141873c5da0a2c0000809100008000000080010000000000000000",
+ "m/44'/145'/0'",
+ );
+ }
+
+ #[test]
+ fn test_dash_demo_from_address() {
+ assert_demo_from_address(
+ "70736274ff010077010000000102754c72a9069560e14bf2faa47998f4442149e798cff5f8c953e7d92ab219d20000000000ffffffff02005a6202000000001976a9140a38ec3f3cc4c169c295ddb037c31c63bf2fa39188acf05f9303000000001976a914265a7d4ef63d643548a599c8fa53a0d9ef3fdca488ac0000000000010057010000000105d94a72185cf340264af0461c176c985bf0d55fef0026c94447f723ec03f90600000000020101ffffffff0100e1f505000000001976a9148a4f58c222cd5544c527bc66925652baa70b5e8088ac00000000010304010000002206026fa9a6f213b6ba86447965f6b4821264aaadd7521f049f00db9c43a770ea74051873c5da0a2c000080050000800000008000000000000000000000220202bd7b0ae9a8a0e67f82891d92545433e1b37074ab0bf5867b977f8c70b00f28671873c5da0a2c0000800500008000000080010000000000000000",
+ "m/44'/5'/0'",
+ );
+ }
+
#[test]
fn test_new_sign() {
{
### rust/apps/cardano/src/structs.rs
@@ -514,7 +514,7 @@ impl ParsedCardanoTx {
None => vec![],
};
- Ok(Self {
+ let mut parsed = Self {
total_input: total_input_amount,
total_output: total_output_amount,
from: from_list_detail,
@@ -566,14 +566,17 @@ impl ParsedCardanoTx {
withdrawals: Self::parse_withdrawals(&tx)?,
auxiliary_data: Self::parse_auxiliary_data(&tx)?,
governance_data: None,
- advanced_data: Self::parse_advanced_data(&tx)?,
+ advanced_data: None,
voting_procedures,
voting_proposals,
mint_assets,
collateral_assets,
has_multi_assets,
has_unknown_inputs,
- })
+ };
+ let advanced = Self::advanced_data_fields(tx);
+ parsed.advanced_data = Self::finish_json(advanced)?;
+ Ok(parsed)
}
fn merge_network_id(network_id: &mut Option<u8>, candidate: u8) -> Result<()> {
@@ -723,20 +726,19 @@ impl ParsedCardanoTx {
}
fn json_or_cbor_value<E>(
- json: core::result::Result<String, E>,
- cbor: Vec<u8>,
+ json: core::result::Result<serde_json::Value, E>,
+ cbor: impl FnOnce() -> Vec<u8>,
) -> serde_json::Value {
json.ok()
- .and_then(|value| serde_json::from_str(&value).ok())
.map(Self::normalize_json_for_display)
- .unwrap_or_else(|| Self::cbor_fallback_value(cbor))
+ .unwrap_or_else(|| Self::cbor_fallback_value(cbor()))
}
fn insert_json_or_cbor_field<E>(
map: &mut serde_json::Map<String, serde_json::Value>,
key: &str,
- json: core::result::Result<String, E>,
- cbor: Vec<u8>,
+ json: core::result::Result<serde_json::Value, E>,
+ cbor: impl FnOnce() -> Vec<u8>,
) {
map.insert(key.to_string(), Self::json_or_cbor_value(json, cbor));
}
@@ -754,16 +756,15 @@ impl ParsedCardanoTx {
}
Value::String(text)
}
- Value::Array(values) => Value::Array(
- values
- .into_iter()
- .map(Self::normalize_json_for_display)
- .collect(),
- ),
- Value::Object(values) => {
- let mut normalized = serde_json::Map::new();
- for (key, value) in values {
- normalized.insert(key, Self::normalize_json_for_display(value));
+ Value::Array(mut values) => {
+ for value in &mut values {
+ *value = Self::normalize_json_for_display(core::mem::take(value));
+ }
+ Value::Array(values)
+ }
+ Value::Object(mut normalized) => {
+ for value in normalized.values_mut() {
+ *value = Self::normalize_json_for_display(core::mem::take(value));
}
if normalized.len() == 1 {
@@ -811,16 +812,40 @@ impl ParsedCardanoTx {
if map.is_empty() {
return Ok(None);
}
- let json = serde_json::to_string_pretty(&serde_json::Value::Object(map))
- .map_err(|e| CardanoError::InvalidTransaction(e.to_string()))?;
- if json.len() > 64 * 1024 {
+ use core::fmt::Write;
+
+ struct JsonSize(usize);
+ impl core::fmt::Write for JsonSize {
+ fn write_str(&mut self, text: &str) -> core::fmt::Result {
+ self.0 = self.0.saturating_add(text.len());
+ Ok(())
+ }
+ }
+ let value = serde_json::Value::Object(map);
+ let mut size = JsonSize(0);
+ write!(&mut size, "{value:#}").map_err(|_| {
+ CardanoError::InvalidTransaction("advanced JSON exceeds 64 KiB limit".to_string())
+ })?;
+ if size.0 > 64 * 1024 {
return Err(CardanoError::InvalidTransaction(
"advanced JSON exceeds 64 KiB limit".to_string(),
));
}
+ let mut json = String::with_capacity(size.0 + 1);
+ write!(&mut json, "{value:#}")
+ .map_err(|e| CardanoError::InvalidTransaction(e.to_string()))?;
Ok(Some(json))
}
+ fn json_object<const N: usize>(fields: [(&str, serde_json::Value); N]) -> serde_json::Value {
+ serde_json::Value::Object(
+ fields
+ .into_iter()
+ .map(|(key, value)| (key.to_string(), value))
+ .collect(),
+ )
+ }
+
fn plutus_data_json(data: &PlutusData, depth: usize) -> serde_json::Value {
if depth >= 64 {
return serde_json::json!({
@@ -834,12 +859,22 @@ impl ParsedCardanoTx {
.as_constr_plutus_data()
.map(|constr| {
let fields = constr.data();
- serde_json::json!({
- "constructor": constr.alternative().to_str(),
- "fields": (0..fields.len())
- .map(|index| Self::plutus_data_json(&fields.get(index), depth + 1))
- .collect::<Vec<_>>()
- })
+ Self::json_object([
+ (
+ "constructor",
+ serde_json::Value::String(constr.alternative().to_str()),
+ ),
+ (
+ "fields",
+ serde_json::Value::Array(
+ (0..fields.len())
+ .map(|index| {
+ Self::plutus_data_json(&fields.get(index), depth + 1)
+ })
+ .collect(),
+ ),
+ ),
+ ])
})
.unwrap_or_else(|| Self::cbor_fallback_value(data.to_bytes())),
PlutusDataKind::Map => data
@@ -852,25 +887,28 @@ impl ParsedCardanoTx {
if let Some(values) = map.get(&key) {
for value_index in 0..values.len() {
if let Some(value) = values.get(value_index) {
- entries.push(serde_json::json!({
- "k": Self::plutus_data_json(&key, depth + 1),
- "v": Self::plutus_data_json(&value, depth + 1)
- }));
+ entries.push(Self::json_object([
+ ("k", Self::plutus_data_json(&key, depth + 1)),
+ ("v", Self::plutus_data_json(&value, depth + 1)),
+ ]));
}
}
}
}
- serde_json::json!({ "map": entries })
+ Self::json_object([("map", serde_json::Value::Array(entries))])
})
.unwrap_or_else(|| Self::cbor_fallback_value(data.to_bytes())),
PlutusDataKind::List => data
.as_list()
.map(|list| {
- serde_json::json!({
- "list": (0..list.len())
- .map(|index| Self::plutus_data_json(&list.get(index), depth + 1))
- .collect::<Vec<_>>()
- })
+ Self::json_object([(
+ "list",
+ serde_json::Value::Array(
+ (0..list.len())
+ .map(|index| Self::plutus_data_json(&list.get(index), depth + 1))
+ .collect(),
+ ),
+ )])
})
.unwrap_or_else(|| Self::cbor_fallback_value(data.to_bytes())),
PlutusDataKind::Integer => data
@@ -899,7 +937,7 @@ impl ParsedCardanoTx {
let amount = output.amount();
value.insert(
"amount".to_string(),
- Self::json_or_cbor_value(amount.to_json(), amount.to_bytes()),
+ Self::json_or_cbor_value(serde_json::to_value(&amount), || amount.to_bytes()),
);
if let Some(data_hash) = output.data_hash() {
value.insert(
@@ -916,45 +954,47 @@ impl ParsedCardanoTx {
if let Some(script_ref) = output.script_ref() {
value.insert(
"script_ref".to_string(),
- Self::json_or_cbor_value(script_ref.to_json(), script_ref.to_bytes()),
+ Self::json_or_cbor_value(serde_json::to_value(&script_ref), || {
+ script_ref.to_bytes()
+ }),
);
}
serde_json::Value::Object(value)
}
- fn parse_advanced_data(tx: &Transaction) -> Result<Option<String>> {
+ fn advanced_data_fields(tx: Transaction) -> serde_json::Map<String, serde_json::Value> {
let body = tx.body_ref();
let mut map = serde_json::Map::new();
if let Some(value) = tx.auxiliary_data_ref() {
Self::insert_json_or_cbor_field(
&mut map,
"auxiliary_data",
- value.to_json(),
- value.to_bytes(),
+ serde_json::to_value(&value),
+ || value.to_bytes(),
);
}
if let Some(value) = body.voting_proposals_ref() {
Self::insert_json_or_cbor_field(
&mut map,
"voting_proposals",
- value.to_json(),
- value.to_bytes(),
+ serde_json::to_value(&value),
+ || value.to_bytes(),
);
}
if let Some(value) = body.voting_procedures_ref() {
Self::insert_json_or_cbor_field(
&mut map,
"voting_procedures",
- value.to_json(),
- value.to_bytes(),
+ serde_json::to_value(&value),
+ || value.to_bytes(),
);
}
if let Some(value) = body.certs_ref() {
Self::insert_json_or_cbor_field(
&mut map,
"certificates",
- value.to_json(),
- value.to_bytes(),
+ serde_json::to_value(&value),
+ || value.to_bytes(),
);
}
if let Some(value) = body.auxiliary_data_hash() {
@@ -967,8 +1007,8 @@ impl ParsedCardanoTx {
Self::insert_json_or_cbor_field(
&mut map,
"protocol_update",
- value.to_json(),
- value.to_bytes(),
+ serde_json::to_value(&value),
+ || value.to_bytes(),
);
}
if let Some(value) = body.script_data_hash() {
@@ -981,32 +1021,32 @@ impl ParsedCardanoTx {
Self::insert_json_or_cbor_field(
&mut map,
"collateral_inputs",
- value.to_json(),
- value.to_bytes(),
+ serde_json::to_value(&value),
+ || value.to_bytes(),
);
}
if let Some(value) = body.required_signers() {
Self::insert_json_or_cbor_field(
&mut map,
"required_signers",
- value.to_json(),
- value.to_bytes(),
+ serde_json::to_value(&value),
+ || value.to_bytes(),
);
}
if let Some(value) = body.collateral_return() {
Self::insert_json_or_cbor_field(
&mut map,
"collateral_return",
- value.to_json(),
- value.to_bytes(),
+ serde_json::to_value(&value),
+ || value.to_bytes(),
);
}
if let Some(value) = body.reference_inputs() {
Self::insert_json_or_cbor_field(
&mut map,
"reference_inputs",
- value.to_json(),
- value.to_bytes(),
+ serde_json::to_value(&value),
+ || value.to_bytes(),
);
}
if let Some(value) = body.current_treasury_value() {
@@ -1022,16 +1062,19 @@ impl ParsedCardanoTx {
.filter(|output| {
output.has_data_hash() || output.has_plutus_data() || output.has_script_ref()
})
- .map(Self::output_with_data_json)
+ .cloned()
.collect::<Vec<_>>();
+ let witness_set = tx.witness_set();
+ drop(tx);
+
if !outputs_with_data.is_empty() {
- map.insert(
- "outputs_with_datum_or_script".to_string(),
- outputs_with_data.into(),
- );
+ let values = outputs_with_data
+ .into_iter()
+ .map(|output| Self::output_with_data_json(&output))
+ .collect::<Vec<_>>();
+ map.insert("outputs_with_datum_or_script".to_string(), values.into());
}
- let witness_set = tx.witness_set();
if witness_set.native_scripts().is_some()
|| witness_set.plutus_scripts().is_some()
|| witness_set.plutus_data().is_some()
@@ -1040,11 +1083,12 @@ impl ParsedCardanoTx {
Self::insert_json_or_cbor_field(
&mut map,
"witness_set",
- witness_set.to_json(),
- witness_set.to_bytes(),
+ serde_json::to_value(&witness_set),
+ || witness_set.to_bytes(),
);
}
- Self::finish_json(map)
+ drop(witness_set);
+ map
}
fn format_stake_credential(network_id: Option<u8>, credential: &Credential) -> Result<String> {
@@ -3061,8 +3105,8 @@ mod tests {
ParsedCardanoTx::insert_json_or_cbor_field::<String>(
&mut map,
"payload",
- Ok("{\"string\":\"decoded\"}".to_string()),
- vec![],
+ Ok(serde_json::json!({"string": "decoded"})),
+ || vec![],
);
let json = ParsedCardanoTx::finish_json(map).unwrap().unwrap();
assert!(json.contains("decoded"));
@@ -3073,12 +3117,55 @@ mod tests {
ParsedCardanoTx::insert_json_or_cbor_field::<String>(
&mut fallback,
"invalid",
- Ok("not-json".to_string()),
- vec![0x01, 0x02],
+ Err("not-json".to_string()),
+ || vec![0x01, 0x02],
);
assert_eq!(fallback["invalid"]["cbor"], "0102");
}
+ #[test]
+ fn test_advanced_json_fallback_is_lazy() {
+ let result = ParsedCardanoTx::json_or_cbor_value::<String>(
+ Ok(serde_json::json!({"list": [{"int": "443000000000000000000"}]})),
+ || panic!("successful JSON must not allocate fallback CBOR"),
+ );
+ assert_eq!(result, serde_json::json!(["443000000000000000000"]));
+ let fallback = ParsedCardanoTx::json_or_cbor_value(
+ Err::<serde_json::Value, _>("serialization failed"),
+ || vec![0x01, 0xff],
+ );
+ assert_eq!(fallback["cbor"], "01ff");
+ }
+
+ #[test]
+ fn test_advanced_json_exact_sizing_and_limit() {
+ let mut map = serde_json::Map::new();
+ map.insert(
+ "escaped\nkey".to_string(),
+ serde_json::json!([
+ {"text": "中文\n\t\"\\", "values": [null, true, -1, 1.25]},
+ [], {}
+ ]),
+ );
+ let expected = serde_json::to_string_pretty(&map).unwrap();
+ assert_eq!(
+ ParsedCardanoTx::finish_json(map).unwrap().unwrap(),
+ expected
+ );
+
+ for size in [64 * 1024 - 13, 64 * 1024 - 12] {
+ let mut map = serde_json::Map::new();
+ map.insert("x".to_string(), serde_json::Value::String("a".repeat(size)));
+ let expected = serde_json::to_string_pretty(&map).unwrap();
+ let result = ParsedCardanoTx::finish_json(map);
+ if expected.len() <= 64 * 1024 {
+ assert_eq!(result.unwrap().unwrap(), expected);
+ } else {
+ assert!(result.unwrap_err().to_string().contains("64 KiB"));
+ }
+ }
+ }
+
#[test]
fn test_parse_inline_datum_with_large_integer() {
let key_hash = Ed25519KeyHash::from_bytes(vec![7u8; 28]).unwrap();
### rust/apps/monero/src/address.rs
@@ -4,6 +4,7 @@ use crate::structs::{AddressType, Network};
use crate::utils::{constants::PUBKEY_LEH, hash::keccak256};
use alloc::format;
use alloc::string::{String, ToString};
+use alloc::vec;
use base58_monero::{decode, encode};
use curve25519_dalek::edwards::EdwardsPoint;
use curve25519_dalek::scalar::Scalar;
@@ -42,6 +43,14 @@ impl Address {
Ok(decoded) => decoded,
_ => return Err(MoneroError::Base58DecodeError),
};
+
+ if decoded.len() != 1 + PUBKEY_LEH * 2 + 4 {
+ return Err(MoneroError::FormatError);
+ }
+ if keccak256(&decoded[..1 + PUBKEY_LEH * 2])[..4] != decoded[1 + PUBKEY_LEH * 2..] {
+ return Err(MoneroError::FormatError);
+ }
+
let prefix = hex::encode(&decoded[0..1]).to_uppercase();
let net = match prefix.as_str() {
"12" => Network::Mainnet,
@@ -124,8 +133,12 @@ pub fn pub_keyring_to_address(
if pub_keyring.len() != PUBKEY_LEH * 4 {
return Err(MoneroError::PubKeyringLengthError);
}
- let pub_spend_key = PublicKey::from_bytes(&hex::decode(&pub_keyring[0..64]).unwrap())?;
- let pub_view_key = PublicKey::from_bytes(&hex::decode(&pub_keyring[64..128]).unwrap())?;
+ let spend_hex =
+ hex::decode(&pub_keyring.as_bytes()[0..64]).map_err(|_| MoneroError::FormatError)?;
+ let view_hex =
+ hex::decode(&pub_keyring.as_bytes()[64..128]).map_err(|_| MoneroError::FormatError)?;
+ let pub_spend_key = PublicKey::from_bytes(&spend_hex)?;
+ let pub_view_key = PublicKey::from_bytes(&view_hex)?;
pub_keys_to_address(net, is_subaddress, &pub_spend_key, &pub_view_key)
}
@@ -173,13 +186,31 @@ fn pub_keys_to_address(
}
}
+pub fn integrated_address_string(
+ public_spend_key: &PublicKey,
+ public_view_key: &PublicKey,
+ payment_id: &[u8; 8],
+) -> Result<String> {
+ let mut payload = vec![0x13u8];
+ payload.extend_from_slice(&public_spend_key.as_bytes());
+ payload.extend_from_slice(&public_view_key.as_bytes());
+ payload.extend_from_slice(payment_id);
+
+ let checksum = keccak256(&payload);
+ payload.extend_from_slice(&checksum[0..4]);
+
+ encode(&payload).map_err(|_| MoneroError::Base58DecodeError)
+}
+
pub fn generate_address(
public_spend_key: &PublicKey,
private_view_key: &PrivateKey,
major: u32,
minor: u32,
is_subaddress: bool,
) -> Result<String> {
+ let point = public_spend_key.validate_for_address()?;
+ PrivateKey::try_from_slice(&private_view_key.to_bytes())?;
if !is_subaddress {
return Ok(Address::new(
Network::Mainnet,
@@ -190,7 +221,6 @@ pub fn generate_address(
.to_string());
}
- let point = public_spend_key.point.decompress().unwrap();
let m = Scalar::from_bytes_mod_order(calc_subaddress_m(
&private_view_key.to_bytes(),
major,
@@ -199,8 +229,9 @@ pub fn generate_address(
let pub_spend_key = PublicKey {
point: (point + EdwardsPoint::mul_base(&m)).compress(),
};
+ let sub_spend_point = pub_spend_key.validate_for_address()?;
let pub_view_point = PublicKey {
- point: (pub_spend_key.point.decompress().unwrap() * private_view_key.scalar).compress(),
+ point: (sub_spend_point * private_view_key.scalar).compress(),
};
pub_keys_to_address(Network::Mainnet, true, &pub_spend_key, &pub_view_point)
### rust/apps/monero/src/errors.rs
@@ -13,6 +13,8 @@ pub enum MoneroError {
Base58DecodeError,
#[error("format error")]
FormatError,
+ #[error("transaction request exceeds the supported display size")]
+ RequestTooComplex,
#[error("unknown network")]
UnknownNetwork,
#[error("pub_keyring length error")]
@@ -29,6 +31,8 @@ pub enum MoneroError {
UnsupportedInputType,
#[error("mismatched mfp")]
MismatchedMfp,
+ #[error("change address does not belong to this wallet")]
+ ChangeAddressMismatch,
#[error("invalid private view key")]
InvalidPrivateViewKey,
}
### rust/apps/monero/src/extra.rs
@@ -1,3 +1,4 @@
+use crate::utils::io::write_varinteger;
use alloc::vec::Vec;
use curve25519_dalek::edwards::EdwardsPoint;
@@ -52,12 +53,17 @@ impl Extra {
self.0.push(ExtraField::Nonce(nonce));
}
+ pub(crate) fn push_padding(&mut self, size: usize) {
+ if size > 0 {
+ self.0.push(ExtraField::Padding(size));
+ }
+ }
+
pub fn serialize(&self) -> Vec<u8> {
let mut res = Vec::new();
for field in &self.0 {
match field {
ExtraField::Padding(size) => {
- res.push(0x00);
res.extend(core::iter::repeat_n(0, *size));
}
ExtraField::PublicKey(key) => {
@@ -66,7 +72,7 @@ impl Extra {
}
ExtraField::Nonce(nonce) => {
res.push(0x02);
- res.extend_from_slice(&[nonce.len() as u8]);
+ res.extend_from_slice(&write_varinteger(nonce.len() as u64));
res.extend_from_slice(nonce);
}
ExtraField::MergeMining(size, data) => {
@@ -76,7 +82,7 @@ impl Extra {
}
ExtraField::PublicKeys(keys) => {
res.push(0x04);
- res.extend_from_slice(&[keys.len() as u8]);
+ res.extend_from_slice(&write_varinteger(keys.len() as u64));
for key in keys {
res.extend_from_slice(&key.compress().to_bytes());
}
@@ -112,7 +118,7 @@ mod tests {
]);
let serialized = extra.serialize();
- let mut expected = vec![0x00, 0x00, 0x00];
+ let mut expected = vec![0x00, 0x00];
expected.push(0x01);
expected.extend_from_slice(&public_key.compress().to_bytes());
expected.extend_from_slice(&[0x02, 0x02, 0x10, 0x20]);
### rust/apps/monero/src/key.rs
@@ -13,6 +13,13 @@ pub struct PrivateKey {
pub scalar: Scalar,
}
+impl Drop for PrivateKey {
+ fn drop(&mut self) {
+ use zeroize::Zeroize;
+ self.scalar.zeroize();
+ }
+}
+
impl PrivateKey {
pub fn new(scalar: Scalar) -> PrivateKey {
PrivateKey { scalar }
@@ -24,6 +31,14 @@ impl PrivateKey {
}
}
+ pub fn try_from_slice(bytes: &[u8]) -> Result<PrivateKey> {
+ let bytes: [u8; PUBKEY_LEH] = bytes.try_into().map_err(|_| MoneroError::FormatError)?;
+ let scalar = Option::<Scalar>::from(Scalar::from_canonical_bytes(bytes))
+ .filter(|s| *s != Scalar::ZERO)
+ .ok_or(MoneroError::InvalidPrivateViewKey)?;
+ Ok(PrivateKey { scalar })
+ }
+
pub fn to_bytes(&self) -> [u8; PUBKEY_LEH] {
self.scalar.to_bytes()
}
@@ -54,10 +69,20 @@ impl PublicKey {
Ok(pub_key)
}
+ pub fn validate_for_address(&self) -> Result<EdwardsPoint> {
+ use curve25519_dalek::traits::IsIdentity;
+ let point = self
+ .point
+ .decompress()
+ .ok_or(MoneroError::PublicKeyFromBytesError)?;
+ if point.compress() != self.point || point.is_identity() || !point.is_torsion_free() {
+ return Err(MoneroError::PublicKeyFromBytesError);
+ }
+ Ok(point)
+ }
+
pub fn from_str(s: &str) -> Result<PublicKey> {
- let bytes = hex::decode(s)
- .map_err(|e| format!("decode error: {e:?}"))
- .unwrap();
+ let bytes = hex::decode(s).map_err(|_| MoneroError::PublicKeyFromBytesError)?;
PublicKey::from_bytes(&bytes)
}
}
### rust/apps/monero/src/key_images.rs
@@ -91,18 +91,14 @@ impl From<&Vec<u8>> for KeyImages {
}
fn calc_output_key_offset(
- keypair: &KeyPair,
+ private_view: &PrivateKey,
tx_pubkey: &[u8; 32],
internal_output_index: u64,
major: u32,
minor: u32,
-) -> Scalar {
- let recv_derivation = (keypair.view.scalar
- * PublicKey::from_bytes(tx_pubkey)
- .unwrap()
- .point
- .decompress()
- .unwrap())
+) -> Option<Scalar> {
+ let recv_derivation = (private_view.scalar
+ * PublicKey::from_bytes(tx_pubkey).ok()?.point.decompress()?)
.mul_by_cofactor();
let mut output_index_buf = vec![0; length(internal_output_index)];
@@ -113,25 +109,92 @@ fn calc_output_key_offset(
hash_to_scalar(&[&recv_derivation.compress().0, scalar.as_slice()].concat());
if major != 0 || minor != 0 {
- key_offset += Scalar::from_bytes_mod_order(keypair.get_m(major, minor));
+ key_offset += Scalar::from_bytes_mod_order(crate::key::calc_subaddress_m(
+ &private_view.to_bytes(),
+ major,
+ minor,
+ ));
}
- key_offset
+ Some(key_offset)
+}
+
+fn candidate_tx_keys(
+ tx_pubkey: &[u8; 32],
+ additional_tx_keys: &[PublicKey],
+ output_index: u64,
+) -> Vec<[u8; 32]> {
+ let mut keys = Vec::with_capacity(2);
+ keys.push(*tx_pubkey);
+ if let Some(key) = usize::try_from(output_index)
+ .ok()
+ .and_then(|index| additional_tx_keys.get(index))
+ {
+ keys.push(key.as_bytes());
+ }
+ keys
}
-fn calc_key_image_private_key(
+pub(crate) fn validate_input_owner(
+ public_spend: &PublicKey,
+ private_view: &PrivateKey,
+ tx_pubkey: &[u8; 32],
+ output_pubkey: &[u8; 32],
+ additional_tx_keys: &[PublicKey],
+ output_index: u64,
+ major: u32,
+ minors: &[u32],
+) -> Result<()> {
+ let spend = public_spend
+ .point
+ .decompress()
+ .ok_or(MoneroError::FormatError)?;
+ let target = PublicKey::from_bytes(output_pubkey)?
+ .point
+ .decompress()
+ .ok_or(MoneroError::FormatError)?;
+ let defaults = [0];
+ let minors = if minors.is_empty() {
+ &defaults[..]
+ } else {
+ minors
+ };
+ for key in candidate_tx_keys(tx_pubkey, additional_tx_keys, output_index) {
+ for minor in minors {
+ if let Some(offset) =
+ calc_output_key_offset(private_view, &key, output_index, major, *minor)
+ {
+ if spend + EdwardsPoint::mul_base(&offset) == target {
+ return Ok(());
+ }
+ }
+ }
+ }
+ Err(MoneroError::GenerateKeyImageError)
+}
+
+fn verified_key_image_offset(
keypair: &KeyPair,
tx_pubkey: &[u8; 32],
+ pubkey: &[u8; 32],
+ additional_tx_keys: &[PublicKey],
internal_output_index: u64,
major: u32,
minor: u32,
-) -> PrivateKey {
- let key_offsset =
- calc_output_key_offset(keypair, tx_pubkey, internal_output_index, major, minor);
-
- let prv_key = keypair.spend.scalar + key_offsset;
+) -> Option<Scalar> {
+ let target = PublicKey::from_bytes(pubkey).ok()?.point.decompress()?;
+
+ for key in candidate_tx_keys(tx_pubkey, additional_tx_keys, internal_output_index).iter() {
+ if let Some(offset) =
+ calc_output_key_offset(&keypair.view, key, internal_output_index, major, minor)
+ {
+ if EdwardsPoint::mul_base(&(keypair.spend.scalar + offset)) == target {
+ return Some(offset);
+ }
+ }
+ }
- PrivateKey::new(prv_key)
+ None
}
fn generate_key_image<R: RngCore + CryptoRng>(
@@ -143,41 +206,36 @@ fn generate_key_image<R: RngCore + CryptoRng>(
major: u32,
minor: u32,
mut rng: R,
-) -> KeyImageAndSignature {
- let mut additional_tx_pub_key = None;
- if major != 0 || minor != 0 {
- if additional_tx_keys.len() == 1 {
- additional_tx_pub_key = Some(additional_tx_keys[0]);
- } else if !additional_tx_keys.is_empty() {
- if internal_output_index as usize >= additional_tx_keys.len() {
- panic!("Wrong number of additional derivations");
- }
- additional_tx_pub_key = Some(additional_tx_keys[internal_output_index as usize]);
- }
- }
-
- let key_to_use = match additional_tx_pub_key {
- Some(key) => &key.as_bytes(),
- None => tx_pubkey,
- };
-
- let prvkey =
- calc_key_image_private_key(keypair, key_to_use, internal_output_index, major, minor);
-
- let image = generate_key_image_from_priavte_key(&prvkey.clone());
+) -> Result<KeyImageAndSignature> {
+ let offset = verified_key_image_offset(
+ keypair,
+ tx_pubkey,
+ pubkey,
+ &additional_tx_keys,
+ internal_output_index,
+ major,
+ minor,
+ )
+ .ok_or(MoneroError::GenerateKeyImageError)?;
+
+ let prvkey = PrivateKey::new(keypair.spend.scalar + offset);
+ let image = generate_key_image_from_priavte_key(&prvkey);
let signature = generate_ring_signature(
- &image.clone().compress().0,
- &image.clone(),
- vec![PublicKey::from_bytes(pubkey).unwrap()],
+ &image.compress().0,
+ &image,
+ vec![PublicKey::from_bytes(pubkey)?],
&prvkey,
0,
&mut rng,
);
let signature = [signature[0][0].to_bytes(), signature[0][1].to_bytes()].concat();
- KeyImageAndSignature::new(image.compress().0, signature.try_into().unwrap())
+ Ok(KeyImageAndSignature::new(
+ image.compress().0,
+ signature.try_into().map_err(|_| MoneroError::FormatError)?,
+ ))
}
fn generate_key_image_from_offset(
@@ -187,7 +245,7 @@ fn generate_key_image_from_offset(
) -> Option<EdwardsPoint> {
let input_key = private_spend_key.scalar + key_offset;
- if EdwardsPoint::mul_base(&input_key) != output_public_key.point.decompress().unwrap() {
+ if EdwardsPoint::mul_base(&input_key) != output_public_key.point.decompress()? {
return None;
}
@@ -203,33 +261,32 @@ pub fn try_to_generate_image(
major: u32,
optional_minors: Vec<u32>,
) -> Result<(Keyimage, Scalar)> {
- let mut additional_tx_pub_key = None;
- if major != 0 || !optional_minors.is_empty() {
- if additional_tx_keys.len() == 1 {
- additional_tx_pub_key = Some(additional_tx_keys[0]);
- } else if !additional_tx_keys.is_empty() {
- if internal_output_index as usize >= additional_tx_keys.len() {
- return Err(MoneroError::GenerateKeyImageError);
- }
- additional_tx_pub_key = Some(additional_tx_keys[internal_output_index as usize]);
- }
- }
+ let output_public_key = PublicKey::from_bytes(output_pubkey)?;
+
+ let candidate_keys = candidate_tx_keys(tx_pubkey, &additional_tx_keys, internal_output_index);
- let key_to_use = match additional_tx_pub_key {
- Some(key) => &key.as_bytes(),
- None => tx_pubkey,
+ let minors = if optional_minors.is_empty() {
+ vec![0]
+ } else {
+ optional_minors
};
- for minor in optional_minors {
- let offset =
- calc_output_key_offset(keypair, key_to_use, internal_output_index, major, minor);
- if let Some(image) = generate_key_image_from_offset(
- &keypair.spend,
- &offset,
- &PublicKey::from_bytes(output_pubkey).unwrap(),
- ) {
- return Ok((Keyimage::new(image.compress().to_bytes()), offset));
- };
+ for key_to_use in candidate_keys.iter() {
+ for minor in minors.iter() {
+ if let Some(offset) = calc_output_key_offset(
+ &keypair.view,
+ key_to_use,
+ internal_output_index,
+ major,
+ *minor,
+ ) {
+ if let Some(image) =
+ generate_key_image_from_offset(&keypair.spend, &offset, &output_public_key)
+ {
+ return Ok((Keyimage::new(image.compress().to_bytes()), offset));
+ }
+ }
+ }
}
Err(MoneroError::GenerateKeyImageError)
@@ -239,8 +296,8 @@ impl ExportedTransferDetail {
pub fn key_image<R: RngCore + CryptoRng>(
&self,
keypair: &KeyPair,
- mut rng: R,
- ) -> KeyImageAndSignature {
+ rng: R,
+ ) -> Result<KeyImageAndSignature> {
generate_key_image(
keypair,
&self.tx_pubkey,
@@ -253,35 +310,27 @@ impl ExportedTransferDetail {
)
}
- pub fn generate_key_image_without_signature(&self, keypair: &KeyPair) -> (PublicKey, Keyimage) {
- let mut additional_tx_pub_key = None;
- let additional_tx_keys = self.additional_tx_keys.clone();
- if additional_tx_keys.len() == 1 {
- additional_tx_pub_key = Some(additional_tx_keys[0]);
- } else if !additional_tx_keys.is_empty() {
- if self.internal_output_index as usize >= additional_tx_keys.len() {
- panic!("Wrong number of additional derivations");
- }
- additional_tx_pub_key = Some(additional_tx_keys[self.internal_output_index as usize]);
- }
-
- let key_to_use = match additional_tx_pub_key {
- Some(key) => &key.as_bytes(),
- None => &self.tx_pubkey,
- };
-
- let prvkey = calc_key_image_private_key(
+ pub fn generate_key_image_without_signature(
+ &self,
+ keypair: &KeyPair,
+ ) -> Result<(PublicKey, Keyimage)> {
+ let offset = verified_key_image_offset(
keypair,
- key_to_use,
+ &self.tx_pubkey,
+ &self.pubkey,
+ &self.additional_tx_keys,
self.internal_output_index,
self.major,
self.minor,
- );
+ )
+ .ok_or(MoneroError::GenerateKeyImageError)?;
- (
+ let prvkey = PrivateKey::new(keypair.spend.scalar + offset);
+
+ Ok((
prvkey.get_public_key(),
Keyimage::new(generate_key_image_from_priavte_key(&prvkey).compress().0),
- )
+ ))
}
}
@@ -290,26 +339,29 @@ pub fn generate_export_ur_data<R: RngCore + CryptoRng>(
request_data: Vec<u8>,
mut rng: R,
) -> Result<Vec<u8>> {
+ if request_data.len() > crate::utils::io::MAX_REQUEST_BYTES {
+ return Err(MoneroError::FormatError);
+ }
let decrypted_data = decrypt_data_with_pvk(
keypair.view.to_bytes().try_into().unwrap(),
request_data.clone(),
OUTPUT_EXPORT_MAGIC,
)?;
- if decrypted_data.pk1 != Some(keypair.get_public_spend()) {
- panic!("Public spend key does not match");
- }
- if decrypted_data.pk2 != Some(keypair.get_public_view()) {
- panic!("Public view key does not match");
+ if decrypted_data.pk1 != Some(keypair.get_public_spend())
+ || decrypted_data.pk2 != Some(keypair.get_public_view())
+ {
+ return Err(MoneroError::MismatchedMfp);
}
let outputs = ExportedTransferDetails::from_bytes(&decrypted_data.data)?;
+ outputs.validate_curve_points()?;
let mut key_images: KeyImages = KeyImages(vec![]);
for output in outputs.details.iter() {
key_images
.0
- .push(output.key_image(&keypair.clone(), &mut rng));
+ .push(output.key_image(&keypair.clone(), &mut rng)?);
}
Ok(encrypt_data_with_pvk(
@@ -463,7 +515,8 @@ mod tests {
0,
0,
rng,
- );
+ )
+ .unwrap();
assert_eq!(
hex::encode(ki.image.0),
### rust/apps/monero/src/outputs.rs
@@ -1,6 +1,6 @@
-use crate::errors::Result;
+use crate::errors::{MoneroError, Result};
use crate::key::PublicKey;
-use crate::utils::{constants::OUTPUT_EXPORT_MAGIC, constants::PUBKEY_LEH, io::*};
+use crate::utils::{constants::OUTPUT_EXPORT_MAGIC, constants::PUBKEY_LEH};
use crate::utils::{decrypt_data_with_decrypt_key, fmt_monero_amount};
use alloc::string::String;
use alloc::vec::Vec;
@@ -49,44 +49,49 @@ pub struct ExportedTransferDetails {
impl ExportedTransferDetails {
pub fn from_bytes(bytes: &[u8]) -> Result<ExportedTransferDetails> {
- let mut offset = 0;
- let has_transfers = read_varinteger(bytes, &mut offset);
- if has_transfers == 0 {
+ if bytes.len() > crate::utils::io::MAX_REQUEST_BYTES {
+ return Err(MoneroError::FormatError);
+ }
+ use crate::utils::io::{Reader, MAX_ADDITIONAL_KEYS, MAX_DESTINATIONS};
+
+ let mut reader = Reader::new(bytes);
+ let tuple_fields = reader.read_varint()?;
+ if tuple_fields != 0 && tuple_fields != 3 {
+ return Err(MoneroError::FormatError);
+ }
+ if tuple_fields == 0 {
+ if reader.remaining() != 0 {
+ return Err(MoneroError::FormatError);
+ }
return Ok(ExportedTransferDetails {
offset: 0,
size: 0,
details: Vec::new(),
});
}
- // offset
- read_varinteger(bytes, &mut offset);
- // transfers.size()
- let value_offset = read_varinteger(bytes, &mut offset);
- // details size
- let value_size = read_varinteger(bytes, &mut offset);
- // for size
- let mut details = Vec::new();
+
+ let _offset = reader.read_varint()?;
+ let value_offset = reader.read_varint()?;
+ let value_size = reader.read_count(MAX_DESTINATIONS)?;
+
+ let mut details = Vec::with_capacity(value_size.min(32));
for _ in 0..value_size {
- // version ignore
- read_varinteger(bytes, &mut offset);
- let pubkey = PublicKey::from_bytes(&bytes[offset..offset + PUBKEY_LEH]).unwrap();
- offset += PUBKEY_LEH;
- let internal_output_index = read_varinteger(bytes, &mut offset);
- let global_output_index = read_varinteger(bytes, &mut offset);
- let tx_pubkey = PublicKey::from_bytes(&bytes[offset..offset + PUBKEY_LEH]).unwrap();
- let flags = bytes[offset + PUBKEY_LEH];
- offset += PUBKEY_LEH + 1;
- let amount = read_varinteger(bytes, &mut offset);
- // FIXME: additional_tx_keys
- let keys_num = read_varinteger(bytes, &mut offset);
- let mut additional_tx_keys = Vec::new();
+ let _version = reader.read_varint()?;
+ let pubkey = PublicKey::from_bytes(reader.read_bytes(PUBKEY_LEH)?)?;
+ let internal_output_index = reader.read_varint()?;
+ let global_output_index = reader.read_varint()?;
+ let tx_pubkey = PublicKey::from_bytes(reader.read_bytes(PUBKEY_LEH)?)?;
+ let flags = reader.read_u8()?;
+ let amount = reader.read_varint()?;
+
+ let keys_num = reader.read_count(MAX_ADDITIONAL_KEYS)?;
+ let mut additional_tx_keys = Vec::with_capacity(keys_num.min(32));
for _ in 0..keys_num {
- let key = PublicKey::from_bytes(&bytes[offset..offset + PUBKEY_LEH]).unwrap();
- additional_tx_keys.push(key);
- offset += PUBKEY_LEH;
+ additional_tx_keys.push(PublicKey::from_bytes(reader.read_bytes(PUBKEY_LEH)?)?);
}
- let major = read_varinteger(bytes, &mut offset);
- let minor = read_varinteger(bytes, &mut offset);
+
+ let major = reader.read_varint()?;
+ let minor = reader.read_varint()?;
details.push(ExportedTransferDetail {
pubkey: pubkey.as_bytes(),
@@ -96,17 +101,40 @@ impl ExportedTransferDetails {
flags,
amount,
additional_tx_keys,
- major: major as u32,
- minor: minor as u32,
+ major: u32::try_from(major).map_err(|_| MoneroError::FormatError)?,
+ minor: u32::try_from(minor).map_err(|_| MoneroError::FormatError)?,
});
}
+ if reader.remaining() != 0 {
+ return Err(MoneroError::FormatError);
+ }
Ok(ExportedTransferDetails {
offset: value_offset,
- size: value_size,
+ size: value_size as u64,
details,
})
}
+
+ pub fn validate_curve_points(&self) -> Result<()> {
+ fn check(bytes: &[u8; PUBKEY_LEH]) -> Result<()> {
+ PublicKey::from_bytes(bytes)?
+ .point
+ .decompress()
+ .ok_or(MoneroError::FormatError)
+ .map(|_| ())
+ }
+
+ for detail in self.details.iter() {
+ check(&detail.pubkey)?;
+ check(&detail.tx_pubkey)?;
+ for key in detail.additional_tx_keys.iter() {
+ check(&key.as_bytes())?;
+ }
+ }
+
+ Ok(())
+ }
}
#[derive(Debug, Clone)]
@@ -120,11 +148,20 @@ pub fn parse_display_info(
decrypt_key: [u8; 32],
pvk: [u8; 32],
) -> Result<DisplayMoneroOutput> {
+ if data.len() > crate::utils::io::MAX_REQUEST_BYTES {
+ return Err(MoneroError::FormatError);
+ }
let decrypted_data =
decrypt_data_with_decrypt_key(decrypt_key, pvk, data.to_vec(), OUTPUT_EXPORT_MAGIC)?;
let outputs = ExportedTransferDetails::from_bytes(&decrypted_data.data)?;
+ outputs.validate_curve_points()?;
- let total_amount = outputs.details.iter().fold(0, |acc, x| acc + x.amount);
+ let mut total_amount = 0u64;
+ for detail in outputs.details.iter() {
+ total_amount = total_amount
+ .checked_add(detail.amount)
+ .ok_or(MoneroError::FormatError)?;
+ }
Ok(DisplayMoneroOutput {
txos_num: outputs.size,
### rust/apps/monero/src/signed_transaction.rs
@@ -3,7 +3,6 @@ use crate::key_images::Keyimage;
use crate::transfer::{TxConstructionData, TxDestinationEntry};
use crate::utils::io::*;
use alloc::{string::String, vec, vec::Vec};
-use curve25519_dalek::Scalar;
use monero_serai::transaction::{NotPruned, Transaction};
#[derive(Debug, Clone)]
@@ -83,6 +82,14 @@ impl SignedTxSet {
}
}
+pub(crate) fn write_selected_transfers(transfers: &[usize]) -> Vec<u8> {
+ let mut res = write_varinteger(transfers.len() as u64);
+ for transfer in transfers {
+ res.extend_from_slice(&write_varinteger(*transfer as u64));
+ }
+ res
+}
+
impl SignedTxSet {
pub fn serialize(&self) -> Vec<u8> {
let signed_tx_set = self;
@@ -99,22 +106,17 @@ impl SignedTxSet {
res.extend_from_slice(&ptx.fee.to_le_bytes());
res.push(ptx.dust_added_to_fee as u8);
res.extend_from_slice(&write_tx_destination_entry(&ptx.change_dts));
- res.extend_from_slice(write_varinteger(ptx.selected_transfers.len() as u64).as_slice());
- for transfer in ptx.selected_transfers {
- res.push(transfer as u8);
- }
+ res.extend_from_slice(&write_selected_transfers(&ptx.selected_transfers));
let key_images_bytes = ptx.key_images.as_bytes();
res.extend_from_slice(write_varinteger(key_images_bytes.len() as u64).as_slice());
if !key_images_bytes.is_empty() {
// res.push(0x01);
res.extend_from_slice(key_images_bytes);
}
- // tx_key ZERO
- res.extend_from_slice(&Scalar::ONE.to_bytes());
- res.extend_from_slice(write_varinteger(ptx.additional_tx_keys.len() as u64).as_slice());
- for key in ptx.additional_tx_keys {
- res.extend_from_slice(&key.to_bytes());
- }
+ let mut placeholder = [0u8; 32];
+ placeholder[0] = 1;
+ res.extend_from_slice(&placeholder);
+ res.extend_from_slice(&write_varinteger(0));
res.extend_from_slice(write_varinteger(ptx.dests.len() as u64).as_slice());
for dest in ptx.dests {
res.extend_from_slice(&write_tx_destination_entry(&dest));
### rust/apps/monero/src/transfer.rs
@@ -8,10 +8,12 @@ use crate::structs::*;
use crate::utils::*;
use crate::utils::{constants::*, hash::*, io::*};
use alloc::borrow::ToOwned;
+use alloc::format;
use alloc::string::{String, ToString};
use alloc::vec;
use alloc::vec::Vec;
use core::fmt::Display;
+use curve25519_dalek::edwards::CompressedEdwardsY;
use curve25519_dalek::scalar::Scalar;
use curve25519_dalek::EdwardsPoint;
use monero_serai::primitives::Commitment;
@@ -23,9 +25,21 @@ use monero_serai::transaction::{Input, Output, Timelock, Transaction, Transactio
use rand_core::OsRng;
use zeroize::Zeroizing;
+const MAX_DISPLAY_INPUTS: usize = 16;
+const MAX_DISPLAY_OUTPUTS: usize = 16;
+
+#[derive(Debug, Clone)]
+pub struct DisplayOutput {
+ pub address: String,
+ pub amount: String,
+ pub is_change: bool,
+ pub is_integrated: bool,
+ pub payment_id: String,
+}
+
#[derive(Debug, Clone)]
pub struct DisplayTransactionInfo {
- pub outputs: Vec<(Address, String, bool)>,
+ pub outputs: Vec<DisplayOutput>,
pub inputs: Vec<(PublicKey, String)>,
pub input_amount: String,
pub output_amount: String,
@@ -39,8 +53,23 @@ impl Display for DisplayTransactionInfo {
writeln!(f, " {:?} - {}", hex::encode(public_key.as_bytes()), amount)?;
}
writeln!(f, "Outputs:")?;
- for (address, amount, _) in self.outputs.iter() {
- writeln!(f, " {:?} - {}", address.to_string(), amount)?;
+ for output in self.outputs.iter() {
+ writeln!(
+ f,
+ " {:?} - {}{}{}",
+ output.address,
+ output.amount,
+ if output.is_integrated {
+ " (integrated)"
+ } else {
+ ""
+ },
+ if output.payment_id.is_empty() {
+ String::new()
+ } else {
+ format!(" [payment id {}]", output.payment_id)
+ }
+ )?;
}
writeln!(f, "Input amount: {}", self.input_amount)?;
writeln!(f, "Output amount: {}", self.output_amount)?;
@@ -240,16 +269,28 @@ impl InnerOutputs {
}
impl TxConstructionData {
- pub fn outputs_amount(&self) -> u64 {
- self.sources.iter().map(|source| source.amount).sum()
+ pub fn sum_source_amounts(&self) -> Result<u64> {
+ self.sources
+ .iter()
+ .map(|source| source.amount)
+ .try_fold(0u64, |acc, amount| {
+ acc.checked_add(amount).ok_or(MoneroError::FormatError)
+ })
}
- pub fn inputs_amount(&self) -> u64 {
- self.splitted_dsts.iter().map(|dest| dest.amount).sum()
+ pub fn sum_destination_amounts(&self) -> Result<u64> {
+ self.splitted_dsts
+ .iter()
+ .map(|dest| dest.amount)
+ .try_fold(0u64, |acc, amount| {
+ acc.checked_add(amount).ok_or(MoneroError::FormatError)
+ })
}
- pub fn fee(&self) -> u64 {
- self.outputs_amount() - self.inputs_amount()
+ pub fn fee(&self) -> Result<u64> {
+ self.sum_source_amounts()?
+ .checked_sub(self.sum_destination_amounts()?)
+ .ok_or(MoneroError::FormatError)
}
fn absolute_output_offsets_to_relative(&self, off: Vec<u64>) -> Vec<u64> {
@@ -319,54 +360,62 @@ impl TxConstructionData {
tx_key: &PrivateKey,
additional_keys: &Vec<PrivateKey>,
tx_key_pub: &EdwardsPoint,
- ) -> InnerOutputs {
+ ) -> Result<InnerOutputs> {
let shared_key_derivations =
self.shared_key_derivations(keypair, tx_key, additional_keys, tx_key_pub);
+
+ let use_view_tags = match self.rct_config.bp_version {
+ RctType::RCTTypeFull => false,
+ RctType::RCTTypeNull | RctType::RCTTypeBulletproof2 => true,
+ _ => return Err(MoneroError::FormatError),
+ };
+
let mut res = InnerOutputs::new();
for (dest, shared_key_derivation) in self.splitted_dsts.iter().zip(shared_key_derivations) {
let image = generate_key_image_from_priavte_key(&PrivateKey::new(
shared_key_derivation.shared_key,
));
- let key = PublicKey::from_bytes(&dest.addr.spend_public_key)
- .unwrap()
+ let key = PublicKey::from_bytes(&dest.addr.spend_public_key)?
.point
.decompress()
- .unwrap()
+ .ok_or(MoneroError::FormatError)?
+ EdwardsPoint::mul_base(&shared_key_derivation.shared_key);
res.push(InnerOutput {
output: Output {
key: key.compress(),
amount: None,
- view_tag: (match self.rct_config.bp_version {
- RctType::RCTTypeFull => false,
- RctType::RCTTypeNull | RctType::RCTTypeBulletproof2 => true,
- _ => panic!("unsupported RctType"),
- })
- .then_some(shared_key_derivation.view_tag),
+ view_tag: use_view_tags.then_some(shared_key_derivation.view_tag),
},
key_image: Keyimage::new(image.compress().to_bytes()),
})
}
- res
+ Ok(res)
}
fn calc_key_image_by_index(
&self,
keypair: &KeyPair,
sources_index: usize,
) -> Result<(Keyimage, Scalar)> {
- let source = self.sources[sources_index].clone();
- let output_entry = source.outputs[source.real_output as usize];
+ let source = self
+ .sources
+ .get(sources_index)
+ .ok_or(MoneroError::FormatError)?
+ .clone();
+ let output_entry = source
+ .outputs
+ .get(source.real_output as usize)
+ .ok_or(MoneroError::FormatError)?;
let ctkey = output_entry.key;
let additional_tx_keys: Vec<PublicKey> = source
.real_out_additional_tx_keys
.iter()
- .map(|key_bytes| PublicKey::from_bytes(key_bytes).unwrap())
- .collect();
+ .map(|key_bytes| PublicKey::from_bytes(key_bytes))
+ .collect::<Result<Vec<PublicKey>>>()?;
match try_to_generate_image(
keypair,
@@ -407,80 +456,538 @@ pub struct UnsignedTx {
transfers: ExportedTransferDetails,
}
+fn own_change_addresses(
+ public_spend: &PublicKey,
+ private_view: &PrivateKey,
+ subaddr_account: u32,
+ subaddr_indices: &[u32],
+) -> Vec<([u8; 32], [u8; 32], bool)> {
+ let mut res = vec![];
+
+ let spend_point = match public_spend.point.decompress() {
+ Some(point) => point,
+ None => return res,
+ };
+ res.push((
+ public_spend.as_bytes(),
+ private_view.get_public_key().as_bytes(),
+ false,
+ ));
+
+ let mut minors = subaddr_indices.to_vec();
+ if !minors.contains(&0) {
+ minors.push(0);
+ }
+ for minor in minors {
+ if subaddr_account == 0 && minor == 0 {
+ continue;
+ }
+ let m = Scalar::from_bytes_mod_order(calc_subaddress_m(
+ &private_view.to_bytes(),
+ subaddr_account,
+ minor,
+ ));
+ let sub_spend = spend_point + EdwardsPoint::mul_base(&m);
+ let sub_view = sub_spend * private_view.scalar;
+ res.push((
+ sub_spend.compress().to_bytes(),
+ sub_view.compress().to_bytes(),
+ true,
+ ));
+ }
+
+ res
+}
+
+fn is_own_change(
+ change: &TxDestinationEntry,
+ own_addresses: &[([u8; 32], [u8; 32], bool)],
+) -> bool {
+ own_addresses.iter().any(|(spend, view, is_subaddress)| {
+ *is_subaddress == change.is_subaddress
+ && *spend == change.addr.spend_public_key
+ && *view == change.addr.view_public_key
+ })
+}
+
+pub fn is_own_change_address(
+ public_spend: &PublicKey,
+ private_view: &PrivateKey,
+ subaddr_account: u32,
+ subaddr_indices: &[u32],
+ change: &TxDestinationEntry,
+) -> bool {
+ is_own_change(
+ change,
+ &own_change_addresses(public_spend, private_view, subaddr_account, subaddr_indices),
+ )
+}
+
+fn integrated_destination(dest: &TxDestinationEntry) -> Option<(PublicKey, PublicKey, [u8; 8])> {
+ if !dest.is_integrated {
+ return None;
+ }
+
+ let (spend, view, payment_id) = parse_integrated_address(&dest.original)?;
+ if spend != dest.addr.spend_public_key || view != dest.addr.view_public_key {
+ return None;
+ }
+
+ Some((
+ PublicKey::from_bytes(&spend).ok()?,
+ PublicKey::from_bytes(&view).ok()?,
+ payment_id,
+ ))
+}
+
+pub fn validate_payment_id_binding(txes: &[TxConstructionData]) -> Result<()> {
+ for tx in txes.iter() {
+ let requested = tx.requested_extra()?;
+
+ let signed = match requested.nonce.as_deref() {
+ None => [0u8; 8],
+ Some(nonce) if nonce.first() == Some(&1) && nonce.len() == 9 => {
+ let mut payment_id = [0u8; 8];
+ payment_id.copy_from_slice(&nonce[1..9]);
+ payment_id
+ }
+ Some(_) => return Err(MoneroError::FormatError),
+ };
+
+ if requested.nonce.is_some() && tx.payment_id_destination_index().is_none() {
+ return Err(MoneroError::FormatError);
+ }
+
+ let change_addr = tx.change_dts.addr;
+ let mut displayed: Option<(AccountPublicAddress, [u8; 8])> = None;
+ let mut unique_payments: Vec<AccountPublicAddress> = vec![];
+
+ for entry in tx.splitted_dsts.iter() {
+ if entry.amount > 0
+ && entry.addr != change_addr
+ && !unique_payments.contains(&entry.addr)
+ {
+ unique_payments.push(entry.addr);
+ }
+
+ if !entry.is_integrated {
+ continue;
+ }
+
+ if entry.amount == 0 || entry.addr == change_addr {
+ return Err(MoneroError::FormatError);
+ }
+ let (_, _, payment_id) =
+ parse_integrated_address(&entry.original).ok_or(MoneroError::FormatError)?;
+ let identity = (entry.addr, payment_id);
+ match displayed {
+ Some(existing) if existing != identity => return Err(MoneroError::FormatError),
+ _ => displayed = Some(identity),
+ }
+ }
+
+ match displayed {
+ Some((displayed_address, displayed_payment_id)) => {
+ if signed != displayed_payment_id
+ || unique_payments.as_slice() != [displayed_address]
+ {
+ return Err(MoneroError::FormatError);
+ }
+ }
+ None => {
+ if signed != [0u8; 8] {
+ return Err(MoneroError::FormatError);
+ }
+ }
+ }
+ }
+
+ Ok(())
+}
+
+fn parse_integrated_address(original: &str) -> Option<([u8; 32], [u8; 32], [u8; 8])> {
+ let decoded = base58_monero::decode(original).ok()?;
+ if decoded.len() != 77 || decoded[0] != 0x13 {
+ return None;
+ }
+ if keccak256(&decoded[..73])[..4] != decoded[73..77] {
+ return None;
+ }
+ let spend: [u8; 32] = decoded[1..33].try_into().ok()?;
+ let view: [u8; 32] = decoded[33..65].try_into().ok()?;
+ let payment_id: [u8; 8] = decoded[65..73].try_into().ok()?;
+ Some((spend, view, payment_id))
+}
+
+pub fn validate_destinations(txes: &[TxConstructionData]) -> Result<()> {
+ for tx in txes.iter() {
+ let mut entries: Vec<&TxDestinationEntry> = vec![];
+ entries.extend(tx.dests.iter());
+ entries.extend(tx.splitted_dsts.iter());
+ entries.push(&tx.change_dts);
+
+ let mut address_types: Vec<(AccountPublicAddress, bool)> = vec![];
+ for entry in entries {
+ if let Some((_, is_subaddress)) =
+ address_types.iter().find(|(addr, _)| *addr == entry.addr)
+ {
+ if *is_subaddress != entry.is_subaddress {
+ return Err(MoneroError::FormatError);
+ }
+ } else {
+ address_types.push((entry.addr, entry.is_subaddress));
+ }
+ if entry.is_subaddress && entry.is_integrated {
+ return Err(MoneroError::FormatError);
+ }
+
+ if entry.original.is_empty() {
+ continue;
+ }
+
+ let ok = match Address::from_str(&entry.original) {
+ Ok(address) => {
+ let expected = if entry.is_subaddress {
+ AddressType::Subaddress
+ } else {
+ AddressType::Standard
+ };
+ address.network == Network::Mainnet
+ && address.addr_type == expected
+ && address.public_spend.as_bytes() == entry.addr.spend_public_key
+ && address.public_view.as_bytes() == entry.addr.view_public_key
+ }
+ Err(_) => match parse_integrated_address(&entry.original) {
+ Some((spend, view, _payment_id)) => {
+ entry.is_integrated
+ && spend == entry.addr.spend_public_key
+ && view == entry.addr.view_public_key
+ }
+ None => false,
+ },
+ };
+
+ if !ok {
+ return Err(MoneroError::FormatError);
+ }
+ }
+ }
+
+ Ok(())
+}
+
+pub fn validate_curve_points(txes: &[TxConstructionData]) -> Result<()> {
+ fn check(bytes: &[u8; 32]) -> Result<()> {
+ CompressedEdwardsY::from_slice(bytes)
+ .map_err(|_| MoneroError::FormatError)?
+ .decompress()
+ .ok_or(MoneroError::FormatError)
+ .map(|_| ())
+ }
+
+ for tx in txes.iter() {
+ for source in tx.sources.iter() {
+ check(&source.real_out_tx_key)?;
+ for key in source.real_out_additional_tx_keys.iter() {
+ check(key)?;
+ }
+ for output in source.outputs.iter() {
+ check(&output.key.dest)?;
+ check(&output.key.mask)?;
+ }
+ }
+
+ for entry in tx
+ .dests
+ .iter()
+ .chain(tx.splitted_dsts.iter())
+ .chain(core::iter::once(&tx.change_dts))
+ {
+ check(&entry.addr.spend_public_key)?;
+ check(&entry.addr.view_public_key)?;
+ }
+ }
+
+ Ok(())
+}
+
impl UnsignedTx {
- pub fn display_info(&self) -> DisplayTransactionInfo {
+ pub fn validate_destinations(&self) -> Result<()> {
+ validate_destinations(&self.txes)
+ }
+
+ pub fn validate_payment_id_binding(&self) -> Result<()> {
+ validate_payment_id_binding(&self.txes)
+ }
+
+ pub fn validate_curve_points(&self) -> Result<()> {
+ validate_curve_points(&self.txes)
+ }
+
+ pub fn validate_all(&self) -> Result<()> {
+ self.validate_destinations()?;
+ self.validate_payment_id_binding()?;
+ self.validate_curve_points()
+ }
+
+ pub fn validate_for_wallet(
+ &self,
+ public_spend: &PublicKey,
+ private_view: &PrivateKey,
+ ) -> Result<()> {
+ self.validate_all()?;
+ if self.txes.is_empty() {
+ return Err(MoneroError::FormatError);
+ }
+ let mut candidate_work = 0usize;
+ let mut input_count = 0usize;
+ let mut output_count = 0usize;
+ let mut totals = (0u64, 0u64, 0u64);
+ for tx in &self.txes {
+ input_count = input_count
+ .checked_add(tx.sources.len())
+ .ok_or(MoneroError::RequestTooComplex)?;
+ output_count = output_count
+ .checked_add(tx.splitted_dsts.len())
+ .ok_or(MoneroError::RequestTooComplex)?;
+ if input_count > MAX_DISPLAY_INPUTS || output_count > MAX_DISPLAY_OUTPUTS {
+ return Err(MoneroError::RequestTooComplex);
+ }
+ if tx.sources.is_empty()
+ || tx.splitted_dsts.is_empty()
+ || tx.splitted_dsts.len() > 16
+ || !matches!(
+ tx.rct_config.bp_version,
+ RctType::RCTTypeFull | RctType::RCTTypeNull | RctType::RCTTypeBulletproof2
+ )
+ {
+ return Err(MoneroError::FormatError);
+ }
+ candidate_work = candidate_work
+ .checked_add(
+ tx.sources
+ .len()
+ .checked_mul(tx.subaddr_indices.len().max(1))
+ .and_then(|n| n.checked_mul(2))
+ .ok_or(MoneroError::FormatError)?,
+ )
+ .ok_or(MoneroError::FormatError)?;
+ if candidate_work > 1024 {
+ return Err(MoneroError::FormatError);
+ }
+ totals.0 = totals
+ .0
+ .checked_add(tx.sum_source_amounts()?)
+ .ok_or(MoneroError::FormatError)?;
+ totals.1 = totals
+ .1
+ .checked_add(tx.sum_destination_amounts()?)
+ .ok_or(MoneroError::FormatError)?;
+ totals.2 = totals
+ .2
+ .checked_add(tx.fee()?)
+ .ok_or(MoneroError::FormatError)?;
+ if tx.has_change_output()
+ && !is_own_change_address(
+ public_spend,
+ private_view,
+ tx.subaddr_account,
+ &tx.subaddr_indices,
+ &tx.change_dts,
+ )
+ {
+ return Err(MoneroError::ChangeAddressMismatch);
+ }
+ for source in &tx.sources {
+ let real = source
+ .outputs
+ .get(
+ usize::try_from(source.real_output)
+ .map_err(|_| MoneroError::FormatError)?,
+ )
+ .ok_or(MoneroError::FormatError)?;
+ crate::key_images::validate_input_owner(
+ public_spend,
+ private_view,
+ &source.real_out_tx_key,
+ &real.key.dest,
+ &source
+ .real_out_additional_tx_keys
+ .iter()
+ .map(|key| PublicKey::from_bytes(key))
+ .collect::<Result<Vec<_>>>()?,
+ source.real_output_in_tx_index,
+ tx.subaddr_account,
+ &tx.subaddr_indices,
+ )?;
+ let commitment = Commitment {
+ mask: Scalar::from_bytes_mod_order(source.mask),
+ amount: source.amount,
+ };
+ if commitment.calculate().compress().to_bytes() != real.key.mask {
+ return Err(MoneroError::FormatError);
+ }
+ }
+ }
+ for transfer in &self.transfers.details {
+ crate::key_images::validate_input_owner(
+ public_spend,
+ private_view,
+ &transfer.tx_pubkey,
+ &transfer.pubkey,
+ &transfer.additional_tx_keys,
+ transfer.internal_output_index,
+ transfer.major,
+ &[transfer.minor],
+ )?;
+ }
+ Ok(())
+ }
+
+ pub fn display_info(
+ &self,
+ public_spend: &PublicKey,
+ private_view: &PrivateKey,
+ ) -> Result<DisplayTransactionInfo> {
let mut inputs = vec![];
let mut outputs = vec![];
for tx in self.txes.iter() {
+ let own_change = own_change_addresses(
+ public_spend,
+ private_view,
+ tx.subaddr_account,
+ &tx.subaddr_indices,
+ );
+ let change_is_ours = is_own_change(&tx.change_dts, &own_change);
+
for source in tx.sources.iter() {
- let output = source.outputs[source.real_output as usize];
+ let output = source
+ .outputs
+ .get(source.real_output as usize)
+ .ok_or(MoneroError::FormatError)?;
let amount = source.amount;
inputs.push((
- PublicKey::from_bytes(&output.key.dest).unwrap(),
+ PublicKey::from_bytes(&output.key.dest)?,
fmt_monero_amount(amount),
));
}
for dest in tx.splitted_dsts.iter() {
- let address = dest.addr.to_address(Network::Mainnet, dest.is_subaddress);
+ let integrated = integrated_destination(dest);
+ let (address, payment_id_hex) = match integrated {
+ Some((ref spend, ref view, ref payment_id)) => (
+ integrated_address_string(spend, view, payment_id)?,
+ hex::encode(payment_id),
+ ),
+ None => (
+ dest.addr
+ .to_address(Network::Mainnet, dest.is_subaddress)
+ .to_string(),
+ String::new(),
+ ),
+ };
let amount = dest.amount;
- let is_change = address
- == tx
- .change_dts
- .addr
- .to_address(Network::Mainnet, tx.change_dts.is_subaddress);
- outputs.push((address, fmt_monero_amount(amount), is_change));
+ let is_change = change_is_ours && dest.addr == tx.change_dts.addr;
+ outputs.push(DisplayOutput {
+ address,
+ amount: fmt_monero_amount(amount),
+ is_change,
+ is_integrated: integrated.is_some(),
+ payment_id: payment_id_hex,
+ });
}
}
- DisplayTransactionInfo {
+ let mut output_amount = 0u64;
+ let mut input_amount = 0u64;
+ let mut fee = 0u64;
+ for tx in self.txes.iter() {
+ output_amount = output_amount
+ .checked_add(tx.sum_destination_amounts()?)
+ .ok_or(MoneroError::FormatError)?;
+ input_amount = input_amount
+ .checked_add(tx.sum_source_amounts()?)
+ .ok_or(MoneroError::FormatError)?;
+ fee = fee.checked_add(tx.fee()?).ok_or(MoneroError::FormatError)?;
+ }
+
+ Ok(DisplayTransactionInfo {
inputs,
outputs,
- input_amount: fmt_monero_amount(self.txes.iter().map(|tx| tx.inputs_amount()).sum()),
- output_amount: fmt_monero_amount(self.txes.iter().map(|tx| tx.outputs_amount()).sum()),
- fee: fmt_monero_amount(self.txes.iter().map(|tx| tx.fee()).sum()),
- }
+ input_amount: fmt_monero_amount(input_amount),
+ output_amount: fmt_monero_amount(output_amount),
+ fee: fmt_monero_amount(fee),
+ })
}
- pub fn deserialize(bytes: &[u8]) -> UnsignedTx {
- let mut offset = 0;
- read_varinteger(bytes, &mut offset); // version: should be 0x02
- let txes_len = read_varinteger(bytes, &mut offset);
- let mut txes = vec![];
+ pub fn deserialize(bytes: &[u8]) -> Result<UnsignedTx> {
+ if bytes.len() > crate::utils::io::MAX_REQUEST_BYTES {
+ return Err(MoneroError::FormatError);
+ }
+ use crate::utils::io::{
+ Reader, MAX_ADDITIONAL_KEYS, MAX_DESTINATIONS, MAX_EXTRA_LEN, MAX_RING_SIZE,
+ MAX_SELECTED_TRANSFERS, MAX_SOURCES, MAX_SUBADDR_INDICES, MAX_TXES,
+ };
+
+ let mut reader = Reader::new(bytes);
+ if reader.read_varint()? != 2 {
+ return Err(MoneroError::FormatError);
+ }
+ let txes_len = reader.read_count(MAX_TXES)?;
+ let mut txes = Vec::with_capacity(txes_len.min(4));
+
for _ in 0..txes_len {
- let sources_len = read_varinteger(bytes, &mut offset);
- let mut sources = vec![];
+ let sources_len = reader.read_count(MAX_SOURCES)?;
+ let mut sources = Vec::with_capacity(sources_len.min(32));
for _ in 0..sources_len {
- let outputs_len = read_varinteger(bytes, &mut offset);
- let mut outputs = vec![];
+ let outputs_len = reader.read_count(MAX_RING_SIZE)?;
+ let mut outputs = Vec::with_capacity(outputs_len.min(32));
for _ in 0..outputs_len {
- read_varinteger(bytes, &mut offset); // should be 0x02
- let index = read_varinteger(bytes, &mut offset);
- let dest = read_next_u8_32(bytes, &mut offset);
- let mask = read_next_u8_32(bytes, &mut offset);
+ if reader.read_varint()? != 2 {
+ return Err(MoneroError::FormatError);
+ }
+ let index = reader.read_varint()?;
+ let dest = reader.read_array32()?;
+ let mask = reader.read_array32()?;
outputs.push(OutputEntry {
index,
key: CtKey { dest, mask },
});
}
- let real_output = read_next_u64(bytes, &mut offset);
- let real_out_tx_key = read_next_u8_32(bytes, &mut offset);
- let real_out_additional_tx_keys_len = read_varinteger(bytes, &mut offset);
- let mut real_out_additional_tx_keys = vec![];
- for _ in 0..real_out_additional_tx_keys_len {
- let key = read_next_u8_32(bytes, &mut offset);
- real_out_additional_tx_keys.push(key);
- }
- let real_output_in_tx_index = read_next_u64(bytes, &mut offset);
- let amount = read_next_u64(bytes, &mut offset);
- let rct = read_next_bool(bytes, &mut offset);
- let mask = read_next_u8_32(bytes, &mut offset);
+
+ let real_output = reader.read_u64()?;
+ let real_out_tx_key = reader.read_array32()?;
+ let real_out_additional_tx_keys = reader.read_vec_array32(MAX_ADDITIONAL_KEYS)?;
+ let real_output_in_tx_index = reader.read_u64()?;
+ let amount = reader.read_u64()?;
+ let rct = reader.read_bool()?;
+ let mask = reader.read_array32()?;
#[allow(non_snake_case)]
let multisig_kLRki = Multisig_kLRki {
- k: read_next_u8_32(bytes, &mut offset),
- L: read_next_u8_32(bytes, &mut offset),
- R: read_next_u8_32(bytes, &mut offset),
- ki: read_next_u8_32(bytes, &mut offset),
+ k: reader.read_array32()?,
+ L: reader.read_array32()?,
+ R: reader.read_array32()?,
+ ki: reader.read_array32()?,
+ };
+
+ if real_output as usize >= outputs.len() || real_output > u8::MAX as u64 {
+ return Err(MoneroError::FormatError);
+ }
+
+ let selected_index = outputs[real_output as usize].index;
+ outputs.sort_by_key(|output| output.index);
+ for pair in outputs.windows(2) {
+ if pair[0].index == pair[1].index {
+ return Err(MoneroError::FormatError);
+ }
+ }
+ let real_output = match outputs
+ .iter()
+ .position(|output| output.index == selected_index)
+ {
+ Some(position) => position as u64,
+ None => return Err(MoneroError::FormatError),
};
+
sources.push(TxSourceEntry {
outputs,
real_output,
@@ -493,61 +1000,68 @@ impl UnsignedTx {
multisig_kLRki,
});
}
- let change_dts = read_next_tx_destination_entry(bytes, &mut offset);
- let splitted_dsts_len = read_varinteger(bytes, &mut offset);
- let mut splitted_dsts = vec![];
+
+ let change_dts = reader.read_tx_destination_entry()?;
+ let splitted_dsts_len = reader.read_count(MAX_DESTINATIONS)?;
+ let mut splitted_dsts = Vec::with_capacity(splitted_dsts_len.min(32));
for _ in 0..splitted_dsts_len {
- splitted_dsts.push(read_next_tx_destination_entry(bytes, &mut offset));
+ splitted_dsts.push(reader.read_tx_destination_entry()?);
}
- let selected_transfers_len = read_varinteger(bytes, &mut offset);
- let mut selected_transfers = vec![];
+
+ let selected_transfers_len = reader.read_count(MAX_SELECTED_TRANSFERS)?;
+ let mut selected_transfers = Vec::with_capacity(selected_transfers_len.min(32));
for _ in 0..selected_transfers_len {
- selected_transfers.push(read_varinteger(bytes, &mut offset) as usize);
+ selected_transfers.push(
+ usize::try_from(reader.read_varint()?).map_err(|_| MoneroError::FormatError)?,
+ );
}
- let extra_len = read_varinteger(bytes, &mut offset);
- let extra = read_next_vec_u8(bytes, &mut offset, extra_len as usize);
- let unlock_time = read_next_u64(bytes, &mut offset);
- let use_rct = read_next_u8(bytes, &mut offset);
- // RCTConfig
- let version = read_varinteger(bytes, &mut offset);
- let range_proof_type = read_varinteger(bytes, &mut offset);
- let range_proof_type = match range_proof_type {
+
+ let extra = reader.read_vec_u8(MAX_EXTRA_LEN)?;
+ let unlock_time = reader.read_u64()?;
+ let use_rct = reader.read_u8()?;
+
+ let version = reader.read_varint()?;
+ let range_proof_type = match reader.read_varint()? {
0 => RangeProofType::Null,
1 => RangeProofType::Full,
2 => RangeProofType::Simple,
3 => RangeProofType::Bulletproof,
4 => RangeProofType::Bulletproof2,
5 => RangeProofType::CLSAG,
6 => RangeProofType::BulletproofPlus,
- _ => panic!("Invalid range_proof_type"),
+ _ => return Err(MoneroError::FormatError),
};
- let bp_version = read_varinteger(bytes, &mut offset);
- let bp_version = match bp_version {
+ let bp_version = match reader.read_varint()? {
0 => RctType::RCTTypeNull,
1 => RctType::RCTTypeFull,
2 => RctType::RCTTypeSimple,
3 => RctType::RCTTypeBulletproof,
4 => RctType::RCTTypeBulletproof2,
5 => RctType::RCTTypeCLSAG,
6 => RctType::RCTTypeBulletproofPlus,
- _ => panic!("Invalid bp_version"),
+ _ => return Err(MoneroError::FormatError),
};
let rct_config = RCTConfig {
- version: version as u32,
+ version: u32::try_from(version).map_err(|_| MoneroError::FormatError)?,
range_proof_type,
bp_version,
};
- let dests_len = read_varinteger(bytes, &mut offset);
- let mut dests = vec![];
+
+ let dests_len = reader.read_count(MAX_DESTINATIONS)?;
+ let mut dests = Vec::with_capacity(dests_len.min(32));
for _ in 0..dests_len {
- dests.push(read_next_tx_destination_entry(bytes, &mut offset));
+ dests.push(reader.read_tx_destination_entry()?);
}
- let subaddr_account = read_next_u32(bytes, &mut offset);
- let subaddr_indices_len = read_varinteger(bytes, &mut offset);
- let mut subaddr_indices = vec![];
+
+ let subaddr_account = reader.read_u32()?;
+ let subaddr_indices_len = reader.read_count(MAX_SUBADDR_INDICES)?;
+ let mut subaddr_indices = Vec::with_capacity(subaddr_indices_len.min(32));
for _ in 0..subaddr_indices_len {
- subaddr_indices.push(read_varinteger(bytes, &mut offset) as u32);
+ subaddr_indices.push(
+ u32::try_from(reader.read_varint()?).map_err(|_| MoneroError::FormatError)?,
+ );
}
+
txes.push(TxConstructionData {
sources,
change_dts,
@@ -562,9 +1076,11 @@ impl UnsignedTx {
subaddr_indices,
});
}
- let transfers = ExportedTransferDetails::from_bytes(&bytes[offset..]).unwrap();
- UnsignedTx { txes, transfers }
+ let transfers = ExportedTransferDetails::from_bytes(reader.remaining_bytes())?;
+ transfers.validate_curve_points()?;
+
+ Ok(UnsignedTx { txes, transfers })
}
pub fn construct_tx(
@@ -586,34 +1102,32 @@ impl UnsignedTx {
bp_commitments.push(commitment);
encrypted_amounts.push(encrypted_amount);
}
- let bulletproof = {
- (match tx.rct_config.bp_version {
- RctType::RCTTypeFull => Bulletproof::prove(&mut OsRng, bp_commitments),
- RctType::RCTTypeNull | RctType::RCTTypeBulletproof2 => {
- Bulletproof::prove_plus(&mut OsRng, bp_commitments)
- }
- _ => panic!("unsupported RctType"),
- })
- .expect("couldn't prove BP(+)s for this many payments despite checking in constructor?")
- };
+ let bulletproof = match tx.rct_config.bp_version {
+ RctType::RCTTypeFull => Bulletproof::prove(&mut OsRng, bp_commitments),
+ RctType::RCTTypeNull | RctType::RCTTypeBulletproof2 => {
+ Bulletproof::prove_plus(&mut OsRng, bp_commitments)
+ }
+ _ => return Err(MoneroError::FormatError),
+ }
+ .map_err(|_| MoneroError::FormatError)?;
let tx = Transaction::V2 {
prefix: TransactionPrefix {
additional_timelock: Timelock::None,
inputs: tx.inputs(keypair)?.get_inputs(),
outputs: tx
- .outputs(keypair, tx_key, additional_keys, tx_key_pub)
+ .outputs(keypair, tx_key, additional_keys, tx_key_pub)?
.get_outputs(),
extra: tx.extra(
keypair,
tx_key,
additional_keys,
tx_key_pub,
additional_keys_pub,
- ),
+ )?,
},
proofs: Some(RctProofs {
base: RctBase {
- fee: tx.fee(),
+ fee: tx.fee()?,
encrypted_amounts,
pseudo_outs: vec![],
commitments,
@@ -629,6 +1143,7 @@ impl UnsignedTx {
}
pub fn sign(&self, keypair: &KeyPair) -> Result<SignedTxSet> {
+ self.validate_for_wallet(&keypair.get_public_spend(), &keypair.view)?;
let mut penging_tx = vec![];
let mut tx_key_images = vec![];
for unsigned_tx in self.txes.iter() {
@@ -649,46 +1164,46 @@ impl UnsignedTx {
let inputs = unsigned_tx.inputs(keypair)?;
let mut clsag_signs = Vec::with_capacity(inputs.0.len());
for (i, input) in inputs.0.iter().enumerate() {
- let ring: Vec<[EdwardsPoint; 2]> = input
- .source
- .outputs
- .iter()
- .map(|output| {
- [
- PublicKey::from_bytes(&output.key.dest)
- .unwrap()
- .point
- .decompress()
- .unwrap(),
- PublicKey::from_bytes(&output.key.mask)
- .unwrap()
- .point
- .decompress()
- .unwrap(),
- ]
- })
- .collect();
+ let mut ring: Vec<[EdwardsPoint; 2]> =
+ Vec::with_capacity(input.source.outputs.len());
+ for output in input.source.outputs.iter() {
+ ring.push([
+ PublicKey::from_bytes(&output.key.dest)?
+ .point
+ .decompress()
+ .ok_or(MoneroError::FormatError)?,
+ PublicKey::from_bytes(&output.key.mask)?
+ .point
+ .decompress()
+ .ok_or(MoneroError::FormatError)?,
+ ]);
+ }
+
+ let context = ClsagContext::new(
+ Decoys::new(
+ unsigned_tx.inputs(keypair)?.get_key_offsets(i),
+ input.source.real_output as u8,
+ ring.clone(),
+ )
+ .ok_or(MoneroError::FormatError)?,
+ Commitment {
+ mask: Scalar::from_bytes_mod_order(input.source.mask),
+ amount: input.source.amount,
+ },
+ )
+ .map_err(|_| MoneroError::FormatError)?;
+
clsag_signs.push((
Zeroizing::new(keypair.spend.scalar + input.key_offset),
- ClsagContext::new(
- Decoys::new(
- unsigned_tx.inputs(keypair)?.get_key_offsets(i),
- input.source.real_output as u8,
- ring.clone(),
- )
- .unwrap(),
- Commitment {
- mask: Scalar::from_bytes_mod_order(input.source.mask),
- amount: input.source.amount,
- },
- )
- .unwrap(),
+ context,
));
}
- let msg = tx.signature_hash().unwrap();
- let clsags_and_pseudo_outs =
- Clsag::sign(&mut OsRng, clsag_signs, mask_sum, msg).unwrap();
+ let msg = tx.signature_hash().ok_or(MoneroError::FormatError)?;
+ let clsags_and_pseudo_outs = Clsag::sign(&mut OsRng, clsag_signs, mask_sum, msg)
+ .map_err(|_| {
+ MoneroError::FormatError
+ })?;
let mut tx = tx.clone();
let inputs_len = tx.prefix().inputs.len();
@@ -730,7 +1245,7 @@ impl UnsignedTx {
};
for item in unsigned_tx
- .outputs(keypair, &tx_key, &additional_keys, &tx_key_pub)
+ .outputs(keypair, &tx_key, &additional_keys, &tx_key_pub)?
.0
.iter()
{
@@ -740,7 +1255,7 @@ impl UnsignedTx {
penging_tx.push(PendingTx::new(
tx.clone(),
0,
- unsigned_tx.fee(),
+ unsigned_tx.fee()?,
false,
unsigned_tx.change_dts.clone(),
unsigned_tx.selected_transfers.clone(),
@@ -755,37 +1270,67 @@ impl UnsignedTx {
}
for transfer in self.transfers.details.iter() {
- tx_key_images.push(transfer.generate_key_image_without_signature(keypair));
+ tx_key_images.push(transfer.generate_key_image_without_signature(keypair)?);
}
Ok(SignedTxSet::new(penging_tx, vec![], tx_key_images))
}
}
+pub fn payload_digest(payload: &[u8]) -> [u8; 32] {
+ keccak256(payload)
+}
+
+pub fn check_unsigned(
+ request_data: Vec<u8>,
+ decrypt_key: [u8; 32],
+ pvk: [u8; 32],
+ public_spend: [u8; 32],
+) -> Result<UnsignedTx> {
+ if request_data.len() > crate::utils::io::MAX_REQUEST_BYTES {
+ return Err(MoneroError::FormatError);
+ }
+ let decrypt_key = zeroize::Zeroizing::new(decrypt_key);
+ let pvk = zeroize::Zeroizing::new(pvk);
+ let envelope = request_data
+ .strip_prefix(UNSIGNED_TX_PREFIX.as_bytes())
+ .ok_or(MoneroError::FormatError)?;
+ if request_data.len() < UNSIGNED_TX_PREFIX.len() || envelope.len() < 72 {
+ return Err(MoneroError::FormatError);
+ }
+ let decrypted_data =
+ decrypt_data_with_decrypt_key(*decrypt_key, *pvk, request_data, UNSIGNED_TX_PREFIX)
+ .map_err(|e| match e {
+ MoneroError::DecryptInvalidSignature => MoneroError::MismatchedMfp,
+ _ => e,
+ })?;
+ let unsigned_tx = UnsignedTx::deserialize(&decrypted_data.data)?;
+ unsigned_tx.validate_for_wallet(
+ &PublicKey::from_bytes(&public_spend)?,
+ &PrivateKey::from_bytes(pvk.as_ref()),
+ )?;
+ Ok(unsigned_tx)
+}
+
pub fn parse_unsigned(
request_data: Vec<u8>,
decrypt_key: [u8; 32],
pvk: [u8; 32],
+ public_spend: [u8; 32],
) -> Result<DisplayTransactionInfo> {
- let decrypted_data = match decrypt_data_with_decrypt_key(
- decrypt_key,
- pvk,
- request_data.clone(),
- UNSIGNED_TX_PREFIX,
- ) {
- Ok(data) => data,
- Err(e) => match e {
- MoneroError::DecryptInvalidSignature => return Err(MoneroError::MismatchedMfp),
- _ => return Err(e),
- },
- };
-
- let unsigned_tx = UnsignedTx::deserialize(&decrypted_data.data);
-
- Ok(unsigned_tx.display_info())
+ let decrypt_key = zeroize::Zeroizing::new(decrypt_key);
+ let pvk = zeroize::Zeroizing::new(pvk);
+ let unsigned_tx = check_unsigned(request_data, *decrypt_key, *pvk, public_spend)?;
+ unsigned_tx.display_info(
+ &PublicKey::from_bytes(&public_spend)?,
+ &PrivateKey::from_bytes(pvk.as_ref()),
+ )
}
pub fn sign_tx(keypair: KeyPair, request_data: Vec<u8>) -> Result<Vec<u8>> {
+ if request_data.len() > crate::utils::io::MAX_REQUEST_BYTES {
+ return Err(MoneroError::FormatError);
+ }
let decrypted_data = match decrypt_data_with_pvk(
keypair.view.to_bytes(),
request_data.clone(),
@@ -798,7 +1343,8 @@ pub fn sign_tx(keypair: KeyPair, request_data: Vec<u8>) -> Result<Vec<u8>> {
},
};
- let unsigned_tx = UnsignedTx::deserialize(&decrypted_data.data);
+ let unsigned_tx = UnsignedTx::deserialize(&decrypted_data.data)?;
+ unsigned_tx.validate_all()?;
let signed_txes = unsigned_tx.sign(&keypair)?;
### rust/apps/monero/src/transfer_key.rs
@@ -1,6 +1,7 @@
+use crate::errors::{MoneroError, Result};
use crate::extra::*;
use crate::key::*;
-use crate::transfer::{TxConstructionData, TxDestinationEntry};
+use crate::transfer::{AccountPublicAddress, TxConstructionData, TxDestinationEntry};
use crate::utils::*;
use alloc::vec;
use alloc::vec::Vec;
@@ -12,51 +13,68 @@ use monero_wallet::SharedKeyDerivations;
use rand_core::OsRng;
use zeroize::Zeroizing;
+#[derive(Debug, Default, Clone)]
+pub(crate) struct RequestedExtra {
+ pub nonce: Option<Vec<u8>>,
+ pub padding: usize,
+}
+
+#[derive(Debug, Default, Clone, Copy)]
+struct DestinationClassification {
+ num_standard: usize,
+ num_subaddress: usize,
+ single_subaddress_spend: Option<[u8; 32]>,
+}
+
impl TxConstructionData {
- fn should_use_additional_keys(&self) -> bool {
- self.sources
- .iter()
- .any(|source| !source.real_out_additional_tx_keys.is_empty())
+ fn classify_destinations(&self) -> DestinationClassification {
+ let change_addr = self.change_dts.addr;
+ let mut unique: Vec<AccountPublicAddress> = vec![];
+ let mut res = DestinationClassification::default();
+
+ for dst in self.splitted_dsts.iter() {
+ if dst.addr == change_addr || unique.contains(&dst.addr) {
+ continue;
+ }
+ unique.push(dst.addr);
+
+ if dst.is_subaddress {
+ res.num_subaddress += 1;
+ res.single_subaddress_spend = Some(dst.addr.spend_public_key);
+ } else {
+ res.num_standard += 1;
+ }
+ }
+
+ res
}
- fn has_payments_to_subaddresses(&self) -> bool {
- self.splitted_dsts.iter().any(|dst| dst.is_subaddress)
+ fn should_use_additional_keys(&self) -> bool {
+ let classification = self.classify_destinations();
+ classification.num_subaddress > 0
+ && (classification.num_standard > 0 || classification.num_subaddress > 1)
}
pub fn transaction_keys(
&self,
) -> (PrivateKey, Vec<PrivateKey>, EdwardsPoint, Vec<EdwardsPoint>) {
- let tx_key = generate_random_scalar(&mut OsRng);
+ let classification = self.classify_destinations();
+ let should_use_additional_keys = self.should_use_additional_keys();
+
+ let tx_key = PrivateKey::from_bytes(generate_random_scalar(&mut OsRng).as_bytes());
let mut additional_keys = vec![];
- if self.should_use_additional_keys() {
+ if should_use_additional_keys {
for _ in 0..self.splitted_dsts.len() {
additional_keys.push(PrivateKey::from_bytes(
generate_random_scalar(&mut OsRng).as_bytes(),
));
}
}
- let tx_key = PrivateKey::from_bytes(tx_key.as_bytes());
let mut tx_key_pub = EdwardsPoint::mul_base(&tx_key.scalar);
let mut additional_keys_pub = vec![];
- let has_payments_to_subaddresses = self.has_payments_to_subaddresses();
- let should_use_additional_keys = self.should_use_additional_keys();
- if has_payments_to_subaddresses && !should_use_additional_keys {
- let spend = self
- .splitted_dsts
- .iter()
- .find(|dest| dest.is_subaddress)
- .unwrap()
- .addr
- .spend_public_key;
-
- tx_key_pub = tx_key.scalar
- * PublicKey::from_bytes(&spend)
- .unwrap()
- .point
- .decompress()
- .unwrap();
- } else if should_use_additional_keys {
+
+ if should_use_additional_keys {
for (additional_key, dest) in
additional_keys.clone().into_iter().zip(&self.splitted_dsts)
{
@@ -68,13 +86,29 @@ impl TxConstructionData {
additional_keys_pub.push(EdwardsPoint::mul_base(&additional_key.scalar))
}
}
+ } else if classification.num_standard == 0 && classification.num_subaddress == 1 {
+ if let Some(spend) = classification.single_subaddress_spend {
+ tx_key_pub = tx_key.scalar
+ * PublicKey::from_bytes(&spend)
+ .unwrap()
+ .point
+ .decompress()
+ .unwrap();
+ }
}
(tx_key, additional_keys, tx_key_pub, additional_keys_pub)
}
pub fn is_change_dest(&self, dest: &TxDestinationEntry) -> bool {
- dest == &self.change_dts
+ dest.addr == self.change_dts.addr
+ }
+
+ pub fn has_change_output(&self) -> bool {
+ let change_addr = self.change_dts.addr;
+ self.splitted_dsts
+ .iter()
+ .any(|dst| dst.addr == change_addr && dst.amount > 0)
}
fn ecdhs(
@@ -120,30 +154,105 @@ impl TxConstructionData {
res
}
+ pub(crate) fn requested_extra(&self) -> Result<RequestedExtra> {
+ let mut res = RequestedExtra::default();
+ use crate::utils::io::Reader;
+ let mut reader = Reader::new(&self.extra);
+ while reader.remaining() > 0 {
+ match reader.read_u8()? {
+ 0x00 => res.padding += 1,
+ 0x01 => {
+ reader.read_bytes(32)?;
+ }
+ 0x02 => {
+ res.nonce = Some(reader.read_vec_u8(255)?);
+ }
+ 0x03 => {
+ let length = reader.read_count(self.extra.len())?;
+ let mut field = Reader::new(reader.read_bytes(length)?);
+ field.read_varint()?;
+ field.read_bytes(32)?;
+ if field.remaining() != 0 {
+ return Err(MoneroError::FormatError);
+ }
+ }
+ 0x04 => {
+ let count = reader.read_count(self.extra.len() / 32)?;
+ reader.read_bytes(count.checked_mul(32).ok_or(MoneroError::FormatError)?)?;
+ }
+ _ => return Err(MoneroError::FormatError),
+ }
+ }
+
+ Ok(res)
+ }
+
+ pub(crate) fn payment_id_destination_index(&self) -> Option<usize> {
+ let change_addr = self.change_dts.addr;
+ let mut unique: Vec<AccountPublicAddress> = vec![];
+ let mut chosen = None;
+ for (i, dst) in self.splitted_dsts.iter().enumerate() {
+ if dst.amount == 0 || dst.addr == change_addr || unique.contains(&dst.addr) {
+ continue;
+ }
+ unique.push(dst.addr);
+ if unique.len() > 1 {
+ return None;
+ }
+ chosen = Some(i);
+ }
+ chosen.or_else(|| {
+ self.splitted_dsts
+ .iter()
+ .position(|dst| dst.addr == change_addr)
+ })
+ }
+
+ fn destination_payment_id_xor(&self, payment_id_xors: &[[u8; 8]]) -> Option<[u8; 8]> {
+ self.payment_id_destination_index()
+ .and_then(|index| payment_id_xors.get(index).copied())
+ }
+
pub fn extra(
&self,
keypair: &KeyPair,
tx_key: &PrivateKey,
additional_keys: &Vec<PrivateKey>,
tx_key_pub: &EdwardsPoint,
additional_keys_pub: &Vec<EdwardsPoint>,
- ) -> Vec<u8> {
+ ) -> Result<Vec<u8>> {
let payment_id_xors = self.payment_id_xors(keypair, tx_key, additional_keys, tx_key_pub);
let mut extra = Extra::new(*tx_key_pub, additional_keys_pub.clone());
- if self.splitted_dsts.len() == 2 {
- let (_, payment_id_xor) = self
- .splitted_dsts
- .iter()
- .zip(&payment_id_xors)
- .find(|(dest, _)| self.is_change_dest(dest))
- .expect("multiple change outputs?");
- let mut id_vec = Vec::with_capacity(1 + 8);
- id_vec.extend_from_slice(&[1]);
- id_vec.extend_from_slice(payment_id_xor);
- extra.push_nonce(id_vec);
+
+ let requested = self.requested_extra().unwrap_or_default();
+ let requested_nonce = requested.nonce;
+ match requested_nonce {
+ Some(nonce) if nonce.first() == Some(&1) && nonce.len() == 9 => {
+ let xor = self
+ .destination_payment_id_xor(&payment_id_xors)
+ .ok_or(MoneroError::FormatError)?;
+ let mut id_vec = Vec::with_capacity(1 + 8);
+ id_vec.push(1);
+ id_vec.extend(nonce[1..9].iter().zip(xor.iter()).map(|(a, b)| a ^ b));
+ extra.push_nonce(id_vec);
+ }
+ Some(nonce) => extra.push_nonce(nonce),
+ None => {
+ if self.splitted_dsts.len() <= 2 {
+ if let Some(payment_id_xor) = self.destination_payment_id_xor(&payment_id_xors)
+ {
+ let mut id_vec = Vec::with_capacity(1 + 8);
+ id_vec.push(1);
+ id_vec.extend_from_slice(&payment_id_xor);
+ extra.push_nonce(id_vec);
+ }
+ }
+ }
}
- extra.serialize()
+ extra.push_padding(requested.padding);
+
+ Ok(extra.serialize())
}
pub fn shared_key_derivations(
### rust/apps/monero/src/utils/io.rs
@@ -1,3 +1,4 @@
+use crate::errors::{MoneroError, Result};
use crate::transfer::{
AccountPublicAddress, OutputEntry, TxConstructionData, TxDestinationEntry, TxSourceEntry,
};
@@ -6,70 +7,163 @@ use alloc::string::String;
use alloc::vec;
use alloc::vec::Vec;
-pub fn read_varinteger(data: &[u8], offset: &mut usize) -> u64 {
- let mut value = 0u64;
- *offset += decode_with_offset(data, *offset, &mut value);
+pub const MAX_REQUEST_BYTES: usize = 14 * 1024;
- value
-}
+pub const MAX_TXES: usize = 256;
+pub const MAX_SOURCES: usize = 4096;
+pub const MAX_RING_SIZE: usize = 4096;
+pub const MAX_DESTINATIONS: usize = 4096;
+pub const MAX_ADDITIONAL_KEYS: usize = 4096;
+pub const MAX_SELECTED_TRANSFERS: usize = 4096;
+pub const MAX_SUBADDR_INDICES: usize = 4096;
+pub const MAX_EXTRA_LEN: usize = MAX_REQUEST_BYTES;
+pub const MAX_ADDRESS_STRING: usize = 512;
-pub fn write_varinteger(value: u64) -> Vec<u8> {
- let mut buffer = vec![0u8; length(value)];
- encode_with_offset(value, &mut buffer, 0);
- buffer
+pub struct Reader<'a> {
+ data: &'a [u8],
+ offset: usize,
}
-pub fn read_next_u8(bytes: &[u8], offset: &mut usize) -> u8 {
- let value = u8::from_le_bytes(bytes[*offset..*offset + 1].try_into().unwrap());
- *offset += 1;
- value
-}
+impl<'a> Reader<'a> {
+ pub fn new(data: &'a [u8]) -> Self {
+ Reader { data, offset: 0 }
+ }
-pub fn read_next_u32(bytes: &[u8], offset: &mut usize) -> u32 {
- let value = u32::from_le_bytes(bytes[*offset..*offset + 4].try_into().unwrap());
- *offset += 4;
- value
-}
+ pub fn offset(&self) -> usize {
+ self.offset
+ }
-pub fn read_next_u64(bytes: &[u8], offset: &mut usize) -> u64 {
- let value = u64::from_le_bytes(bytes[*offset..*offset + 8].try_into().unwrap());
- *offset += 8;
- value
-}
+ pub fn remaining(&self) -> usize {
+ self.data.len().saturating_sub(self.offset)
+ }
-pub fn read_next_bool(bytes: &[u8], offset: &mut usize) -> bool {
- read_next_u8(bytes, offset) != 0
-}
+ pub fn remaining_bytes(&self) -> &'a [u8] {
+ let start = self.offset.min(self.data.len());
+ &self.data[start..]
+ }
-pub fn read_next_vec_u8(bytes: &[u8], offset: &mut usize, len: usize) -> Vec<u8> {
- let value = bytes[*offset..*offset + len].to_vec();
- *offset += len;
- value
-}
+ pub fn read_bytes(&mut self, len: usize) -> Result<&'a [u8]> {
+ let end = self
+ .offset
+ .checked_add(len)
+ .ok_or(MoneroError::FormatError)?;
+ if end > self.data.len() {
+ return Err(MoneroError::FormatError);
+ }
+ let out = &self.data[self.offset..end];
+ self.offset = end;
+ Ok(out)
+ }
-pub fn read_next_tx_destination_entry(bytes: &[u8], offset: &mut usize) -> TxDestinationEntry {
- let original_len = read_varinteger(bytes, offset) as usize;
- let original = String::from_utf8(bytes[*offset..*offset + original_len].to_vec()).unwrap();
- *offset += original_len;
- let amount = read_varinteger(bytes, offset);
- let mut spend_public_key = [0u8; 32];
- spend_public_key.copy_from_slice(&bytes[*offset..*offset + 32]);
- *offset += 32;
- let mut view_public_key = [0u8; 32];
- view_public_key.copy_from_slice(&bytes[*offset..*offset + 32]);
- *offset += 32;
- let is_subaddress = read_next_bool(bytes, offset);
- let is_integrated = read_next_bool(bytes, offset);
- TxDestinationEntry {
- original,
- amount,
- addr: AccountPublicAddress {
- spend_public_key,
- view_public_key,
- },
- is_subaddress,
- is_integrated,
+ pub fn read_u8(&mut self) -> Result<u8> {
+ Ok(self.read_bytes(1)?[0])
+ }
+
+ pub fn read_u32(&mut self) -> Result<u32> {
+ let bytes: [u8; 4] = self
+ .read_bytes(4)?
+ .try_into()
+ .map_err(|_| MoneroError::FormatError)?;
+ Ok(u32::from_le_bytes(bytes))
+ }
+
+ pub fn read_u64(&mut self) -> Result<u64> {
+ let bytes: [u8; 8] = self
+ .read_bytes(8)?
+ .try_into()
+ .map_err(|_| MoneroError::FormatError)?;
+ Ok(u64::from_le_bytes(bytes))
+ }
+
+ pub fn read_bool(&mut self) -> Result<bool> {
+ Ok(self.read_u8()? != 0)
+ }
+
+ pub fn read_array32(&mut self) -> Result<[u8; 32]> {
+ let bytes: [u8; 32] = self
+ .read_bytes(32)?
+ .try_into()
+ .map_err(|_| MoneroError::FormatError)?;
+ Ok(bytes)
+ }
+
+ pub fn read_varint(&mut self) -> Result<u64> {
+ let mut value = 0u64;
+ let mut shift = 0u32;
+
+ for _ in 0..10 {
+ let byte = self.read_u8()?;
+ let low = (byte & 0x7f) as u64;
+ if shift == 63 && low > 1 {
+ return Err(MoneroError::FormatError);
+ }
+ value |= low << shift;
+ if byte & 0x80 == 0 {
+ return Ok(value);
+ }
+ shift += 7;
+ }
+
+ Err(MoneroError::FormatError)
+ }
+
+ pub fn read_count(&mut self, max: usize) -> Result<usize> {
+ let value = self.read_varint()?;
+ if value > max as u64 {
+ return Err(MoneroError::FormatError);
+ }
+ let value = value as usize;
+ if value > self.remaining().saturating_add(1) {
+ return Err(MoneroError::FormatError);
+ }
+ Ok(value)
+ }
+
+ pub fn read_string(&mut self, max: usize) -> Result<String> {
+ let len = self.read_count(max)?;
+ let bytes = self.read_bytes(len)?;
+ String::from_utf8(bytes.to_vec()).map_err(|_| MoneroError::FormatError)
+ }
+
+ pub fn read_vec_u8(&mut self, max: usize) -> Result<Vec<u8>> {
+ let len = self.read_count(max)?;
+ Ok(self.read_bytes(len)?.to_vec())
}
+
+ pub fn read_vec_array32(&mut self, max: usize) -> Result<Vec<[u8; 32]>> {
+ let len = self.read_count(max)?;
+ let mut res = Vec::with_capacity(len.min(64));
+ for _ in 0..len {
+ res.push(self.read_array32()?);
+ }
+ Ok(res)
+ }
+
+ pub fn read_tx_destination_entry(&mut self) -> Result<TxDestinationEntry> {
+ let original = self.read_string(MAX_ADDRESS_STRING)?;
+ let amount = self.read_varint()?;
+ let spend_public_key = self.read_array32()?;
+ let view_public_key = self.read_array32()?;
+ let is_subaddress = self.read_bool()?;
+ let is_integrated = self.read_bool()?;
+
+ Ok(TxDestinationEntry {
+ original,
+ amount,
+ addr: AccountPublicAddress {
+ spend_public_key,
+ view_public_key,
+ },
+ is_subaddress,
+ is_integrated,
+ })
+ }
+}
+
+pub fn write_varinteger(value: u64) -> Vec<u8> {
+ let mut buffer = vec![0u8; length(value)];
+ encode_with_offset(value, &mut buffer, 0);
+ buffer
}
pub fn write_tx_destination_entry(entry: &TxDestinationEntry) -> Vec<u8> {
@@ -165,54 +259,86 @@ pub fn read_next_u8_32(bytes: &[u8], offset: &mut usize) -> [u8; 32] {
mod tests {
use super::*;
+ fn encoded_destination() -> Vec<u8> {
+ let spend = [0x11u8; 32];
+ let view = [0x22u8; 32];
+ let mut bytes = write_varinteger(6);
+ bytes.extend_from_slice(b"48A1-t");
+ bytes.extend_from_slice(&write_varinteger(12_345));
+ bytes.extend_from_slice(&spend);
+ bytes.extend_from_slice(&view);
+ bytes.push(1);
+ bytes.push(0);
+ bytes
+ }
+
#[test]
- fn primitive_readers_advance_the_offset() {
+ fn primitives_read_and_advance_the_offset() {
let mut bytes = vec![0x7F];
bytes.extend_from_slice(&0x1234_5678u32.to_le_bytes());
bytes.extend_from_slice(&0x0123_4567_89AB_CDEFu64.to_le_bytes());
bytes.push(1);
- bytes.extend_from_slice(&[9, 8, 7]);
bytes.extend_from_slice(&[0xAA; 32]);
- let mut offset = 0;
- assert_eq!(read_next_u8(&bytes, &mut offset), 0x7F);
- assert_eq!(read_next_u32(&bytes, &mut offset), 0x1234_5678);
- assert_eq!(read_next_u64(&bytes, &mut offset), 0x0123_4567_89AB_CDEF);
- assert!(read_next_bool(&bytes, &mut offset));
- assert_eq!(read_next_vec_u8(&bytes, &mut offset, 3), vec![9, 8, 7]);
- assert_eq!(read_next_u8_32(&bytes, &mut offset), [0xAA; 32]);
- assert_eq!(offset, bytes.len());
+ let mut reader = Reader::new(&bytes);
+ assert_eq!(reader.read_u8().unwrap(), 0x7F);
+ assert_eq!(reader.read_u32().unwrap(), 0x1234_5678);
+ assert_eq!(reader.read_u64().unwrap(), 0x0123_4567_89AB_CDEF);
+ assert!(reader.read_bool().unwrap());
+ assert_eq!(reader.read_array32().unwrap(), [0xAA; 32]);
+ assert_eq!(reader.offset(), bytes.len());
+ assert_eq!(reader.remaining(), 0);
}
#[test]
fn varinteger_roundtrip_updates_the_offset() {
for value in [0, 127, 128, 16_384, u32::MAX as u64, u64::MAX] {
let encoded = write_varinteger(value);
- let mut offset = 0;
-
- assert_eq!(read_varinteger(&encoded, &mut offset), value);
- assert_eq!(offset, encoded.len());
+ let mut reader = Reader::new(&encoded);
+ assert_eq!(reader.read_varint().unwrap(), value);
+ assert_eq!(reader.offset(), encoded.len());
}
}
#[test]
fn destination_entry_roundtrip() {
- let entry = TxDestinationEntry {
- original: String::from("48A1-test-address"),
- amount: 12_345_678_901,
- addr: AccountPublicAddress {
- spend_public_key: [0x11; 32],
- view_public_key: [0x22; 32],
- },
- is_subaddress: true,
- is_integrated: false,
- };
+ let encoded = encoded_destination();
+ let mut reader = Reader::new(&encoded);
+ let decoded = reader.read_tx_destination_entry().unwrap();
- let encoded = write_tx_destination_entry(&entry);
- let mut offset = 0;
- let decoded = read_next_tx_destination_entry(&encoded, &mut offset);
+ assert_eq!(decoded.original, "48A1-t");
+ assert_eq!(decoded.amount, 12_345);
+ assert_eq!(decoded.addr.spend_public_key, [0x11u8; 32]);
+ assert_eq!(decoded.addr.view_public_key, [0x22u8; 32]);
+ assert!(decoded.is_subaddress);
+ assert!(!decoded.is_integrated);
+ assert_eq!(reader.offset(), encoded.len());
+ }
- assert_eq!(decoded, entry);
- assert_eq!(offset, encoded.len());
+ #[test]
+ fn truncated_reads_return_an_error_instead_of_panicking() {
+ let mut reader = Reader::new(&[0x80]);
+ assert!(reader.read_varint().is_err());
+
+ let mut reader = Reader::new(&[0u8; 4]);
+ assert!(reader.read_array32().is_err());
+
+ let mut reader = Reader::new(&[0xff, 0xff, 0xff, 0xff, 0x0f]);
+ assert!(reader.read_count(MAX_SOURCES).is_err());
+
+ let mut reader = Reader::new(&[0x80, 0x80, 0x80, 0x80, 0x08]);
+ assert!(reader.read_count(16).is_err());
+
+ let mut bytes = write_varinteger(1);
+ bytes.push(0xFF);
+ let mut reader = Reader::new(&bytes);
+ assert!(reader.read_tx_destination_entry().is_err());
+ }
+
+ #[test]
+ fn oversized_varints_are_rejected() {
+ let bytes = [0xFFu8; 10];
+ let mut reader = Reader::new(&bytes);
+ assert!(reader.read_varint().is_err());
}
}
### rust/apps/monero/src/utils/mod.rs
@@ -33,7 +33,8 @@ pub struct DecryptUrData {
}
pub fn generate_decrypt_key(pvk: [u8; PUBKEY_LEH]) -> [u8; 32] {
- cryptonight_hash_v0(&pvk)
+ let pvk = zeroize::Zeroizing::new(pvk);
+ cryptonight_hash_v0(&*pvk)
}
pub fn encrypt_data_with_pincode(data: String, pin: [u8; 6]) -> Vec<u8> {
@@ -113,9 +114,10 @@ pub fn decrypt_data_with_pvk(
if pvk.len() != PUBKEY_LEH {
return Err(MoneroError::InvalidPrivateViewKey);
}
- let pvk_hash = cryptonight_hash_v0(&pvk);
+ let pvk = zeroize::Zeroizing::new(pvk);
+ let pvk_hash = zeroize::Zeroizing::new(cryptonight_hash_v0(&*pvk));
- decrypt_data_with_decrypt_key(pvk_hash, pvk, data, magic)
+ decrypt_data_with_decrypt_key(*pvk_hash, *pvk, data, magic)
}
pub fn decrypt_data_with_decrypt_key(
@@ -124,68 +126,60 @@ pub fn decrypt_data_with_decrypt_key(
data: Vec<u8>,
magic: &str,
) -> Result<DecryptUrData> {
- let key = GenericArray::from_slice(&decrypt_key);
-
- let magic_bytes = magic.as_bytes();
-
- let mut data = data.clone();
- let mut magic_bytes_found = true;
- for i in 0..magic_bytes.len() {
- if data[i] != magic_bytes[i] {
- magic_bytes_found = false;
- break;
- }
- }
-
- if magic_bytes_found {
- data = data[magic_bytes.len()..].to_vec();
+ use zeroize::Zeroizing;
+ let decrypt_key = Zeroizing::new(decrypt_key);
+ let pvk = Zeroizing::new(pvk);
+ let envelope = data
+ .strip_prefix(magic.as_bytes())
+ .ok_or(MoneroError::FormatError)?;
+ let start = if magic == KEY_IMAGE_EXPORT_MAGIC {
+ 4
+ } else {
+ 0
+ };
+ let has_public_keys = magic == OUTPUT_EXPORT_MAGIC || magic == KEY_IMAGE_EXPORT_MAGIC;
+ let header = start + if has_public_keys { PUBKEY_LEH * 2 } else { 0 };
+ if envelope.len() < 8 + header + 64 {
+ return Err(MoneroError::FormatError);
}
-
- let nonce_bytes = data[0..8].to_vec();
- let nonce = GenericArray::from_slice(&nonce_bytes);
-
- let raw_data = data[0..data.len() - 64].to_vec();
- let data = data[8..].to_vec();
-
- let mut cipher = ChaCha20Legacy::new(key, nonce);
-
- let mut buffer = data.clone();
-
- let signature = buffer[buffer.len() - 64..].to_vec();
-
+ let split = envelope.len() - 64;
+ let raw_data = &envelope[..split];
+ let signature = envelope[split..].to_vec();
if !check_signature(
- &keccak256(&raw_data.clone()),
- &PrivateKey::from_bytes(&pvk).get_public_key(),
- &Signature(signature.clone().try_into().unwrap()),
+ &keccak256(raw_data),
+ &PrivateKey::from_bytes(pvk.as_ref()).get_public_key(),
+ &Signature(
+ signature
+ .as_slice()
+ .try_into()
+ .map_err(|_| MoneroError::FormatError)?,
+ ),
) {
return Err(MoneroError::DecryptInvalidSignature);
}
-
+ let nonce_bytes = envelope[..8].to_vec();
+ let mut buffer = Zeroizing::new(envelope[8..split].to_vec());
+ let mut cipher = ChaCha20Legacy::new(
+ GenericArray::from_slice(decrypt_key.as_ref()),
+ GenericArray::from_slice(&nonce_bytes),
+ );
cipher.apply_keystream(&mut buffer);
-
- let start = match magic {
- KEY_IMAGE_EXPORT_MAGIC => 4,
- _ => 0,
+ let (pk1, pk2) = if has_public_keys {
+ (
+ Some(PublicKey::from_bytes(&buffer[start..start + PUBKEY_LEH])?),
+ Some(PublicKey::from_bytes(&buffer[start + PUBKEY_LEH..header])?),
+ )
+ } else {
+ (None, None)
};
- let has_pubilc_keys = magic == OUTPUT_EXPORT_MAGIC || magic == KEY_IMAGE_EXPORT_MAGIC;
-
- let mut pk1 = None;
- let mut pk2 = None;
- if has_pubilc_keys {
- pk1 = Some(PublicKey::from_bytes(&buffer[start..start + PUBKEY_LEH]).unwrap());
- pk2 = Some(
- PublicKey::from_bytes(&buffer[start + PUBKEY_LEH..start + PUBKEY_LEH * 2]).unwrap(),
- );
- }
Ok(DecryptUrData {
pk1,
pk2,
- data: buffer[(start + if has_pubilc_keys { PUBKEY_LEH * 2 } else { 0 })..buffer.len() - 64]
- .to_vec(),
+ data: buffer[header..].to_vec(),
nonce: Some(nonce_bytes),
magic: magic.to_string(),
signature: Some(signature),
- hash: keccak256(&raw_data).to_vec(),
+ hash: keccak256(raw_data).to_vec(),
})
}
@@ -203,14 +197,20 @@ pub fn get_key_image_from_input(input: Input) -> Result<Keyimage> {
}
pub fn fmt_monero_amount(value: u64) -> String {
- let value = value as f64 / 1_000_000_000_000.0;
- let value = format!("{value:.12}");
- let value = value.trim_end_matches('0').to_string();
- if value.ends_with('.') {
- format!("{} XMR", &value[..value.len() - 1])
- } else {
- format!("{value} XMR")
+ const PICONERO: u64 = 1_000_000_000_000;
+
+ let whole = value / PICONERO;
+ let fraction = value % PICONERO;
+ if fraction == 0 {
+ return format!("{whole} XMR");
+ }
+
+ let mut fraction = format!("{fraction:012}");
+ while fraction.ends_with('0') {
+ fraction.pop();
}
+
+ format!("{whole}.{fraction} XMR")
}
#[cfg(test)]
@@ -391,6 +391,12 @@ mod tests {
#[test]
fn test_fmt_monero_amount() {
+ assert_eq!(fmt_monero_amount(u64::MAX), "18446744.073709551615 XMR");
+ assert_eq!(
+ fmt_monero_amount(9_007_199_254_740_993),
+ "9007.199254740993 XMR"
+ );
+
let amount = 10000000000001;
let res = fmt_monero_amount(amount);
assert_eq!(res, "10.000000000001 XMR");
### rust/apps/solana/src/advanced.rs
@@ -0,0 +1,204 @@
+use crate::message::Message;
+use alloc::{format, string::String, vec::Vec};
+use bitcoin::base58;
+
+#[derive(Clone, Debug)]
+pub struct AdvancedItem {
+ pub title: String,
+ pub value: String,
+}
+
+fn item(title: impl Into<String>, value: impl Into<String>) -> AdvancedItem {
+ AdvancedItem {
+ title: title.into(),
+ value: value.into(),
+ }
+}
+
+impl Message {
+ pub(crate) fn advanced_review(&self, signer: Option<&[u8; 32]>) -> Vec<AdvancedItem> {
+ let required = self.header.num_required_signatures as usize;
+ let static_len = self.accounts.len();
+ let mut accounts: Vec<(String, bool, bool)> = self
+ .accounts
+ .iter()
+ .enumerate()
+ .map(|(i, a)| {
+ let is_signer = i < required;
+ let writable = if is_signer {
+ i < required - self.header.num_readonly_signed_accounts as usize
+ } else {
+ i < static_len - self.header.num_readonly_unsigned_accounts as usize
+ };
+ (base58::encode(&a.value), is_signer, writable)
+ })
+ .collect();
+ if let Some(lookups) = &self.address_table_lookups {
+ for writable in [true, false] {
+ for lookup in lookups {
+ let indexes = if writable {
+ &lookup.writable_indexes
+ } else {
+ &lookup.readonly_indexes
+ };
+ for index in indexes {
+ accounts.push((
+ format!(
+ "{{{{solana_advanced_unresolved}}}}\n{{{{solana_advanced_table}}}}: {}\n{{{{solana_advanced_index}}}}: {}",
+ base58::encode(&lookup.account_key.value),
+ index
+ ),
+ false,
+ writable,
+ ));
+ }
+ }
+ }
+ }
+ let version = if self.transaction_config.is_some() {
+ "V1"
+ } else if self.is_versioned {
+ "V0"
+ } else {
+ "Legacy"
+ };
+ let mut items = alloc::vec![
+ item("{{solana_advanced_version}}", version),
+ item("{{solana_advanced_signatures}}", format!("{}", required)),
+ item(
+ "{{solana_advanced_fee_payer}}",
+ self.accounts
+ .first()
+ .map(|a| base58::encode(&a.value))
+ .unwrap_or_else(|| String::from("{{solana_advanced_not_present}}"))
+ ),
+ ];
+ if let Some(signer) = signer {
+ items.push(item(
+ "{{solana_advanced_device_signer}}",
+ base58::encode(signer),
+ ));
+ }
+ for (i, (address, signer, writable)) in accounts.iter().enumerate() {
+ items.push(item(
+ format!("{{{{solana_advanced_account}}}} #{}", i),
+ format!(
+ "{} | {}\n{}",
+ if *signer {
+ "{{solana_advanced_signer}}"
+ } else {
+ "{{solana_advanced_non_signer}}"
+ },
+ if *writable {
+ "{{solana_advanced_writable}}"
+ } else {
+ "{{solana_advanced_readonly}}"
+ },
+ address
+ ),
+ ));
+ }
+ for (i, instruction) in self.instructions.iter().enumerate() {
+ let program = &accounts[instruction.program_index as usize].0;
+ let mut value = format!(
+ "{{{{solana_advanced_program}}}} [{}]\n{}\n{{{{solana_advanced_indexes}}}}: {:?}\n{{{{solana_advanced_data}}}}: {} {{{{solana_advanced_bytes}}}}",
+ instruction.program_index,
+ program,
+ instruction.account_indexes,
+ instruction.data.len()
+ );
+ if self.transaction_config.is_some()
+ && program == "ComputeBudget111111111111111111111111111111"
+ {
+ value.push_str("\n{{solana_advanced_ignored}}");
+ }
+ items.push(item(
+ format!("{{{{solana_advanced_instruction}}}} #{}", i + 1),
+ value,
+ ));
+ }
+ items.push(item(
+ if self.transaction_config.is_some() {
+ "{{solana_advanced_lifetime}}"
+ } else {
+ "{{solana_advanced_blockhash}}"
+ },
+ base58::encode(&self.block_hash.value),
+ ));
+ items
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use alloc::vec;
+
+ #[test]
+ fn empty_account_list_does_not_panic() {
+ let mut raw = vec![0, 0, 0, 0];
+ raw.extend([0; 32]);
+ raw.push(0);
+ let message = Message::read_exact(&mut raw).unwrap();
+ assert!(message
+ .advanced_review(None)
+ .iter()
+ .any(|i| i.title == "{{solana_advanced_fee_payer}}"
+ && i.value == "{{solana_advanced_not_present}}"));
+ }
+
+ #[test]
+ fn permissions_and_alt_order_are_preserved() {
+ let mut raw = vec![128, 2, 1, 1, 4];
+ for byte in 1..=4 {
+ raw.extend([byte; 32]);
+ }
+ raw.extend([9; 32]);
+ raw.extend([1, 3, 4, 0, 4, 5, 7, 0, 2]);
+ for byte in 5..=6 {
+ raw.extend([byte; 32]);
+ raw.extend([1, 7, 1, 8]);
+ }
+ let message = Message::read_exact(&mut raw).unwrap();
+ let fields = message.advanced_review(Some(&[1; 32]));
+ let value = |title: &str| {
+ fields
+ .iter()
+ .find(|i| i.title == title)
+ .unwrap()
+ .value
+ .as_str()
+ };
+ assert!(value("{{solana_advanced_account}} #0")
+ .starts_with("{{solana_advanced_signer}} | {{solana_advanced_writable}}"));
+ assert!(value("{{solana_advanced_account}} #1")
+ .starts_with("{{solana_advanced_signer}} | {{solana_advanced_readonly}}"));
+ assert!(value("{{solana_advanced_account}} #2")
+ .starts_with("{{solana_advanced_non_signer}} | {{solana_advanced_writable}}"));
+ assert!(value("{{solana_advanced_account}} #3")
+ .starts_with("{{solana_advanced_non_signer}} | {{solana_advanced_readonly}}"));
+ assert_eq!(
+ value("{{solana_advanced_account}} #5"),
+ format!(
+ "{{{{solana_advanced_non_signer}}}} | {{{{solana_advanced_writable}}}}\n{{{{solana_advanced_unresolved}}}}\n{{{{solana_advanced_table}}}}: {}\n{{{{solana_advanced_index}}}}: 7",
+ base58::encode(&[6; 32])
+ )
+ );
+ assert_eq!(
+ value("{{solana_advanced_account}} #6"),
+ format!(
+ "{{{{solana_advanced_non_signer}}}} | {{{{solana_advanced_readonly}}}}\n{{{{solana_advanced_unresolved}}}}\n{{{{solana_advanced_table}}}}: {}\n{{{{solana_advanced_index}}}}: 8",
+ base58::encode(&[5; 32])
+ )
+ );
+ assert!(
+ value("{{solana_advanced_instruction}} #1").contains("{{solana_advanced_program}} [3]")
+ );
+ assert!(value("{{solana_advanced_instruction}} #1")
+ .contains("{{solana_advanced_indexes}}: [0, 4, 5, 7]"));
+ assert_eq!(
+ value("{{solana_advanced_device_signer}}"),
+ base58::encode(&[1; 32])
+ );
+ }
+}
### rust/apps/solana/src/instruction.rs
@@ -127,6 +127,24 @@ impl Instruction {
resolvers::squads_v4::resolve(instruction, accounts)
}
SupportedProgram::JupiterProgramV6 => {
+ if self.data.len() < 8 {
+ return Err(SolanaError::InvalidData(
+ "Jupiter instruction discriminator is truncated".to_string(),
+ ));
+ }
+ let discriminator = &self.data[..8];
+ let is_supported_instruction = matches!(
+ discriminator,
+ [0xc1, 0x20, 0x9b, 0x33, 0x41, 0xd6, 0x9c, 0x81]
+ | [0xe5, 0x17, 0xcb, 0x97, 0x7a, 0xe3, 0xad, 0x2a]
+ | [0xd0, 0x33, 0xef, 0x97, 0x7b, 0x2b, 0xed, 0x5c]
+ | [0xb0, 0xd1, 0x69, 0xa8, 0x9a, 0x7d, 0x45, 0x3e]
+ );
+ if !is_supported_instruction {
+ return Err(SolanaError::UnsupportedProgram(
+ "unsupported Jupiter v6 instruction".to_string(),
+ ));
+ }
let instruction =
crate::solana_lib::jupiter_v6::instructions::JupiterInstructions::dispatch(
self.data.as_slice(),
@@ -150,8 +168,9 @@ impl Instruction {
));
}
let mut detail = ProgramDetailComputeBudget::default();
+ // Match the validator's unchecked Borsh decoding: require complete
let method = match data[0] {
- 0 if data.len() == 9 => {
+ 0 if data.len() >= 9 => {
detail.compute_unit_limit =
u32::from_le_bytes(data[1..5].try_into().map_err(|_| {
SolanaError::InvalidData("invalid compute unit limit".to_string())
@@ -164,23 +183,23 @@ impl Instruction {
.to_string();
"RequestUnitsDeprecated"
}
- 1 if data.len() == 5 => {
+ 1 if data.len() >= 5 => {
detail.heap_frame_bytes = Self::read_compute_budget_u32(&data[1..5])?.to_string();
"RequestHeapFrame"
}
- 2 if data.len() == 5 => {
+ 2 if data.len() >= 5 => {
detail.compute_unit_limit = Self::read_compute_budget_u32(&data[1..5])?.to_string();
"SetComputeUnitLimit"
}
- 3 if data.len() == 9 => {
+ 3 if data.len() >= 9 => {
detail.compute_unit_price_micro_lamports =
u64::from_le_bytes(data[1..9].try_into().map_err(|_| {
SolanaError::InvalidData("invalid compute unit price".to_string())
})?)
.to_string();
"SetComputeUnitPrice"
}
- 4 if data.len() == 5 => {
+ 4 if data.len() >= 5 => {
detail.loaded_accounts_data_size_limit =
Self::read_compute_budget_u32(&data[1..5])?.to_string();
"SetLoadedAccountsDataSizeLimit"
@@ -211,9 +230,8 @@ impl Instruction {
) -> Result<T> {
// Copied from solana_sdk
// pub const PACKET_DATA_SIZE: usize = 1280 - 40 - 8;
- crate::solana_lib::solana_program::program_utils::limited_deserialize(
+ crate::solana_lib::solana_program::program_utils::limited_deserialize::<T, 1232>(
instruction_data.as_slice(),
- 1280 - 40 - 8,
)
.map_err(|e| ProgramError(e.to_string()))
}
@@ -263,7 +281,31 @@ mod tests {
}
#[test]
- fn parses_compute_budget_instructions_strictly() {
+ fn distinguishes_malformed_and_unknown_jupiter_instructions() {
+ let jupiter_program = PROGRAM_IDS[7];
+ let instruction = |data| Instruction {
+ program_index: 0,
+ account_indexes: vec![],
+ data,
+ };
+
+ assert!(matches!(
+ instruction(vec![0x42; 7]).parse(jupiter_program, vec![]),
+ Err(SolanaError::InvalidData(_))
+ ));
+ assert!(matches!(
+ instruction(vec![0x42; 8]).parse(jupiter_program, vec![]),
+ Err(SolanaError::UnsupportedProgram(_))
+ ));
+ assert!(matches!(
+ instruction(vec![0xc1, 0x20, 0x9b, 0x33, 0x41, 0xd6, 0x9c, 0x81])
+ .parse(jupiter_program, vec![]),
+ Err(SolanaError::ProgramError(_))
+ ));
+ }
+
+ #[test]
+ fn parses_compute_budget_instructions_with_trailing_bytes() {
let cases = [
(vec![0, 64, 13, 3, 0, 7, 0, 0, 0], "RequestUnitsDeprecated"),
(vec![1, 0, 0, 4, 0], "RequestHeapFrame"),
@@ -275,11 +317,26 @@ mod tests {
let parsed = Instruction::parse_compute_budget_instruction(&data, vec![]).unwrap();
assert_eq!("ComputeBudget", parsed.common.program);
assert_eq!(method, parsed.common.method);
+ let expected = serde_json::to_value(&parsed).unwrap();
+ let mut padded = data.clone();
+ padded.extend_from_slice(&[0, 0xff, 0x42, 0]);
+ let parsed = Instruction::parse_compute_budget_instruction(&padded, vec![]).unwrap();
+ assert_eq!(expected, serde_json::to_value(&parsed).unwrap());
+ for length in 0..data.len() {
+ assert!(
+ Instruction::parse_compute_budget_instruction(&data[..length], vec![]).is_err()
+ );
+ }
}
- assert!(
- Instruction::parse_compute_budget_instruction(&[2, 1, 0, 0, 0, 0], vec![]).is_err()
- );
+ let parsed =
+ Instruction::parse_compute_budget_instruction(&[1, 0, 0, 1, 0, 0, 0, 0, 0], vec![])
+ .unwrap();
+ let ProgramDetail::ComputeBudget(detail) = parsed.kind else {
+ panic!("expected ComputeBudget detail");
+ };
+ assert_eq!("65536", detail.heap_frame_bytes);
+ assert!(Instruction::parse_compute_budget_instruction(&[5, 0, 0, 0, 0], vec![]).is_err());
assert!(Instruction::parse_compute_budget_instruction(
&[2, 1, 0, 0, 0],
vec!["unexpected".to_string()]
### rust/apps/solana/src/lib.rs
@@ -2,6 +2,8 @@
#![allow(dead_code)] // add for solana use a lot of external code
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
+pub mod advanced;
+
extern crate alloc;
extern crate core;
#[cfg(test)]
@@ -23,6 +25,7 @@ mod compact;
pub mod errors;
mod instruction;
pub mod message;
+mod message_json;
mod message_v1;
pub mod parser;
pub mod read;
@@ -105,6 +108,7 @@ fn parse_offchain_message_v0(data: &[u8]) -> Option<&str> {
}
pub fn parse_message(tx_hex: Vec<u8>, from_key: &String) -> errors::Result<SolanaMessage> {
+ let message_length = tx_hex.len();
// Keep only the representation that is displayed. Retaining both the
// UTF-8 string and its hex encoding doubles peak memory for long messages.
let offchain_message = parse_offchain_message_v0(&tx_hex).map(ToString::to_string);
@@ -119,7 +123,7 @@ pub fn parse_message(tx_hex: Vec<u8>, from_key: &String) -> errors::Result<Solan
Err(error) => (hex::encode(error.as_bytes()), String::new()),
},
};
- SolanaMessage::from(raw_message, utf8_message, from_key)
+ SolanaMessage::from(raw_message, utf8_message, from_key, message_length)
}
pub fn validate_tx(message: &mut Vec<u8>) -> bool {
@@ -154,6 +158,53 @@ pub fn parse_for_signer(data: &Vec<u8>, signer: &[u8; 32]) -> errors::Result<Par
ParsedSolanaTx::build_for_signer(data, signer)
}
+const MAX_DERIVATION_PATH_DEPTH: usize = 5;
+const MAX_DERIVATION_PATH_LEN: usize = 2 + MAX_DERIVATION_PATH_DEPTH * 12 - 1;
+
+pub fn validate_derivation_path(path: &str) -> errors::Result<String> {
+ let max_input_len = if path.starts_with("m/") {
+ MAX_DERIVATION_PATH_LEN
+ } else {
+ MAX_DERIVATION_PATH_LEN - 2
+ };
+ if path.len() > max_input_len {
+ return Err(errors::SolanaError::InvalidData(
+ "Solana derivation path exceeds maximum length".to_string(),
+ ));
+ }
+ let normalized = if path.starts_with("m/") {
+ path.to_string()
+ } else {
+ format!("m/{path}")
+ };
+ let components = normalized
+ .strip_prefix("m/")
+ .unwrap_or("")
+ .split('/')
+ .collect::<Vec<_>>();
+ if components.len() > MAX_DERIVATION_PATH_DEPTH {
+ return Err(errors::SolanaError::InvalidData(
+ "Solana derivation path exceeds maximum depth of 5".to_string(),
+ ));
+ }
+ let parse_hardened = |component: &str| {
+ component
+ .strip_suffix('\'')
+ .filter(|digits| !digits.is_empty() && digits.bytes().all(|byte| byte.is_ascii_digit()))
+ .and_then(|digits| digits.parse::<u32>().ok())
+ .filter(|index| *index < 0x8000_0000)
+ };
+ if components
+ .iter()
+ .any(|component| parse_hardened(component).is_none())
+ {
+ return Err(errors::SolanaError::InvalidData(
+ "invalid hardened Solana derivation path".to_string(),
+ ));
+ }
+ Ok(normalized)
+}
+
pub fn sign(message: Vec<u8>, hd_path: &String, seed: &[u8]) -> errors::Result<[u8; 64]> {
keystore::algorithms::ed25519::slip10_ed25519::sign_message_by_seed(seed, hd_path, &message)
.map_err(|e| errors::SolanaError::KeystoreError(format!("sign failed {:?}", e.to_string())))
@@ -166,6 +217,51 @@ mod tests {
use super::*;
+ #[test]
+ fn validates_supported_derivation_paths() {
+ for path in [
+ "44'/501'",
+ "m/44'/501'",
+ "m/44'/501'/0'",
+ "m/44'/501'/49'",
+ "m/44'/501'/0'/0'",
+ "m/44'/501'/49'/0'",
+ "m/44'/501'/50'",
+ "m/44'/501'/1000'/1'",
+ "m/44'/501'/0'/0'/0'",
+ "m/44'/501'/2147483647'",
+ "m/44'/60'/0'",
+ "m/501'/0'",
+ "m/0'",
+ ] {
+ assert!(validate_derivation_path(path).is_ok(), "{path}");
+ }
+ for path in [
+ "",
+ "m/",
+ "m/44'/501",
+ "m/44/501'",
+ "m/44'/501'/50",
+ "m/44'/501'/2147483648'",
+ "m/44'/501'/+1'",
+ "m/44'/501'//0'",
+ ] {
+ assert!(validate_derivation_path(path).is_err(), "{path}");
+ }
+ }
+
+ #[test]
+ fn bounds_derivation_path_depth_and_length() {
+ let deepest = "2147483647'/2147483647'/2147483647'/2147483647'/2147483647'";
+ assert_eq!(deepest.len() + 2, MAX_DERIVATION_PATH_LEN);
+ assert!(validate_derivation_path(deepest).is_ok());
+ assert!(validate_derivation_path(&format!("m/{deepest}")).is_ok());
+ assert!(validate_derivation_path("m/0'/0'/0'/0'/0'/0'").is_err());
+ assert!(validate_derivation_path("0'/0'/0'/0'/0'/0'").is_err());
+ assert!(validate_derivation_path(&format!("m/{}'", "0".repeat(1000))).is_err());
+ assert!(validate_derivation_path(&format!("{}'", "0".repeat(1000))).is_err());
+ }
+
#[test]
fn test_solana_sign() {
let hd_path = "m/44'/501'/0'".to_string();
@@ -198,6 +294,8 @@ mod tests {
assert!(!has_tx_prefix(&mut data.clone()));
let parsed = parse_message(data.clone(), &String::new()).unwrap();
+ assert_eq!(parsed.message_length, data.len());
+ assert!(parsed.message_length > parsed.utf8_message.len());
assert!(parsed.raw_message.is_empty());
assert!(parsed
.utf8_message
@@ -246,15 +344,13 @@ mod tests {
#[test]
fn test_solana_version_message() {
let mut buffer = hex::decode("8001000308ad7dba70a9559a85961a00a0d00e7caf6967ff28c5861360cd8e22abcbb9b3eb080a39da2d35d3c666ff3d5195bb9065ed97a2208b4245bc70e69ff4b1d2b73fff21b6871e314c96e0848ba15117ec8cef8433b5a594ff2b88798b7e6d37b84e0a0cc6b26d4216a826e48cbb719136037e76cc273efb63ec73a6f2cb56cfa6015f376f7759fe1a4270a9b568d86110869cb073c8580adc986a178c876c18ee3d0306466fe5211732ffecadba72c39be7bc8ce5bbc5f7126b2c439b3a4000000004b2acb11258cce3682c418ba872ff3df91102712f15af12b6be69b3435b0008eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a5b6bfd38a1d64b54c65490c10b1be53496be5ede8d18086335aade667915e9e90705000502400d03000500090310010a00000000000606080d0706060e0802da8aeb4fc9196606030d010808218493e497c04859060b0001090802030d0f101112098c90fd150a4af80300060c00010d09080a0b0c04061113104b5d5ddc2296dac4ffffffffffffffff060b0001090802030d0f101112098c90fd150a4af803000110aaf654f15c22d8c9aa80622becb4872b0f5a52cc8f467d8a0da58b19197d690540024544420701757403060704").unwrap();
- let pubkey = "e671e524ef43ccc5ef0006876f9a2fd66681d5abc5871136b343a3e4b073efde".to_string();
let parsed = validate_tx(&mut buffer);
assert_eq!(true, parsed)
}
#[test]
fn test_solana_version_message_2() {
let buffer = hex::decode("800100080ed027455eccf0385fc38f217c5bfbb95f711a16fbe782af7b33a97d1f17ebcd79281764ffe753b4a7a87393561a7178e5d7048eabf5302f5b0ac9ff8c2cd40560f06ebde13476f2455bc64dd1d49730033c0bac118dcbf72c38da62354df37a861c98c04915df1902f5c239c753a4bb55932b2e60b713c81bc81be9badfed8e7968e9def8e27815d652d0072a832a901e7960d89173ba8cb1c9450507eb7129f6d82fac025f4fec4efb956ef13dc4145063534dcddc006382f016f49a64eb71818c97258f4e2489f1bb3d1029148e0d830b5a1399daff1084048e7bd8dbe9f8591b8ffe6224eb2dcd8c0558731a23be68b7f64292a77e9b76889a44264468fff3000000000000000000000000000000000000000000000000000000000000000006ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a90306466fe5211732ffecadba72c39be7bc8ce5bbc5f7126b2c439b3a40000000069b8857feab8184fb687f634618c035dac439dc1aeb3b5598a0f00000000001ca4d39964c9cb5f9790d0a12969f60fd9724936284ea4a12daded42ddfa69c5d0479d52dedbf6bc5ecd09d84534a34aea5975043b36fd02b24650bb58443595c973c265a4390cf341062b67c0c2df7225807028c17a4006a4cfea9e5cfebe53f0706060001071e080901010a000502c05c15000a000903d8d600000000000006060002000b0809010106060003000c080901010d280900041b091c1d00050e0f0210111b091f20000212130314152122160003041718191a092324250126e517cb977ae3ad2a0003000000020302030219a086010000000000054000000000000032004b0903020000010903fe234c2bed04b83d2bc2e13d5320d2c0e31393816adb2d0bca769afbeb0bea1004c6c8c4c30304c5c2ac6488e2949297db40612a5f2340f0bc6a1c476982accc1a20b032e4d99c04fa048e8b898a031d8f8dd64fd4ba4db1bd148b9135fd8024bc94a40d9849e774d871cb2d366ae6a0265205b7b5bfbeb60564bca2bbba").unwrap();
- let pubkey = "e671e524ef43ccc5ef0006876f9a2fd66681d5abc5871136b343a3e4b073efde".to_string();
let parsed = parse(&buffer);
assert_eq!(true, parsed.is_ok())
}
### rust/apps/solana/src/message.rs
@@ -239,7 +239,7 @@ impl Message {
// parse instruction data
match instruction.parse(&program_account, instruction_accounts.clone()) {
Ok(value) => Ok(value),
- Err(_) => Ok(SolanaDetail {
+ Err(SolanaError::UnsupportedProgram(_)) => Ok(SolanaDetail {
common: CommonDetail {
program: "Unknown".to_string(),
method: "".to_string(),
@@ -250,6 +250,7 @@ impl Message {
program_account,
}),
}),
+ Err(error) => Err(error),
}
})
.collect::<Result<Vec<SolanaDetail>>>()?;
@@ -259,6 +260,37 @@ impl Message {
Ok(details)
}
+ pub fn to_raw_program_details(&self) -> Result<Vec<SolanaDetail>> {
+ let accounts = self.prepare_accounts();
+ self.instructions
+ .iter()
+ .map(|instruction| {
+ let account_at = |index: u8| {
+ accounts.get(index as usize).cloned().ok_or_else(|| {
+ SolanaError::InvalidData(
+ "instruction account index exceeds account list".to_string(),
+ )
+ })
+ };
+ Ok(SolanaDetail {
+ common: CommonDetail {
+ program: "Unknown".to_string(),
+ method: String::new(),
+ },
+ kind: ProgramDetail::Instruction(ProgramDetailInstruction {
+ data: base58::encode(&instruction.data),
+ accounts: instruction
+ .account_indexes
+ .iter()
+ .map(|index| account_at(*index))
+ .collect::<Result<Vec<_>>>()?,
+ program_account: account_at(instruction.program_index)?,
+ }),
+ })
+ })
+ .collect()
+ }
+
pub fn validate(raw: &mut Vec<u8>) -> bool {
Self::read_exact(raw).is_ok()
}
@@ -358,7 +390,11 @@ mod tests {
use alloc::vec;
use alloc::vec::Vec;
- use super::Message;
+ use crate::errors::SolanaError;
+ use crate::instruction::Instruction;
+ use crate::parser::detail::ProgramDetail;
+
+ use super::{Account, BlockHash, Message, MessageHeader};
fn minimal_legacy_message() -> Vec<u8> {
let mut message = vec![1, 0, 0, 1];
@@ -384,6 +420,30 @@ mod tests {
message
}
+ fn single_instruction_message(program_id: &str, data: Vec<u8>) -> Message {
+ Message {
+ transaction_config: None,
+ is_versioned: false,
+ header: MessageHeader {
+ num_required_signatures: 0,
+ num_readonly_signed_accounts: 0,
+ num_readonly_unsigned_accounts: 1,
+ },
+ accounts: vec![Account {
+ value: bitcoin::base58::decode(program_id).unwrap(),
+ }],
+ block_hash: BlockHash {
+ value: vec![0u8; 32],
+ },
+ instructions: vec![Instruction {
+ program_index: 0,
+ account_indexes: vec![],
+ data,
+ }],
+ address_table_lookups: None,
+ }
+ }
+
#[test]
fn exact_parser_rejects_trailing_bytes() {
let mut message = minimal_legacy_message();
@@ -415,4 +475,44 @@ mod tests {
assert_eq!(details[0].common.program, "System");
assert_eq!(details[0].common.method, "Transfer");
}
+
+ #[test]
+ fn rejects_malformed_known_programs_but_preserves_unknown_programs() {
+ let malformed_jupiter =
+ single_instruction_message("JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4", vec![0u8; 7]);
+ assert!(matches!(
+ malformed_jupiter.to_program_details(),
+ Err(SolanaError::InvalidData(_))
+ ));
+
+ let malformed_token =
+ single_instruction_message("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", vec![0xff]);
+ assert!(malformed_token.to_program_details().is_err());
+
+ let unknown =
+ single_instruction_message("11111111111111111111111111111112", vec![0xaa, 0xbb]);
+ let details = unknown.to_program_details().unwrap();
+ assert!(matches!(details[0].kind, ProgramDetail::Instruction(_)));
+ assert_eq!(details[0].common.program, "Unknown");
+ }
+
+ #[test]
+ fn rejects_malformed_supported_instructions_but_keeps_unknown_programs() {
+ let mut malformed_token = system_transfer_message();
+ let token_program =
+ bitcoin::base58::decode("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA").unwrap();
+ malformed_token[68..100].copy_from_slice(&token_program);
+ malformed_token[137] = 1;
+ malformed_token[138] = 12;
+ malformed_token.truncate(139);
+ let message = Message::read_exact(&mut malformed_token).unwrap();
+ assert!(message.to_program_details().is_err());
+
+ let mut unknown_program = system_transfer_message();
+ unknown_program[68..100].copy_from_slice(&[0x33; 32]);
+ let message = Message::read_exact(&mut unknown_program).unwrap();
+ let details = message.to_program_details().unwrap();
+ assert_eq!(details.len(), 1);
+ assert_eq!(details[0].common.program, "Unknown");
+ }
}
### rust/apps/solana/src/message_json.rs
@@ -0,0 +1,207 @@
+use alloc::{string::String, vec::Vec};
+use bitcoin::base58;
+use serde_json::{json, Value};
+
+use crate::{errors::Result, message::Message};
+
+impl Message {
+ pub(crate) fn to_message_json(&self) -> Result<String> {
+ let header = json!({
+ "num_required_signatures": self.header.num_required_signatures,
+ "num_readonly_signed_accounts": self.header.num_readonly_signed_accounts,
+ "num_readonly_unsigned_accounts": self.header.num_readonly_unsigned_accounts,
+ });
+ let addresses: Vec<String> = self
+ .accounts
+ .iter()
+ .map(|a| base58::encode(&a.value))
+ .collect();
+ let blockhash = base58::encode(&self.block_hash.value);
+ let value = if let Some(config) = &self.transaction_config {
+ let mut words = Vec::<u32>::new();
+ if config.mask & 3 == 3 {
+ words.push(config.priority_fee_lamports as u32);
+ words.push((config.priority_fee_lamports >> 32) as u32);
+ }
+ if config.mask & 4 != 0 {
+ words.push(config.compute_unit_limit);
+ }
+ if config.mask & 8 != 0 {
+ words.push(config.loaded_accounts_data_size_limit);
+ }
+ if config.mask & 16 != 0 {
+ words.push(config.heap_frame_bytes);
+ }
+ json!({
+ "version": 1,
+ "version_byte": 129,
+ "header": header,
+ "transaction_config_mask": config.mask,
+ "lifetime_specifier": blockhash,
+ "num_instructions": self.instructions.len(),
+ "num_addresses": addresses.len(),
+ "addresses": addresses,
+ "config_values": words,
+ "instruction_data_encoding": "base58",
+ "instruction_headers": self.instructions.iter().map(|i| json!({
+ "program_account_index": i.program_index,
+ "num_instruction_accounts": i.account_indexes.len(),
+ "num_instruction_data_bytes": i.data.len(),
+ })).collect::<Vec<Value>>(),
+ "instruction_payloads": self.instructions.iter().map(|i| json!({
+ "instruction_account_indexes": i.account_indexes,
+ "instruction_data": base58::encode(&i.data),
+ })).collect::<Vec<Value>>(),
+ })
+ } else {
+ let mut value = json!({
+ "version": if self.is_versioned { json!(0) } else { json!("legacy") },
+ "header": header,
+ "account_keys": addresses,
+ "recent_blockhash": blockhash,
+ "instruction_data_encoding": "base58",
+ "instructions": self.instructions.iter().map(|i| json!({
+ "program_id_index": i.program_index,
+ "accounts": i.account_indexes,
+ "data": base58::encode(&i.data),
+ })).collect::<Vec<Value>>(),
+ });
+ if let Some(lookups) = &self.address_table_lookups {
+ value["version_byte"] = json!(128);
+ value["address_table_lookups"] = json!(lookups
+ .iter()
+ .map(|lookup| json!({
+ "account_key": base58::encode(&lookup.account_key.value),
+ "writable_indexes": lookup.writable_indexes,
+ "readonly_indexes": lookup.readonly_indexes,
+ }))
+ .collect::<Vec<Value>>());
+ }
+ value
+ };
+ Ok(serde_json::to_string_pretty(&value)?)
+ }
+}
+
+#[cfg(test)]
+pub(crate) mod tests {
+ use super::*;
+
+ fn number(value: &Value) -> u64 {
+ value.as_u64().unwrap()
+ }
+ fn byte(value: &Value) -> u8 {
+ number(value).try_into().unwrap()
+ }
+ fn bytes(value: &Value) -> Vec<u8> {
+ value.as_array().unwrap().iter().map(byte).collect()
+ }
+ fn decode(value: &Value) -> Vec<u8> {
+ base58::decode(value.as_str().unwrap()).unwrap()
+ }
+ fn shortvec(out: &mut Vec<u8>, mut length: usize) {
+ loop {
+ let mut next = (length & 127) as u8;
+ length >>= 7;
+ if length != 0 {
+ next |= 128;
+ }
+ out.push(next);
+ if length == 0 {
+ break;
+ }
+ }
+ }
+
+ pub(crate) fn assert_json_roundtrip(original: &[u8], rendered: &str) {
+ let v: Value = serde_json::from_str(rendered).unwrap();
+ let mut out = Vec::new();
+ if v["version"] != "legacy" {
+ out.push(byte(&v["version_byte"]));
+ }
+ for key in [
+ "num_required_signatures",
+ "num_readonly_signed_accounts",
+ "num_readonly_unsigned_accounts",
+ ] {
+ out.push(byte(&v["header"][key]));
+ }
+ assert_eq!(v["instruction_data_encoding"], "base58");
+ if v["version"] == 1 {
+ let mask: u32 = number(&v["transaction_config_mask"]).try_into().unwrap();
+ out.extend(mask.to_le_bytes());
+ out.extend(decode(&v["lifetime_specifier"]));
+ out.push(byte(&v["num_instructions"]));
+ out.push(byte(&v["num_addresses"]));
+ let addresses = v["addresses"].as_array().unwrap();
+ assert_eq!(addresses.len(), number(&v["num_addresses"]) as usize);
+ for address in addresses {
+ out.extend(decode(address));
+ }
+ let words = v["config_values"].as_array().unwrap();
+ assert_eq!(words.len(), mask.count_ones() as usize);
+ for word in words {
+ let word: u32 = number(word).try_into().unwrap();
+ out.extend(word.to_le_bytes());
+ }
+ let headers = v["instruction_headers"].as_array().unwrap();
+ let payloads = v["instruction_payloads"].as_array().unwrap();
+ assert_eq!(headers.len(), number(&v["num_instructions"]) as usize);
+ assert_eq!(headers.len(), payloads.len());
+ for h in headers {
+ out.push(byte(&h["program_account_index"]));
+ out.push(byte(&h["num_instruction_accounts"]));
+ let length: u16 = number(&h["num_instruction_data_bytes"]).try_into().unwrap();
+ out.extend(length.to_le_bytes());
+ }
+ for (h, p) in headers.iter().zip(payloads) {
+ let accounts = bytes(&p["instruction_account_indexes"]);
+ let data = decode(&p["instruction_data"]);
+ assert_eq!(
+ accounts.len(),
+ number(&h["num_instruction_accounts"]) as usize
+ );
+ assert_eq!(
+ data.len(),
+ number(&h["num_instruction_data_bytes"]) as usize
+ );
+ out.extend(accounts);
+ out.extend(data);
+ }
+ } else {
+ let accounts = v["account_keys"].as_array().unwrap();
+ shortvec(&mut out, accounts.len());
+ for account in accounts {
+ out.extend(decode(account));
+ }
+ out.extend(decode(&v["recent_blockhash"]));
+ let instructions = v["instructions"].as_array().unwrap();
+ shortvec(&mut out, instructions.len());
+ for i in instructions {
+ out.push(byte(&i["program_id_index"]));
+ let accounts = bytes(&i["accounts"]);
+ shortvec(&mut out, accounts.len());
+ out.extend(accounts);
+ let data = decode(&i["data"]);
+ shortvec(&mut out, data.len());
+ out.extend(data);
+ }
+ if v["version"] == 0 {
+ let lookups = v["address_table_lookups"].as_array().unwrap();
+ shortvec(&mut out, lookups.len());
+ for lookup in lookups {
+ out.extend(decode(&lookup["account_key"]));
+ for key in ["writable_indexes", "readonly_indexes"] {
+ let indexes = bytes(&lookup[key]);
+ shortvec(&mut out, indexes.len());
+ out.extend(indexes);
+ }
+ }
+ }
+ }
+ assert_eq!(
+ out, original,
+ "Details must preserve the signable message bytes"
+ );
+ }
+}
### rust/apps/solana/src/message_v1.rs
@@ -11,6 +11,7 @@ use crate::parser::detail::{
#[derive(Clone, Debug)]
pub struct TransactionConfig {
+ pub mask: u32,
pub priority_fee_lamports: u64,
pub compute_unit_limit: u32,
pub loaded_accounts_data_size_limit: u32,
@@ -108,6 +109,7 @@ impl Message {
0
};
let config = TransactionConfig {
+ mask,
priority_fee_lamports,
compute_unit_limit: if mask & 4 != 0 { cursor.u32()? } else { 0 },
loaded_accounts_data_size_limit: if mask & 8 != 0 { cursor.u32()? } else { 0 },
@@ -159,7 +161,7 @@ impl Message {
#[cfg(test)]
mod tests {
use super::*;
- use crate::{classify_payload, parse, parse_for_signer, read::Read, SolanaPayloadType};
+ use crate::{classify_payload, parse, parse_for_signer, SolanaPayloadType};
use alloc::vec;
fn encode(
@@ -204,13 +206,69 @@ mod tests {
encode(0, &[], &[[1; 32], [2; 32], [0; 32]], &[transfer()])
}
+ #[test]
+ fn raw_squads_review_preserves_message_config() {
+ use crate::parser::overview::SolanaOverview;
+ let squads: [u8; 32] =
+ bitcoin::base58::decode("SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf")
+ .unwrap()
+ .try_into()
+ .unwrap();
+ let activate = Instruction {
+ program_index: 3,
+ account_indexes: vec![],
+ data: hex::decode("0b225cf89a1b336a").unwrap(),
+ };
+ for mask in [0u32, 31] {
+ let mut config = Vec::new();
+ if mask != 0 {
+ config.extend(123456789u64.to_le_bytes());
+ config.extend(200000u32.to_le_bytes());
+ config.extend(65536u32.to_le_bytes());
+ config.extend(65536u32.to_le_bytes());
+ }
+ let instructions = [activate.clone(), transfer()];
+ let raw = encode(
+ mask,
+ &config,
+ &[[1; 32], [2; 32], [0; 32], squads],
+ &instructions,
+ );
+ let parsed = parse(&raw).unwrap();
+ let SolanaOverview::Instructions(overview) = &parsed.overview else {
+ panic!("Squads with a transfer must retain raw review");
+ };
+ assert_eq!(overview.overview_instructions.len(), instructions.len());
+ for (shown, original) in overview.overview_instructions.iter().zip(&instructions) {
+ assert_eq!(shown.data, bitcoin::base58::encode(&original.data));
+ }
+ assert!(parsed.overview_order.is_empty());
+ assert_eq!(parsed.additional_overviews.len(), 1);
+ let metadata = &parsed.additional_overviews[0];
+ assert_eq!(metadata.program, "TransactionConfig");
+ assert_eq!(metadata.instruction_index, 0);
+ let expected = if mask == 0 {
+ "Priority Fee: 0 lamports"
+ } else {
+ "Priority Fee: 123456789 lamports"
+ };
+ assert!(metadata.memo.contains(expected));
+ if mask != 0 {
+ assert!(metadata.memo.contains("200000"));
+ assert!(metadata.memo.contains("65536"));
+ }
+ crate::message_json::tests::assert_json_roundtrip(&raw, &parsed.detail);
+ }
+ }
+
#[test]
fn transfer_and_defaults_are_reviewed() {
let raw = sample();
assert_eq!(classify_payload(&raw), SolanaPayloadType::Transaction);
let parsed = parse_for_signer(&raw, &[1; 32]).unwrap();
assert_eq!(parsed.display_type.to_string(), "Transfer");
- assert!(parsed.detail.contains("0.123456789 SOL"));
+ assert!(!parsed.detail.contains("0.123456789 SOL"));
+ crate::message_json::tests::assert_json_roundtrip(&raw, &parsed.detail);
let config = &parsed.additional_overviews[0];
assert_eq!(config.instruction_index, 0);
assert!(config.memo.contains("Priority Fee: 0 lamports"));
@@ -219,6 +277,57 @@ mod tests {
assert!(parse_for_signer(&raw, &[9; 32]).is_err());
}
+ #[test]
+ fn security_review_preserves_v1_instruction_order_and_metadata() {
+ use crate::parser::structs::OverviewAction;
+ let unknown = Instruction {
+ program_index: 3,
+ account_indexes: vec![0],
+ data: vec![42],
+ };
+ for unknown_first in [true, false] {
+ let instructions = if unknown_first {
+ vec![unknown.clone(), transfer()]
+ } else {
+ vec![transfer(), unknown.clone()]
+ };
+ let raw = encode(
+ 3,
+ &5000u64.to_le_bytes(),
+ &[[1; 32], [2; 32], [0; 32], [3; 32]],
+ &instructions,
+ );
+ let parsed = parse_for_signer(&raw, &[1; 32]).unwrap();
+ let expected = if unknown_first {
+ vec![
+ (1, OverviewAction::Unknown(0)),
+ (2, OverviewAction::Primary),
+ (0, OverviewAction::General(0)),
+ ]
+ } else {
+ vec![
+ (1, OverviewAction::Primary),
+ (2, OverviewAction::Unknown(0)),
+ (0, OverviewAction::General(0)),
+ ]
+ };
+ assert_eq!(parsed.overview_order, expected);
+ assert!(parsed.additional_overviews[0]
+ .memo
+ .contains("5000 lamports"));
+ assert_eq!(parsed.unknown_programs.len(), 1);
+ }
+ }
+
+ #[test]
+ fn security_parser_rejects_v1_known_instruction_trailing_data() {
+ let mut malformed = transfer();
+ malformed.data.push(0);
+ let raw = encode(0, &[], &[[1; 32], [2; 32], [0; 32]], &[malformed]);
+ assert!(Message::read_exact(&mut raw.clone()).is_ok());
+ assert!(parse_for_signer(&raw, &[1; 32]).is_err());
+ }
+
#[test]
fn every_config_mask_and_full_u64_fee() {
for mask in 0u32..32 {
@@ -239,7 +348,12 @@ mod tests {
values.extend(65536u32.to_le_bytes());
}
let mut raw = encode(mask, &values, &[[1; 32], [2; 32], [0; 32]], &[transfer()]);
+ let original = raw.clone();
let message = Message::read_exact(&mut raw).unwrap();
+ crate::message_json::tests::assert_json_roundtrip(
+ &original,
+ &message.to_message_json().unwrap(),
+ );
let config = message.transaction_config.unwrap();
assert_eq!(
config.priority_fee_lamports,
@@ -287,9 +401,11 @@ mod tests {
],
);
let parsed = parse(&raw).unwrap();
- assert!(parsed.detail.contains("IgnoredInV1"));
+ assert!(!parsed.detail.contains("IgnoredInV1"));
+ crate::message_json::tests::assert_json_roundtrip(&raw, &parsed.detail);
assert!(!parsed.detail.contains("compute_unit_price_micro_lamports"));
- assert!(parsed.detail.contains("\"priority_fee_lamports\":\"42\""));
+ let detail: serde_json::Value = serde_json::from_str(&parsed.detail).unwrap();
+ assert_eq!(detail["config_values"], serde_json::json!([42, 0]));
let message = Message::read_exact(&mut raw.clone()).unwrap();
assert_eq!(message.instructions[0].data, message.instructions[2].data);
}
@@ -363,6 +479,9 @@ mod tests {
assert_eq!(Message::read_exact(&mut raw.clone()).is_ok(), valid);
if !valid {
rejected(&raw);
+ } else {
+ let parsed = parse(&raw).unwrap();
+ crate::message_json::tests::assert_json_roundtrip(&raw, &parsed.detail);
}
}
}
### rust/apps/solana/src/parser/detail.rs
@@ -1,7 +1,7 @@
use alloc::string::{String, ToString};
use alloc::vec::Vec;
-use serde::ser::SerializeStruct;
+use serde::ser::{SerializeSeq, SerializeStruct};
use serde::{Serialize, Serializer};
use crate::solana_lib::jupiter_v6::instructions::{
@@ -17,17 +17,62 @@ use crate::solana_lib::spl::token_swap::instruction::{
WithdrawAllTokenTypes, WithdrawSingleTokenTypeExactAmountOut,
};
use crate::solana_lib::squads_v4::instructions::{
- MultisigCreateArgs, MultisigCreateArgsV2, ProposalCreateArgs, ProposalVoteArgs,
- VaultTransactionCreateArgs,
+ ConfigTransactionCreateArgs, MultisigCreateArgs, MultisigCreateArgsV2, ProposalCreateArgs,
+ ProposalVoteArgs, VaultTransactionCreateArgs,
};
+#[derive(Debug, Clone, Serialize)]
+pub struct ProgramDetailSquadsConfigTransactionCreate {
+ pub multisig: String,
+ pub creator: String,
+ #[serde(flatten)]
+ pub args: ConfigTransactionCreateArgs,
+}
+
#[derive(Debug, Clone, Default, Serialize)]
pub struct ProgramDetailSystemTransfer {
pub value: String,
+ #[serde(serialize_with = "serialize_account_reference")]
pub from: String,
+ #[serde(serialize_with = "serialize_account_reference")]
pub to: String,
}
+fn serialize_account_reference<S: Serializer>(
+ account: &String,
+ serializer: S,
+) -> core::result::Result<S::Ok, S::Error> {
+ if let Some((table, index)) = account.split_once('#') {
+ if let Ok(index) = index.parse::<u8>() {
+ if !table.is_empty() {
+ let mut reference = serializer.serialize_struct("AltReference", 3)?;
+ reference.serialize_field("Table", table)?;
+ reference.serialize_field("Index", &index)?;
+ reference.serialize_field("Status", "Unresolved offline")?;
+ return reference.end();
+ }
+ }
+ }
+ serializer.serialize_str(account)
+}
+
+fn serialize_account_references<S: Serializer>(
+ accounts: &Vec<String>,
+ serializer: S,
+) -> core::result::Result<S::Ok, S::Error> {
+ struct Account<'a>(&'a String);
+ impl Serialize for Account<'_> {
+ fn serialize<S: Serializer>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error> {
+ serialize_account_reference(self.0, serializer)
+ }
+ }
+ let mut seq = serializer.serialize_seq(Some(accounts.len()))?;
+ for account in accounts {
+ seq.serialize_element(&Account(account))?;
+ }
+ seq.end()
+}
+
#[derive(Debug, Clone, Default, Serialize)]
pub struct ProgramDetailComputeBudget {
#[serde(skip_serializing_if = "String::is_empty")]
@@ -1054,7 +1099,9 @@ pub struct ProgramDetailUnknown {
#[derive(Debug, Clone, Default, Serialize)]
pub struct ProgramDetailInstruction {
pub data: String,
+ #[serde(serialize_with = "serialize_account_references")]
pub accounts: Vec<String>,
+ #[serde(serialize_with = "serialize_account_reference")]
pub program_account: String,
}
@@ -1216,6 +1263,7 @@ pub enum ProgramDetail {
StakeDeactivateDelinquent(ProgramDetailStakeDeactivateDelinquent),
// squads v4
+ SquadsV4ConfigTransactionCreate(ProgramDetailSquadsConfigTransactionCreate),
SquadsV4MultisigCreate(MultisigCreateArgs),
SquadsV4MultisigCreateV2(MultisigCreateArgsV2),
SquadsV4ProposalActivate,
### rust/apps/solana/src/parser/mod.rs
@@ -2,23 +2,24 @@ use alloc::borrow::ToOwned;
use alloc::format;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
+#[cfg(test)]
use bitcoin::base58;
+#[cfg(test)]
use serde_json::json;
use crate::errors::{Result, SolanaError};
use crate::message::Message;
-use crate::parser::detail::{
- CommonDetail, ProgramDetail, ProgramDetailGeneralUnknown, SolanaDetail,
-};
+#[cfg(test)]
+use crate::parser::detail::ProgramDetailGeneralUnknown;
+use crate::parser::detail::{CommonDetail, ProgramDetail, SolanaDetail};
use crate::parser::overview::{
JupiterV6SwapOverview, JupiterV6SwapTokenInfoOverview, ProgramOverviewGeneral,
ProgramOverviewInstruction, ProgramOverviewInstructions, ProgramOverviewMultisigCreate,
ProgramOverviewProposal, ProgramOverviewSplTokenTransfer, ProgramOverviewTransfer,
ProgramOverviewVote, SolanaOverview,
};
-use crate::parser::structs::{ParsedSolanaTx, SolanaTxDisplayType};
-use crate::read::Read;
+use crate::parser::structs::{OverviewAction, ParsedSolanaTx, SolanaTxDisplayType};
use crate::utils;
pub mod detail;
@@ -56,20 +57,122 @@ impl ParsedSolanaTx {
message.validate_signer(signer)?;
}
let raw_details = message.to_program_details()?;
- let display_type = Self::detect_display_type(&raw_details);
- let parsed_overview = Self::build_overview(&display_type, &raw_details)?;
+ let has_unresolved_lookups = message
+ .address_table_lookups
+ .as_ref()
+ .map(|lookups| !lookups.is_empty())
+ .unwrap_or(false);
+ let alt_transfer_supported = matches!(raw_details.as_slice(), [SolanaDetail {
+ kind: ProgramDetail::SystemTransfer(transfer), ..
+ }] if !Self::is_lookup_table_reference(&transfer.from)
+ && Self::is_lookup_table_reference(&transfer.to));
+ let display_type = if has_unresolved_lookups && !alt_transfer_supported {
+ SolanaTxDisplayType::Unknown
+ } else {
+ Self::detect_display_type(&raw_details)
+ };
+ let mut parsed_overview = Self::build_overview(&display_type, &raw_details)?;
+ if matches!(parsed_overview, SolanaOverview::Instructions(_)) {
+ parsed_overview =
+ Self::build_instructions_overview(&message.to_raw_program_details()?)?;
+ }
let additional_overviews = Self::build_additional_overviews(&display_type, &raw_details)?;
let unknown_programs = Self::collect_additional_unknown_programs(&raw_details);
- let parsed_detail = Self::build_detail(&display_type, &raw_details, &message)?;
+ let parsed_detail = Self::compact_byte_arrays(&message.to_message_json()?);
+ let overview_order = Self::build_overview_order(&display_type, &raw_details);
Ok(Self {
display_type,
overview: parsed_overview,
additional_overviews,
unknown_programs,
+ overview_order,
detail: parsed_detail,
- network: "Solana Mainnet".to_string(),
+ advanced: message.advanced_review(signer),
+ network: "Solana / Cluster not encoded".to_string(),
})
}
+ fn compact_byte_arrays(json: &str) -> String {
+ let bytes = json.as_bytes();
+ let mut output = String::with_capacity(json.len());
+ let (mut cursor, mut copied, mut quoted, mut escaped) = (0, 0, false, false);
+ while cursor < bytes.len() {
+ let byte = bytes[cursor];
+ if quoted {
+ if escaped {
+ escaped = false;
+ } else if byte == b'\\' {
+ escaped = true;
+ } else if byte == b'"' {
+ quoted = false;
+ }
+ } else if byte == b'"' {
+ quoted = true;
+ } else if byte == b'[' {
+ let mut end = cursor + 1;
+ while end < bytes.len()
+ && (bytes[end].is_ascii_whitespace()
+ || bytes[end].is_ascii_digit()
+ || bytes[end] == b',')
+ {
+ end += 1;
+ }
+ if end < bytes.len() && bytes[end] == b']' {
+ if let Ok(values) = serde_json::from_str::<Vec<u8>>(&json[cursor..=end]) {
+ output.push_str(&json[copied..cursor]);
+ output.push('[');
+ for (index, value) in values.iter().enumerate() {
+ if index > 0 {
+ output.push_str(", ");
+ }
+ output.push_str(&value.to_string());
+ }
+ output.push(']');
+ cursor = end + 1;
+ copied = cursor;
+ continue;
+ }
+ }
+ }
+ cursor += 1;
+ }
+ output.push_str(&json[copied..]);
+ output
+ }
+
+ fn build_overview_order(
+ display_type: &SolanaTxDisplayType,
+ details: &[SolanaDetail],
+ ) -> Vec<(usize, OverviewAction)> {
+ if matches!(display_type, SolanaTxDisplayType::Unknown) {
+ return Vec::new();
+ }
+ let mut order = Vec::new();
+ let (mut general, mut unknown, mut primary_added) = (0, 0, false);
+ for (index, detail) in details.iter().enumerate() {
+ let action = if Self::is_unknown_detail(&detail.common) {
+ let action = OverviewAction::Unknown(unknown);
+ unknown += 1;
+ action
+ } else if Self::is_represented_by_primary_overview(display_type, detail) {
+ if primary_added {
+ continue;
+ }
+ primary_added = true;
+ OverviewAction::Primary
+ } else {
+ let action = OverviewAction::General(general);
+ general += 1;
+ action
+ };
+ let ordinal = if detail.common.program == "TransactionConfig" {
+ 0
+ } else {
+ index + 1
+ };
+ order.push((ordinal, action));
+ }
+ order
+ }
// detect the display type by the details vec contains number of details
fn detect_display_type(details: &[SolanaDetail]) -> SolanaTxDisplayType {
let unknown_count = details
@@ -79,11 +182,44 @@ impl ParsedSolanaTx {
if unknown_count == details.len() {
return SolanaTxDisplayType::Unknown;
}
+ if details
+ .iter()
+ .any(|d| matches!(d.kind, ProgramDetail::SquadsV4ConfigTransactionCreate(_)))
+ {
+ return if details.iter().all(Self::can_fully_review_config_sibling) {
+ SolanaTxDisplayType::General
+ } else {
+ SolanaTxDisplayType::Unknown
+ };
+ }
let squads = details
.iter()
.filter(|d| Self::is_sqauds_v4_detail(&d.common))
.collect::<Vec<&SolanaDetail>>();
if !squads.is_empty() {
+ if details.iter().any(|d| {
+ Self::is_system_transfer_detail(&d.common)
+ || matches!(
+ d.kind,
+ ProgramDetail::SquadsV4MultisigCreate(_)
+ | ProgramDetail::SquadsV4MultisigCreateV2(_)
+ )
+ }) {
+ return SolanaTxDisplayType::Unknown;
+ }
+ let mut primary_seen = false;
+ let mut group_ended = false;
+ for detail in details {
+ if Self::is_represented_by_primary_overview(&SolanaTxDisplayType::SquadsV4, detail)
+ {
+ if group_ended {
+ return SolanaTxDisplayType::Unknown;
+ }
+ primary_seen = true;
+ } else if primary_seen {
+ group_ended = true;
+ }
+ }
return SolanaTxDisplayType::SquadsV4;
}
@@ -131,6 +267,20 @@ impl ParsedSolanaTx {
common.program.eq("System") && common.method.eq("Transfer")
}
+ fn can_fully_review_config_sibling(detail: &SolanaDetail) -> bool {
+ match &detail.kind {
+ ProgramDetail::SquadsV4ConfigTransactionCreate(_)
+ | ProgramDetail::SystemTransfer(_) => true,
+ ProgramDetail::TokenTransfer(value) => {
+ value.signers.as_ref().map_or(true, Vec::is_empty)
+ }
+ ProgramDetail::TokenTransferChecked(value) => {
+ value.signers.as_ref().map_or(true, Vec::is_empty)
+ }
+ _ => false,
+ }
+ }
+
fn is_token_transfer_detail(common: &CommonDetail) -> bool {
common.program.eq("Token")
&& (common.method.eq("TransferChecked") || common.method.eq("Transfer"))
@@ -158,6 +308,7 @@ impl ParsedSolanaTx {
fn is_jupiter_v6_detail(common: &CommonDetail) -> bool {
common.program.eq("JupiterV6")
}
+ #[cfg(test)]
fn build_genera_detail(details: &[SolanaDetail]) -> Result<String> {
let parsed_detail = details
.iter()
@@ -175,23 +326,25 @@ impl ParsedSolanaTx {
d.clone()
})
.collect::<Vec<SolanaDetail>>();
- Ok(serde_json::to_string(&parsed_detail)?)
+ Ok(serde_json::to_string_pretty(&parsed_detail)?)
}
+ #[cfg(test)]
fn build_unknown_detail(details: &[SolanaDetail], message: &Message) -> Result<String> {
let value = json!({
- "header": {
- "num_required_signatures": message.header.num_required_signatures,
- "num_readonly_signed_accounts": message.header.num_readonly_signed_accounts,
- "num_readonly_unsigned_accounts": message.header.num_readonly_unsigned_accounts,
- },
- "accounts": message.accounts.iter().map(|account| {base58::encode(&account.value)}).collect::<Vec<String>>(),
- "block_hash": base58::encode(&message.block_hash.value),
- "instructions": details,
- }).to_string();
- Ok(value)
+ "header": {
+ "num_required_signatures": message.header.num_required_signatures,
+ "num_readonly_signed_accounts": message.header.num_readonly_signed_accounts,
+ "num_readonly_unsigned_accounts": message.header.num_readonly_unsigned_accounts,
+ },
+ "accounts": message.accounts.iter().map(|account| {base58::encode(&account.value)}).collect::<Vec<String>>(),
+ "block_hash": base58::encode(&message.block_hash.value),
+ "instructions": details,
+ });
+ Ok(serde_json::to_string_pretty(&value)?)
}
+ #[cfg(test)]
fn build_detail(
display_type: &SolanaTxDisplayType,
details: &[SolanaDetail],
@@ -201,11 +354,11 @@ impl ParsedSolanaTx {
SolanaTxDisplayType::Unknown => Self::build_unknown_detail(details, message),
SolanaTxDisplayType::General => Self::build_genera_detail(details),
SolanaTxDisplayType::Transfer | SolanaTxDisplayType::Vote => {
- Ok(serde_json::to_string(&details)?)
+ Ok(serde_json::to_string_pretty(&details)?)
}
- SolanaTxDisplayType::SquadsV4 => Ok(serde_json::to_string(&details)?),
- SolanaTxDisplayType::TokenTransfer => Ok(serde_json::to_string(&details)?),
- SolanaTxDisplayType::JupiterV6 => Ok(serde_json::to_string(&details)?),
+ SolanaTxDisplayType::SquadsV4 => Ok(serde_json::to_string_pretty(&details)?),
+ SolanaTxDisplayType::TokenTransfer => Ok(serde_json::to_string_pretty(&details)?),
+ SolanaTxDisplayType::JupiterV6 => Ok(serde_json::to_string_pretty(&details)?),
}
}
@@ -545,6 +698,12 @@ impl ParsedSolanaTx {
item.to_lookup_table_reference = value.to.clone();
}
}
+ ProgramDetail::TokenTransfer(value) => {
+ item.amount = format!("{} raw units", value.amount);
+ item.source = value.source_account.clone();
+ item.destination = value.recipient.clone();
+ item.authority = value.owner.clone();
+ }
ProgramDetail::TokenTransferChecked(value) => {
Self::validate_token_decimals(&value.mint, value.decimals)?;
let token_info = Self::find_token_info(&value.mint);
@@ -563,6 +722,9 @@ impl ParsedSolanaTx {
Self::has_unusual_token_decimals(&value.mint, value.decimals);
item.decimals = value.decimals;
}
+ ProgramDetail::SquadsV4ConfigTransactionCreate(value) => {
+ item.memo = serde_json::to_string_pretty(value)?;
+ }
ProgramDetail::SquadsV4VaultTransactionCreate(value) => {
item.memo = value.memo.clone().unwrap_or_default();
}
@@ -583,12 +745,17 @@ impl ParsedSolanaTx {
display_type: &SolanaTxDisplayType,
details: &[SolanaDetail],
) -> Result<Vec<ProgramOverviewGeneral>> {
- if matches!(
- display_type,
- SolanaTxDisplayType::General | SolanaTxDisplayType::Unknown
- ) {
+ if matches!(display_type, SolanaTxDisplayType::General) {
return Ok(Vec::new());
}
+ if matches!(display_type, SolanaTxDisplayType::Unknown) {
+ let config = details
+ .iter()
+ .filter(|detail| detail.common.program == "TransactionConfig")
+ .cloned()
+ .collect::<Vec<_>>();
+ return Self::build_general_items(&config, None);
+ }
Self::build_general_items(details, Some(display_type))
}
fn build_squads_v4_proposal_overview(details: &[SolanaDetail]) -> Result<SolanaOverview> {
@@ -803,6 +970,18 @@ impl ParsedSolanaTx {
account.contains("#")
}
+ fn format_basis_points(basis_points: u16) -> String {
+ let whole = basis_points / 100;
+ let fractional = basis_points % 100;
+ if fractional == 0 {
+ format!("{whole}%")
+ } else if fractional % 10 == 0 {
+ format!("{whole}.{}%", fractional / 10)
+ } else {
+ format!("{whole}.{fractional:02}%")
+ }
+ }
+
fn genreate_jupiter_swap_overview(
instruction_name: &str,
token_a_mint: &str,
@@ -814,12 +993,8 @@ impl ParsedSolanaTx {
) -> SolanaOverview {
let program_name = "Jupiter Aggregator v6";
let program_address = "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4";
- let base_percent = 10000;
- let slippage_bps = format!("{}%", (slippage_bps as f64 / base_percent as f64) * 100.0);
- let platform_fee_bps = format!(
- "{}%",
- (platform_fee_bps as f64 / base_percent as f64) * 100.0
- );
+ let slippage_bps = Self::format_basis_points(slippage_bps);
+ let platform_fee_bps = Self::format_basis_points(platform_fee_bps);
let token_a_mint = token_a_mint.to_string();
let token_b_mint = token_b_mint.to_string();
let token_a_overview = JupiterV6SwapTokenInfoOverview {
@@ -828,10 +1003,11 @@ impl ParsedSolanaTx {
token_address: token_a_mint.clone(),
token_amount: format!(
"{} {}",
- utils::token_amount_to_human_readable(
- in_amount,
- Self::find_token_info(&token_a_mint).2.into()
- ),
+ utils::format_token_amount(
+ &in_amount.to_string(),
+ Self::find_token_info(&token_a_mint).2
+ )
+ .unwrap_or_else(|_| in_amount.to_string()),
Self::find_token_info(&token_a_mint).0
),
exist_in_address_lookup_table: Self::is_account_exist_in_lookup_table(&token_a_mint),
@@ -842,10 +1018,11 @@ impl ParsedSolanaTx {
token_address: token_b_mint.clone(),
token_amount: format!(
"{} {}",
- utils::token_amount_to_human_readable(
- out_amount,
- Self::find_token_info(&token_b_mint).2.into()
- ),
+ utils::format_token_amount(
+ &out_amount.to_string(),
+ Self::find_token_info(&token_b_mint).2
+ )
+ .unwrap_or_else(|_| out_amount.to_string()),
Self::find_token_info(&token_b_mint).0
),
exist_in_address_lookup_table: Self::is_account_exist_in_lookup_table(&token_b_mint),
@@ -1071,11 +1248,24 @@ impl ParsedSolanaTx {
#[cfg(test)]
mod tests {
+ use crate::parser::detail::{
+ ProgramDetailSquadsConfigTransactionCreate, ProgramDetailTokenTransfer,
+ };
use hex::FromHex;
use serde_json::{json, Value};
use super::*;
+ fn semantic_detail_json(transaction: &[u8], display_type: &SolanaTxDisplayType) -> String {
+ let message = Message::read_exact(&mut transaction.to_vec()).unwrap();
+ ParsedSolanaTx::build_detail(
+ display_type,
+ &message.to_program_details().unwrap(),
+ &message,
+ )
+ .unwrap()
+ }
+
fn detail(program: &str, method: &str) -> SolanaDetail {
SolanaDetail {
common: CommonDetail {
@@ -1086,6 +1276,268 @@ mod tests {
}
}
+ fn config_detail_for_review_test() -> SolanaDetail {
+ use crate::solana_lib::squads_v4::instructions::{
+ ConfigAction, ConfigTransactionCreateArgs,
+ };
+ SolanaDetail {
+ common: CommonDetail {
+ program: "SquadsV4".to_string(),
+ method: "ConfigTransactionCreate".to_string(),
+ },
+ kind: ProgramDetail::SquadsV4ConfigTransactionCreate(
+ ProgramDetailSquadsConfigTransactionCreate {
+ multisig: "multisig".to_string(),
+ creator: "creator".to_string(),
+ args: ConfigTransactionCreateArgs {
+ actions: vec![ConfigAction::ChangeThreshold { new_threshold: 3 }],
+ memo: None,
+ },
+ },
+ ),
+ }
+ }
+
+ #[test]
+ fn config_with_plain_token_transfer_discloses_all_authorization_fields() {
+ let transfer = SolanaDetail {
+ common: CommonDetail {
+ program: "Token".to_string(),
+ method: "Transfer".to_string(),
+ },
+ kind: ProgramDetail::TokenTransfer(ProgramDetailTokenTransfer {
+ source_account: "source".to_string(),
+ recipient: "destination".to_string(),
+ owner: "authority".to_string(),
+ amount: "9007199254740993".to_string(),
+ signers: None,
+ }),
+ };
+ let details = vec![config_detail_for_review_test(), transfer.clone()];
+ assert!(matches!(
+ ParsedSolanaTx::detect_display_type(&details),
+ SolanaTxDisplayType::General
+ ));
+ let items = ParsedSolanaTx::build_general_items(&details, None).unwrap();
+ assert_eq!(items[1].amount, "9007199254740993 raw units");
+ assert_eq!(items[1].source, "source");
+ assert_eq!(items[1].destination, "destination");
+ assert_eq!(items[1].authority, "authority");
+ assert!(items[1].mint.is_empty());
+ assert!(items[1].token.is_empty());
+ let mut multisig_transfer = transfer;
+ let ProgramDetail::TokenTransfer(value) = &mut multisig_transfer.kind else {
+ unreachable!()
+ };
+ value.signers = Some(vec!["extra signer".to_string()]);
+ assert!(matches!(
+ ParsedSolanaTx::detect_display_type(&[
+ config_detail_for_review_test(),
+ multisig_transfer
+ ]),
+ SolanaTxDisplayType::Unknown
+ ));
+ }
+
+ #[test]
+ fn config_preserves_raw_review_for_unrepresented_siblings() {
+ use crate::solana_lib::squads_v4::instructions::{
+ MultisigCreateArgs, MultisigCreateArgsV2,
+ };
+ for kind in [
+ ProgramDetail::SquadsV4MultisigCreate(MultisigCreateArgs::default()),
+ ProgramDetail::SquadsV4MultisigCreateV2(MultisigCreateArgsV2::default()),
+ ProgramDetail::SquadsV4ProposalActivate,
+ ] {
+ let sibling = SolanaDetail {
+ common: CommonDetail {
+ program: "SquadsV4".to_string(),
+ method: "sibling".to_string(),
+ },
+ kind,
+ };
+ assert!(matches!(
+ ParsedSolanaTx::detect_display_type(&[config_detail_for_review_test(), sibling]),
+ SolanaTxDisplayType::Unknown
+ ));
+ }
+ assert!(matches!(
+ ParsedSolanaTx::detect_display_type(&[config_detail_for_review_test()]),
+ SolanaTxDisplayType::General
+ ));
+ }
+
+ #[test]
+ fn rejects_overflow_reproducer_with_repeated_threshold_changes() {
+ let data = hex::decode(
+ include_str!("../../../../rust_c/tests/fixtures/solana-squads-overflow.hex").trim(),
+ )
+ .unwrap();
+ assert!(ParsedSolanaTx::build(&data).is_err());
+ }
+
+ #[test]
+ fn reviews_squads_config_transaction_request_in_full_order() {
+ let data = hex::decode("80010003082b8d8b3addd92759f55b840c2852f5bd50aee3552fe987ee0d4fe24b9043df8ebf971b59108b5b85a04fb093f1e21b4e3fd4c4c8f487dd09b95752769f0dd8c341af7426b48b8300268990b6aec6e1d41bf48e7f04732fb54865e8f1cf2be299e2394fff52100345b926b3fca49a43d059d27f6a771f1d39155eddfb0d114875afb04c998560a9ac7407ea3bf10c625824819009fabbfb33d95a3a271028b0f90306466fe5211732ffecadba72c39be7bc8ce5bbc5f7126b2c439b3a4000000000000000000000000000000000000000000000000000000000000000000000000681c4ce47e22368b8b1555ec887af092efc7efbb66ca3f52fbf68d4ac9cb7a80b0c6a879e5fe16bb69effc546043d750720867d2dc8f59fb8a143d2d0ec720605050009035c2c040000000000060200010c02000000a08601000000000007050203000006369bec57e4894b51270100000001902cce4c0210897aa154b0529cdf3759e940e07449f7176e4656ca468ace8fbf0104000000746573740705020400000611dc3c49e01e6c4f9f0200000000000000000703020004099025a488bcd82af80000").unwrap();
+ let parsed = ParsedSolanaTx::build(&data).unwrap();
+ assert!(matches!(parsed.display_type, SolanaTxDisplayType::Unknown));
+ let message = Message::read_exact(&mut data.clone()).unwrap();
+ let details = message.to_program_details().unwrap();
+ let items = ParsedSolanaTx::build_general_items(&details, None).unwrap();
+ assert_eq!(items.len(), 5);
+ assert_eq!(
+ items
+ .iter()
+ .map(|v| v.instruction_index)
+ .collect::<Vec<_>>(),
+ vec![1, 2, 3, 4, 5]
+ );
+ assert_eq!(items[2].method, "ConfigTransactionCreate");
+ let config: serde_json::Value = serde_json::from_str(&items[2].memo).unwrap();
+ assert_eq!(config["memo"], "test");
+ assert!(config["multisig"].is_string());
+ assert!(config["creator"].is_string());
+ assert!(config["actions"][0]["RemoveMember"]["old_member"].is_string());
+ assert_eq!(items[3].method, "ProposalCreate");
+ assert_eq!(items[4].method, "ProposalApprove");
+ }
+
+ #[test]
+ fn interleaved_squads_preserves_raw_instruction_order() {
+ let squads = "SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf";
+ let unknown = bitcoin::base58::encode(&[7; 32]);
+ let activate = hex::decode("0b225cf89a1b336a").unwrap();
+ let mut raw = vec![1, 0, 2, 3];
+ raw.extend([1; 32]);
+ raw.extend(bitcoin::base58::decode(squads).unwrap());
+ raw.extend([7; 32]);
+ raw.extend([9; 32]);
+ raw.push(3);
+ for (program, data) in [(1, activate.clone()), (2, vec![42]), (1, activate.clone())] {
+ raw.extend([program, 0, data.len() as u8]);
+ raw.extend(data);
+ }
+ let parsed = ParsedSolanaTx::build(&raw).unwrap();
+ assert!(matches!(parsed.display_type, SolanaTxDisplayType::Unknown));
+ let SolanaOverview::Instructions(overview) = parsed.overview else {
+ panic!("interleaved Squads must use raw instruction review");
+ };
+ assert_eq!(overview.overview_instructions.len(), 3);
+ for (instruction, (program, data)) in overview.overview_instructions.iter().zip([
+ (squads, activate.as_slice()),
+ (unknown.as_str(), &[42][..]),
+ (squads, activate.as_slice()),
+ ]) {
+ assert_eq!(instruction.program_address, program);
+ assert_eq!(instruction.data, bitcoin::base58::encode(data));
+ }
+
+ for middle in [
+ detail("Unknown", ""),
+ detail("ComputeBudget", "SetComputeUnitLimit"),
+ ] {
+ let interleaved = vec![
+ detail("SquadsV4", "ProposalActivate"),
+ middle,
+ detail("System", "Transfer"),
+ ];
+ assert!(matches!(
+ ParsedSolanaTx::detect_display_type(&interleaved),
+ SolanaTxDisplayType::Unknown
+ ));
+ }
+ let contiguous = vec![
+ detail("Unknown", ""),
+ detail("SquadsV4", "ProposalActivate"),
+ detail("SquadsV4", "ProposalActivate"),
+ detail("Unknown", ""),
+ ];
+ assert!(matches!(
+ ParsedSolanaTx::detect_display_type(&contiguous),
+ SolanaTxDisplayType::SquadsV4
+ ));
+ }
+
+ #[test]
+ fn squads_creation_and_transfers_use_complete_raw_review() {
+ let squads =
+ bitcoin::base58::decode("SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf").unwrap();
+ for discriminator in ["7a4d509f54585ac5", "32ddc75d28f58be9", "0b225cf89a1b336a"] {
+ let mut data = hex::decode(discriminator).unwrap();
+ let is_create = discriminator != "0b225cf89a1b336a";
+ if is_create {
+ data.extend([0, 1, 0, 1, 0, 0, 0]);
+ data.extend([1; 32]);
+ data.push(7);
+ data.extend([0; 4]);
+ if discriminator == "32ddc75d28f58be9" {
+ data.push(0);
+ }
+ data.push(0);
+ }
+ for count in 0..=3u8 {
+ let mut raw = vec![1, 0, 2, 4];
+ raw.extend([1; 32]);
+ raw.extend([2; 32]);
+ raw.extend(&squads);
+ raw.extend([0; 32]);
+ raw.extend([9; 32]);
+ raw.push(1 + count);
+ raw.extend([2, 0, data.len() as u8]);
+ raw.extend(&data);
+ for amount in 1..=count {
+ raw.extend([3, 2, 0, 1, 12]);
+ raw.extend(2u32.to_le_bytes());
+ raw.extend(u64::from(amount).to_le_bytes());
+ }
+ let parsed = ParsedSolanaTx::build(&raw).unwrap();
+ if !is_create && count == 0 {
+ assert!(matches!(parsed.display_type, SolanaTxDisplayType::SquadsV4));
+ continue;
+ }
+ let SolanaOverview::Instructions(overview) = parsed.overview else {
+ panic!("all creation and transfer instructions must be reviewable");
+ };
+ assert_eq!(overview.overview_instructions.len(), 1 + count as usize);
+ assert_eq!(
+ overview.overview_instructions[0].data,
+ bitcoin::base58::encode(&data)
+ );
+ for (index, instruction) in
+ overview.overview_instructions.iter().skip(1).enumerate()
+ {
+ assert_eq!(
+ instruction.program_address,
+ "11111111111111111111111111111111"
+ );
+ let mut expected = 2u32.to_le_bytes().to_vec();
+ expected.extend((index as u64 + 1).to_le_bytes());
+ assert_eq!(instruction.data, bitcoin::base58::encode(&expected));
+ }
+ }
+ }
+ }
+
+ #[test]
+ fn compact_byte_arrays_preserves_json_and_strings() {
+ let original = json!({
+ "transaction_message": [1, 0, 255, 42],
+ "nested": [{"bytes": [2, 3]}],
+ "memo": "Keep [1, 2] and escaped \"quotes\" / 中文 unchanged",
+ "not_bytes": [256, -1, 1.5],
+ "empty": []
+ });
+ let pretty = serde_json::to_string_pretty(&original).unwrap();
+ let compact = ParsedSolanaTx::compact_byte_arrays(&pretty);
+ assert!(compact.contains("[1, 0, 255, 42]"));
+ assert!(compact.contains("[2, 3]"));
+ assert!(compact.contains("\"nested\": [\n"));
+ assert!(compact.contains("\"not_bytes\": [\n"));
+ assert_eq!(serde_json::from_str::<Value>(&compact).unwrap(), original);
+ assert_eq!(ParsedSolanaTx::compact_byte_arrays(&compact), compact);
+ assert!(compact.len() < pretty.len());
+ }
+
#[test]
fn display_classification_and_account_helpers_cover_security_boundaries() {
assert!(ParsedSolanaTx::is_lookup_table_reference("table#255"));
@@ -1200,7 +1652,7 @@ mod tests {
detail("SquadsV4", "ProposalCreate"),
detail("System", "Transfer")
]),
- SolanaTxDisplayType::SquadsV4
+ SolanaTxDisplayType::Unknown
));
assert!(ParsedSolanaTx::is_instructions_detail(
&detail("Instructions", "").common
@@ -1215,7 +1667,7 @@ mod tests {
const QA_MEMO: &str = concat!(
"Keystone offers seamless compatibility with leading wallets such as MetaMask, ",
- "OKX Wallet, Tonkeeper, Solflare, Backpack, Blue Wallet, Keplr, Eternl and others, ",
+ "OKX Wallet, Keeper, Solflare, Backpack, Blue Wallet, Keplr, Eternl and others, ",
"ensuring top-tier security for a wide range of cryptocurrencies, including ",
"Bitcoin and Ethereum."
);
@@ -1368,6 +1820,10 @@ mod tests {
"1 raw units (decimals: 19)"
);
assert!(ParsedSolanaTx::format_token_amount_for_display("unknown", "bad", 19).is_err());
+ assert_eq!(ParsedSolanaTx::format_basis_points(0), "0%");
+ assert_eq!(ParsedSolanaTx::format_basis_points(50), "0.5%");
+ assert_eq!(ParsedSolanaTx::format_basis_points(125), "1.25%");
+ assert_eq!(ParsedSolanaTx::format_basis_points(u16::MAX), "655.35%");
}
#[test]
@@ -1389,6 +1845,7 @@ mod tests {
let data = "01000103876c762c4c83532f82966935ba1810659a96237028a2af6688dadecb0155ae071c7d0930a08193e702b0f24ebba96f179e9c186ef1208f98652ee775001744490000000000000000000000000000000000000000000000000000000000000000a7516fe1d3af3457fdc54e60856c0c3c87f4e5be3d10ffbc7a5cce8bf96792a101020200010c020000008813000000000000";
let transaction = Vec::from_hex(data).unwrap();
let parsed = ParsedSolanaTx::build(&transaction).unwrap();
+ crate::message_json::tests::assert_json_roundtrip(&transaction, &parsed.detail);
match parsed.overview {
SolanaOverview::Transfer(overview) => {
assert_eq!("0.000005 SOL".to_string(), overview.value);
@@ -1404,7 +1861,9 @@ mod tests {
}
_ => println!("program overview parse error!"),
};
- let parsed_detail: Value = serde_json::from_str(parsed.detail.as_str()).unwrap();
+ let parsed_detail: Value =
+ serde_json::from_str(&semantic_detail_json(&transaction, &parsed.display_type))
+ .unwrap();
let expected_detail = json!([
{
"program": "System",
@@ -1424,6 +1883,7 @@ mod tests {
let data = "0301070a2877bcb8e7acfa950840ace015aee0f7c34f8da98cb47a0379a0848d1d146732295c04a089afe0f89e2eb1068d40b6dabc909d1c8fbd42a33d38388a9028952a0bfed77df018f67f348da938e5e96b9f66d05a542123fa3f9bebf7332df339cf000000000000000000000000000000000000000000000000000000000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc00000000006a1d817a502050b680791e6ce6db88e1e5b7150f61fc6790a4eb4d10000000006a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a7d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a0000000006a7d517193584d0feed9bb3431d13206be544281b57b8566cc5375ff40000006dcf56df0c05417d5642726a2159a63bec115672bf8c57a694cf097e91a21c6f5cd38793d98807ac0a75e5553f78d37654a08385ecb7280ce9c7c905843164d305030200010c02000000af613239da0000000301010c08000000c800000000000000030101240100000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0000000000402010774000000000bfed77df018f67f348da938e5e96b9f66d05a542123fa3f9bebf7332df339cfc384e275e260429599cc2093f115fa55564dee44af077765b86417bd6967b37d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004060109060805020402000000";
let transaction = Vec::from_hex(data).unwrap();
let parsed = ParsedSolanaTx::build(&transaction).unwrap();
+ crate::message_json::tests::assert_json_roundtrip(&transaction, &parsed.detail);
match parsed.overview {
SolanaOverview::Transfer(overview) => {
assert_eq!("937.262473647 SOL".to_string(), overview.value);
@@ -1439,7 +1899,9 @@ mod tests {
}
_ => println!("program overview parse error!"),
};
- let parsed_detail: Value = serde_json::from_str(parsed.detail.as_str()).unwrap();
+ let parsed_detail: Value =
+ serde_json::from_str(&semantic_detail_json(&transaction, &parsed.display_type))
+ .unwrap();
let expected_detail = json!([
{
"program": "System",
@@ -1510,6 +1972,7 @@ mod tests {
let data = "01000305b446cb8fd7c225bf416df87c286710d75711af95222e41216da2177289cbbfa6b68edcd94d93de68614892bd165a94a6647aa040d87b9a042b41a009bdb469cf06a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a7d517192f0aafc6f265e3fb77cc7ada82c529d0be3b136e2d0055200000000761481d357474bb7c4d7624ebd3bdb3d8355e73d11043fc0da35380000000009254bd5e695fabf43f0ead6da730e88cf39bec6991c2c4374bcade97d0a73be7010404010302003d02000000010000000000000060f2790800000000856a887d33af1cd1723388576a7be8fa6d9c9c80c548495a24bf680c908812cf01da7dd66200000000";
let transaction = Vec::from_hex(data).unwrap();
let parsed = ParsedSolanaTx::build(&transaction).unwrap();
+ crate::message_json::tests::assert_json_roundtrip(&transaction, &parsed.detail);
match parsed.overview {
SolanaOverview::Vote(overview) => {
assert_eq!("Vote".to_string(), overview.main_action);
@@ -1521,7 +1984,9 @@ mod tests {
}
_ => println!("program overview parse error!"),
};
- let parsed_detail: Value = serde_json::from_str(parsed.detail.as_str()).unwrap();
+ let parsed_detail: Value =
+ serde_json::from_str(&semantic_detail_json(&transaction, &parsed.display_type))
+ .unwrap();
let expected_detail = json!([
{
"program": "Vote",
@@ -1547,6 +2012,7 @@ mod tests {
let data = "0200050a06852df21778a462ea79aae81500eae98a935dcca05f8b899ca8b41021a79980acc933a10d87058ad3131361cd345fe95eb7598ad52d972ee559f1ea3f8deb452bb2df65fdf1ad0514f549457e4338bb71e6885354aa5ed87969ef14f5fc736772295dfa0330919867f6f90f2e334d1a56a2203ec3d4086151aab0171ca13c74b626da01ca1cb62be1bbbf9927dd0de251964d351736fd36100bb0e06f728b4100000000000000000000000000000000000000000000000000000000000000008c97258f4e2489f1bb3d1029148e0d830b5a1399daff1084048e7bd8dbe9f8590b7065b1e3d17c45389d527f6b04c3cd58b86c731aa0fdb549b6d1bc03f8294606a7d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a0000000006ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a92865a919afcfd4d57cf8f69e11990c98a55e4cc4389ba43c7d32184ca652adb406050200013400000000604d160000000000520000000000000006ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a90902010843000006852df21778a462ea79aae81500eae98a935dcca05f8b899ca8b41021a799800106852df21778a462ea79aae81500eae98a935dcca05f8b899ca8b41021a799800707030100000005087b0012000000536e65616b65722023313830333539303435000000003200000068747470733a2f2f6170692e737465706e2e636f6d2f72756e2f6e66746a736f6e2f3130332f3130363036313531353732319001010100000006852df21778a462ea79aae81500eae98a935dcca05f8b899ca8b41021a799800164010607000400010509080009030104000907010000000000000007090201000000030905080a0a010000000000000000";
let transaction = Vec::from_hex(data).unwrap();
let parsed = ParsedSolanaTx::build(&transaction).unwrap();
+ crate::message_json::tests::assert_json_roundtrip(&transaction, &parsed.detail);
assert_eq!(3, parsed.unknown_programs.len());
match parsed.overview {
SolanaOverview::General(overview) => {
@@ -1563,7 +2029,9 @@ mod tests {
}
_ => println!("program overview parse error!"),
};
- let parsed_detail: Value = serde_json::from_str(parsed.detail.as_str()).unwrap();
+ let parsed_detail: Value =
+ serde_json::from_str(&semantic_detail_json(&transaction, &parsed.display_type))
+ .unwrap();
let expected_detail = json!(
[
@@ -1649,6 +2117,7 @@ mod tests {
let data = "02000407e9940f6435ae992ddbb4ac739ada475fde93bd54c6a9f36a8b60b37fe23ec3fdd8ffff8ad461ca3138f356758b148f2dffa7d055a79356b52727298026189ae82e6df8bd210e5f167971908e8746aa6790aa3bc74ee48a4bbf23236f9effaa65069b8857feab8184fb687f634618c035dac439dc1aeb3b5598a0f0000000000106a7d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a00000000000000000000000000000000000000000000000000000000000000000000000006ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a9bff514b7cba346fe333553de5579d50a7da74cf950dd7bdd27327ce9a17c876f04050200013400000000f01d1f0000000000a50000000000000006ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a9060401030004010106030201000903242d84be0000000006030100000109";
let transaction = Vec::from_hex(data).unwrap();
let parsed = ParsedSolanaTx::build(&transaction).unwrap();
+ crate::message_json::tests::assert_json_roundtrip(&transaction, &parsed.detail);
match parsed.overview {
SolanaOverview::General(mut overview) => {
let overview_1 = overview.pop().unwrap();
@@ -1700,7 +2169,9 @@ mod tests {
"owner": "GinwSnwbsjkWXkancBr5E6EPrQtKdwnE5vPdriv1tK3i"
}
]);
- let parsed_detail: Value = serde_json::from_str(parsed.detail.as_str()).unwrap();
+ let parsed_detail: Value =
+ serde_json::from_str(&semantic_detail_json(&transaction, &parsed.display_type))
+ .unwrap();
assert_eq!(expected_detail, parsed_detail);
}
@@ -1711,6 +2182,7 @@ mod tests {
let data = "0201060908a13fb5c9e7bc18aef6d4ec2e5bca9fb0b8c329c32bdf2baae9125aa3191cd36eeb5c79927943eef87a2828925665d2b3612a070fe5eee74680d8ac0b779ca136a3ae0cda1d97779bcd08c24409fe1c76f84f218aeed3296d8efe2dade261a606a7d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a0000000006ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a90b3338a0ab2cc841d5b014bc6a3cf756291874b319c9517d9bbfa9e4e9661ef90000000000000000000000000000000000000000000000000000000000000000054a5350f85dc882d614a55672788a296ddf1eababd0a60678884932f4eef6a08c97258f4e2489f1bb3d1029148e0d830b5a1399daff1084048e7bd8dbe9f859704b00127cf4d5d2ca44446993ee3bab439ce957bde518d1767b108b87a4a7d00307002c416141414141414141414141414141414141414141414141414141414141414141414141414141414141413d08070002010506040300040202012306030108a13fb5c9e7bc18aef6d4ec2e5bca9fb0b8c329c32bdf2baae9125aa3191cd3";
let transaction = Vec::from_hex(data).unwrap();
let parsed = ParsedSolanaTx::build(&transaction).unwrap();
+ crate::message_json::tests::assert_json_roundtrip(&transaction, &parsed.detail);
match parsed.overview {
SolanaOverview::General(mut overview) => {
let overview_1 = overview.pop().unwrap();
@@ -1719,7 +2191,9 @@ mod tests {
}
_ => println!("program overview parse error!"),
};
- let parsed_detail: Value = serde_json::from_str(parsed.detail.as_str()).unwrap();
+ let parsed_detail: Value =
+ serde_json::from_str(&semantic_detail_json(&transaction, &parsed.display_type))
+ .unwrap();
let expected_detail = json!([
{
@@ -1761,6 +2235,7 @@ mod tests {
let data = "0301070faa30697d8ea2d14ce506c401ad5f1bd33476ebcb8a8b5cea89fa0aafb7c04f3925070f12913aa23553bfaf08f0a6f293aadb24dd66711db239c9b0ccca751b05dcc3a6c16cb67f59d67085e174cd7469f3e00b99a63d6c8d95337096f9e8437d8c17a1e64eba64bb7238d33b21461db8824508c879f91199d9eff9309ff63952baf04e4356057aaea057a6d744e1a0dbb99091448d6c2807114f0a016c9f2c39df8b1e991b87277d51b2ee23b63496ff1a54ab30e61eb4c4572e52fb99af9421e636e5095d76cede0e72ff2a024a07652d423fb7f3978a4663a278d13e1c1ba10deb821d34b39060c73598d3dd86ecf853df3b2f38b02991ad2ccfa51306e01600000000000000000000000000000000000000000000000000000000000000003f5877e18f96dea58c638a21d2be860ba96f0e21d1d84c6a94dba44e2be81f0e494500f4fdcbc9ad22814e250c0d6763266f6ca9169e12662f477601991e1a36be49a1eeb81bf889c158fd8b7496ff9141d4aa433eae3948d0d8488f78951b78069b8857feab8184fb687f634618c035dac439dc1aeb3b5598a0f0000000000106a7d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a0000000006ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a954c495b382bac905bb70f97bc252b2ee3b796b2836a3287ed5787c70eb2484120608020001340000000030266d0500000000a50000000000000006ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a90e04010c000d01010e03010200090440084e05000000000b0a090a020106030504070e110140084e05000000005d4d3700000000000e02010001050e030100000109";
let transaction = Vec::from_hex(data).unwrap();
let parsed = ParsedSolanaTx::build(&transaction).unwrap();
+ crate::message_json::tests::assert_json_roundtrip(&transaction, &parsed.detail);
assert_eq!(1, parsed.unknown_programs.len());
match parsed.overview {
SolanaOverview::General(overview) => {
@@ -1779,7 +2254,9 @@ mod tests {
}
_ => println!("program overview parse error!"),
};
- let parsed_detail: Value = serde_json::from_str(parsed.detail.as_str()).unwrap();
+ let parsed_detail: Value =
+ serde_json::from_str(&semantic_detail_json(&transaction, &parsed.display_type))
+ .unwrap();
let expected_detail = json!(
[
@@ -1848,7 +2325,9 @@ mod tests {
let raw_message = "800100020305919998ccad85d7254856bde658b1926b77276f9c9f93d4713eec50c6f0cd4e0306466fe5211732ffecadba72c39be7bc8ce5bbc5f7126b2c439b3a4000000008239266ec3629985acb2ec387b47c3c3ca057181773835b4f0e99ab4f065e7dc3e93416d06d11ad5352987624986db3240b02ea5cc42ba3c2e9f3a6e9bfe1c203010005028c45080001000903208601000000000002271d1f1e00040508070906191c19141b11120c0f1a0b0a0e13101020070d00180315000d04171619295bbffbf792f60aa2084d230100000000ad88c11900000000030201070000000000000101000000000004fdd750c4799429e7e17c0c7cf0a55a82d70846d1bc97665714af810651e8bb04010e060d010c0f0709209be863b24cb2303c7162670000dfaf3176a1ada32a0305df593d8a935c7dcd06038b8d118a8c0287868cb7d386ca1b4cb4125557bf989073c37d63ae73104247ee1280afa86a8ac75b0b9695938f97949a9192988d019bfddf37b259d3ceada480a9a43ba12f21bfd3d7afd64d35b9f0330f6645d3016f03969a9900";
let transaction = Vec::from_hex(raw_message).unwrap();
let parsed = ParsedSolanaTx::build(&transaction).unwrap();
- let detail_tx = parsed.detail;
+ crate::message_json::tests::assert_json_roundtrip(&transaction, &parsed.detail);
+ assert!(matches!(parsed.display_type, SolanaTxDisplayType::Unknown));
+ let detail_tx = semantic_detail_json(&transaction, &parsed.display_type);
let parsed_detail: Value = serde_json::from_str(detail_tx.as_str()).unwrap();
let expect_data = json!([
{
@@ -1908,7 +2387,23 @@ mod tests {
"program_account": "YmirFH6wUrtUMUmfRPZE7TcnszDw689YNWYrMgyB55N"
}
]);
- assert_eq!(expect_data, parsed_detail);
+ let mut expect_data = expect_data;
+ for instruction in expect_data.as_array_mut().unwrap() {
+ if let Some(accounts) = instruction
+ .get_mut("accounts")
+ .and_then(Value::as_array_mut)
+ {
+ for account in accounts {
+ if let Some((table, index)) = account.as_str().and_then(|s| s.split_once('#')) {
+ *account = json!({"Table": table, "Index": index.parse::<u8>().unwrap(), "Status": "Unresolved offline"});
+ }
+ }
+ }
+ }
+ assert_eq!(expect_data, parsed_detail["instructions"]);
+ assert!(parsed_detail["accounts"].is_array());
+ assert!(parsed_detail["header"].is_object());
+ assert!(parsed_detail["block_hash"].is_string());
}
#[test]
@@ -1917,7 +2412,8 @@ mod tests {
let raw_message = "0100091b08904ad8e08db0a43a396c4d58b75befb2d0bb52a884fe2356f7a5d4f79c18456369e2b9dd2eed26b91e56b642d118df0ff7d4a0f3c6c2e722face2365fd87ce889403562623feb51a656493fb3964e89c2ed1be748c2692c410cdb7e69122365a3f4fc6e059cbef43a31884da9144fb99ea03b253c5bf15e8b703cd0d6cb4a48b335f799935aa3f8ccd9384f456fe6222a26f7d31b04143246b927066cbab9d6184d194fcd38b5fd4826bcfce778ada40a4ee6e864f74daf824cfaf0354431c8b69cf47f17b6ab36eb9dcac947bbaf6666e8c2b597b8a25861babfd6216ce2a6c9010bb7b7cc2bfc144a74aa59f3b28a1368c87c352012c8d37eb4045d20e0a3d6e472e67a46ea6b4bd0bab9dfd35e2b4c72f1d6d59c2eab95c942573ad22f1f411b5d45e8c66bb2cf71b6f45f5ac00ca5737f1a76205c77b0afef885eae5c7b870e12dd379891561d2e9fa8f26431834eb736f2f24fc2a2a4dff1fd5dca4dff2cbb9b760eddb185706303063ad33d7b57296ea02d4e0335e31ceafa4cc42dd84c2fb18aed619f546632653ef06029f02a864bf3829867181bb20df1d715c3000f426e16eb8cf03119175f980514344955ce370e765940f3c29439545fb45a9a6dfd15c507705f9339b953c1a4dfdbc9cc186dd2f62df48a958045e2a7652594020894653cfddfa7b7e60c966682736a2db0f838564925b11077a21e036d7971f26f5f0461c4010bd5cc8ca7066dda584a6ee717934c677adf4c25fbd156a2d6ae3ed327a0f8849a772941d97050f3a6e8cb8dd3abcdb1470887c82b54d3f367e54771a57a6f14ca9e402d54aee45f7378aca365c7b169a7ec83f5182b298f006ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a9c523f583f96ed4fdbd8ade165f8dfe5533c10fa021a22a3f31e54adc0203166104798dce15306e485502448ae418831ba6a76b92956377a6eb7e058e5e011e544bd949c43602c33f207790ed16a3524ca1b9975cf121a2a90cffec7df8b68acd4157b0580f31c5fce44a62582dbcf9d78ee75943a084a393b350368d22899308850f2d6e02a47af824d09ab69dc42d70cb28cbfa249fb7ee57b9d256c12762efd1ef734f68204eb2e2c04629794a8c02107ad09bf3b219597a14effb8a04d9860479d50ca68497da9571369968ee1347fda9c3ba32e438dad6225250695de886032145aed8034a56f7cea8a915bcff6b59933a8fed2fd11f034073391917ae75031a02010508e455b9704e4f4d021a0b12131415000203040506071abbc076d43e6d1cd501a484c302000000000000000000000000001a1316130817090a0b180c0d0e0f101119050200011245e3625dedcadf8c005300c5020000000000";
let transaction = Vec::from_hex(raw_message).unwrap();
let parsed = ParsedSolanaTx::build(&transaction).unwrap();
- let detail_tx = parsed.detail;
+ crate::message_json::tests::assert_json_roundtrip(&transaction, &parsed.detail);
+ let detail_tx = semantic_detail_json(&transaction, &parsed.display_type);
let parsed_detail: Value = serde_json::from_str(detail_tx.as_str()).unwrap();
let expect_json = json!({
"accounts": [
@@ -2025,8 +2521,9 @@ mod tests {
let raw_message = "800100020305919998ccad85d7254856bde658b1926b77276f9c9f93d4713eec50c6f0cd4e0306466fe5211732ffecadba72c39be7bc8ce5bbc5f7126b2c439b3a4000000008239266ec3629985acb2ec387b47c3c3ca057181773835b4f0e99ab4f065e7dc3e93416d06d11ad5352987624986db3240b02ea5cc42ba3c2e9f3a6e9bfe1c203010005028c45080001000903208601000000000002271d1f1e00040508070906191c19141b11120c0f1a0b0a0e13101020070d00180315000d04171619295bbffbf792f60aa2084d230100000000ad88c11900000000030201070000000000000101000000000004fdd750c4799429e7e17c0c7cf0a55a82d70846d1bc97665714af810651e8bb04010e060d010c0f0709209be863b24cb2303c7162670000dfaf3176a1ada32a0305df593d8a935c7dcd06038b8d118a8c0287868cb7d386ca1b4cb4125557bf989073c37d63ae73104247ee1280afa86a8ac75b0b9695938f97949a9192988d019bfddf37b259d3ceada480a9a43ba12f21bfd3d7afd64d35b9f0330f6645d3016f03969a9900";
let transaction = Vec::from_hex(raw_message).unwrap();
let parsed = ParsedSolanaTx::build(&transaction).unwrap();
+ crate::message_json::tests::assert_json_roundtrip(&transaction, &parsed.detail);
- let detail_tx = parsed.detail;
+ let detail_tx = semantic_detail_json(&transaction, &parsed.display_type);
let parsed_detail: Value = serde_json::from_str(detail_tx.as_str()).unwrap();
println!("parsed_detail: {:?}", parsed_detail);
@@ -2043,6 +2540,7 @@ mod tests {
let data = "010007096aefb992fa0cd54aea185bf65a7da92aad6bd46da5a67c7675a04e6540d86f7a3d2ce2421048aa748a6cc22b5696032f902cfc0b3dd6bce0d379f76c383bceda0000000000000000000000000000000000000000000000000000000000000000e23a2b23b625e7513991be370a2c20d5c5e276491d36777ef2e5b1227ffe732906a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc00000000006a1d817a502050b680791e6ce6db88e1e5b7150f61fc6790a4eb4d10000000006a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a7d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a0000000006a7d517193584d0feed9bb3431d13206be544281b57b8566cc5375ff4000000aada712c5d14f4e64d913b330ff3e519bc7f2aac580997f0c549620601866915030202000174030000006aefb992fa0cd54aea185bf65a7da92aad6bd46da5a67c7675a04e6540d86f7a18000000000000007374616b653a302e3231363239323431373439393638393500de2a9200000000c80000000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc0000000000402010774000000006aefb992fa0cd54aea185bf65a7da92aad6bd46da5a67c7675a04e6540d86f7a6aefb992fa0cd54aea185bf65a7da92aad6bd46da5a67c7675a04e6540d86f7a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004060103060805000402000000";
let transaction = Vec::from_hex(data).unwrap();
let parsed = ParsedSolanaTx::build(&transaction).unwrap();
+ crate::message_json::tests::assert_json_roundtrip(&transaction, &parsed.detail);
match parsed.overview {
SolanaOverview::General(overview) => {
let overview_1 = overview.get(0).unwrap();
@@ -2057,7 +2555,9 @@ mod tests {
}
_ => println!("program overview parse error!"),
};
- let parsed_detail: Value = serde_json::from_str(parsed.detail.as_str()).unwrap();
+ let parsed_detail: Value =
+ serde_json::from_str(&semantic_detail_json(&transaction, &parsed.display_type))
+ .unwrap();
let expected_detail = json!([
{
"program": "System",
@@ -2103,6 +2603,7 @@ mod tests {
let data = "01000305575949043cea1e1713d06b6b2eba6bb22d303884908e683fcaaa7b0ba6209be859d521dc428449106dabb34dadd3b44cc7795f58be0d4a81aaeaada967b21bd206a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc00000000006a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a7d517193584d0feed9bb3431d13206be544281b57b8566cc5375ff400000067415e51677a2d98e9f86da5c65fe4c72bdee5cb2755af7a27d13dda710aa26001020501000304000c04000000ed77410300000000";
let transaction = Vec::from_hex(data).unwrap();
let parsed = ParsedSolanaTx::build(&transaction).unwrap();
+ crate::message_json::tests::assert_json_roundtrip(&transaction, &parsed.detail);
match parsed.overview {
SolanaOverview::General(overview) => {
let overview_1 = overview.get(0).unwrap();
@@ -2111,7 +2612,9 @@ mod tests {
}
_ => println!("program overview parse error!"),
};
- let parsed_detail: Value = serde_json::from_str(parsed.detail.as_str()).unwrap();
+ let parsed_detail: Value =
+ serde_json::from_str(&semantic_detail_json(&transaction, &parsed.display_type))
+ .unwrap();
let expected_detail = json!([
{
"program": "Stake",
@@ -2135,6 +2638,7 @@ mod tests {
let data = "010002044dd6a13d7b9ca64c690638eb9679f4a264a5a93022212ec608b24964dbc5701aff979426efda42a314f5b5477ea3264fddfb5ee1b9f939bff1e90cbea09cde3306a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc00000000006a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b2100000000a4eb4d5967097a0ec98783003eba3fde67341ba6d6d55f7d6987494a952466520102030103000405000000";
let transaction = Vec::from_hex(data).unwrap();
let parsed = ParsedSolanaTx::build(&transaction).unwrap();
+ crate::message_json::tests::assert_json_roundtrip(&transaction, &parsed.detail);
match parsed.overview {
SolanaOverview::General(overview) => {
let overview_1 = overview.get(0).unwrap();
@@ -2143,7 +2647,9 @@ mod tests {
}
_ => println!("program overview parse error!"),
};
- let parsed_detail: Value = serde_json::from_str(parsed.detail.as_str()).unwrap();
+ let parsed_detail: Value =
+ serde_json::from_str(&semantic_detail_json(&transaction, &parsed.display_type))
+ .unwrap();
let expected_detail = json!([
{
"program": "Stake",
@@ -2175,13 +2681,16 @@ mod tests {
let data = "0100060e1a93fffb26ce645adeae58f0f414c320bcec30ce12a66bd263a91ec9b3958ff45d2a5ee5685c17e07cede5bef98300d4170ebbe2d99f064c4bb05ee97b35de7d75119b3175807586e3f4a7e5cd0f890e96a753b10fccc7681e9473a0083270f1bfa153f6e9dc8b683a60c22c944131adc8abfb93befad36efcc572c783e27055f7f1afd0d58a5a0dcfa04274a0c6aaa6e8c38380af1cd2b1c3f881cc9e24ac330b62ba074f722c9d4114f2d8f70a00c66002337b9bf90c873657a6d201db4c80067d7c615ffb9455750b6b889211bcf4c76f687cbb6ba93adc37ecaefbfb41b207154414aa83b02488ade068d5effab202658060008643843ceacd8dc5e1b89f0000000000000000000000000000000000000000000000000000000000000000222829e89767b2043c86d1b51f31364e5adaeb861fd62e7a7f46be4dbbc55ca4cfa6452d2d0f594a1ddd1bead98a7a52fd63925ae3266435dde44a5ab3fdb8f10545e365bef271ad75350367565da40da336dc1c879bb1548a7afcc55aa9391e0b616d4895472c6a02e9ecd3e87951f18401d675dedcbe33e8673e00221522d306ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a91b421195ecaa4f6b65834080c6ac091cd06449b7cb33a5cbe42a86b27d36a469010c0d020507010a03000409080d0b0610f223c68952e1f2b68096980000000000";
let transaction = Vec::from_hex(data).unwrap();
let parsed = ParsedSolanaTx::build(&transaction).unwrap();
+ crate::message_json::tests::assert_json_roundtrip(&transaction, &parsed.detail);
match parsed.overview {
SolanaOverview::Unknown(overview) => {
assert_eq!("This transaction can not be decoded", overview.description);
}
_ => println!("program overview parse error!"),
};
- let parsed_detail: Value = serde_json::from_str(parsed.detail.as_str()).unwrap();
+ let parsed_detail: Value =
+ serde_json::from_str(&semantic_detail_json(&transaction, &parsed.display_type))
+ .unwrap();
let expected_detail = json!({
"accounts": [
"2nkVYBJQg5UavBjvBT4jcahJamnFyr8wzPhzabDaRnBD",
@@ -2237,6 +2746,7 @@ mod tests {
let data = "01000306507e6e0eedc8bad07d8e1907faf5cd44364b75503f4b2f9a2efd196fabcdbc0d8a35bc824e0b6a9970622a2d84513cb3d0d8d9274d026c09b189a3c991b04e679afd0fdcc13de092bc32eaef523c79183e3c923924634e64b9808b67ce00316f06a7d51718c774c928566398691d5eb68b5eb8a39b4b6d5c73555b210000000006a7d517193584d0feed9bb3431d13206be544281b57b8566cc5375ff400000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc000000000453461b52d93efbb8f738fe6df0fb3d12c5a014432f41011d426e3b01eb4f66b01050501020304000407000000";
let transaction = Vec::from_hex(data).unwrap();
let parsed = ParsedSolanaTx::build(&transaction).unwrap();
+ crate::message_json::tests::assert_json_roundtrip(&transaction, &parsed.detail);
match parsed.overview {
SolanaOverview::General(overview) => {
let overview_1 = overview.get(0).unwrap();
@@ -2245,7 +2755,9 @@ mod tests {
}
_ => println!("program overview parse error!"),
};
- let parsed_detail: Value = serde_json::from_str(parsed.detail.as_str()).unwrap();
+ let parsed_detail: Value =
+ serde_json::from_str(&semantic_detail_json(&transaction, &parsed.display_type))
+ .unwrap();
let expected_detail = json!([{"program":"Stake","method":"Merge","destination_stake_account":"AJWneUm7QuQENJXkn7rDMp1Bvfab3R5vY7LcGuMmTtQv","source_stake_account":"BS1bVhRD2iJrGbiHV61J3SRg8TsGjR2a9TSBeoJBY6Ce","sysvar_clock":"SysvarC1ock11111111111111111111111111111111","sysvar_stake_history":"SysvarStakeHistory1111111111111111111111111","stake_authority_pubkey":"6RDS19fkTJ3BtTx78NswVm2VSPRmwM9tEa6kGuadAPKS"}]);
assert_eq!(expected_detail, parsed_detail);
}
### rust/apps/solana/src/parser/structs.rs
@@ -8,15 +8,21 @@ use crate::parser::overview::{ProgramOverviewGeneral, SolanaOverview};
pub struct ParsedSolanaTx {
pub display_type: SolanaTxDisplayType,
pub overview: SolanaOverview,
- /// Parsed sibling instructions which must be shown after a specialized
- /// overview such as Jupiter. This keeps the richer primary UI without
- /// hiding any other instruction committed by the signature.
pub additional_overviews: Vec<ProgramOverviewGeneral>,
pub unknown_programs: Vec<String>,
+ pub overview_order: Vec<(usize, OverviewAction)>,
pub detail: String,
+ pub advanced: Vec<crate::advanced::AdvancedItem>,
pub network: String,
}
+#[derive(Clone, Debug, PartialEq)]
+pub enum OverviewAction {
+ Primary,
+ General(usize),
+ Unknown(usize),
+}
+
// method label on ui
#[derive(Clone, Debug)]
pub enum SolanaTxDisplayType {
### rust/apps/solana/src/resolvers/mod.rs
@@ -1,8 +1,6 @@
+use crate::errors::Result;
use alloc::format;
use alloc::string::String;
-use core::ops::Div;
-
-use crate::errors::{Result, SolanaError};
pub mod squads_v4;
pub mod stake;
@@ -14,13 +12,9 @@ pub mod vote;
pub mod jupiter_v6;
-pub const DIVIDER: f64 = 1_000_000_000_f64;
-
pub fn format_amount(value: String) -> Result<String> {
- if let Ok(value) = value.as_str().parse::<f64>() {
- return Ok(format!("{} {}", value.div(DIVIDER), "SOL"));
- }
- Err(SolanaError::ParseTxError(format!(
- "invalid value {value:?}"
- )))
+ Ok(format!(
+ "{} SOL",
+ crate::utils::format_token_amount(&value, 9)?
+ ))
}
### rust/apps/solana/src/resolvers/squads_v4.rs
@@ -2,7 +2,9 @@ use alloc::string::{String, ToString};
use alloc::vec::Vec;
use crate::errors::Result;
-use crate::parser::detail::{CommonDetail, ProgramDetail, SolanaDetail};
+use crate::parser::detail::{
+ CommonDetail, ProgramDetail, ProgramDetailSquadsConfigTransactionCreate, SolanaDetail,
+};
use crate::solana_lib::squads_v4::instructions::{
MultisigCreateArgs, MultisigCreateArgsV2, ProposalCreateArgs, ProposalVoteArgs,
SquadsInstructions, VaultTransactionCreateArgs,
@@ -11,6 +13,26 @@ use crate::solana_lib::squads_v4::instructions::{
static PROGRAM_NAME: &str = "SquadsV4";
pub fn resolve(instruction: SquadsInstructions, accounts: Vec<String>) -> Result<SolanaDetail> {
match instruction {
+ SquadsInstructions::ConfigTransactionCreate(args) => {
+ if accounts.len() < 5 {
+ return Err(crate::errors::SolanaError::InvalidData(
+ "missing Squads config transaction accounts".to_string(),
+ ));
+ }
+ Ok(SolanaDetail {
+ common: CommonDetail {
+ program: PROGRAM_NAME.to_string(),
+ method: "ConfigTransactionCreate".to_string(),
+ },
+ kind: ProgramDetail::SquadsV4ConfigTransactionCreate(
+ ProgramDetailSquadsConfigTransactionCreate {
+ multisig: accounts[0].clone(),
+ creator: accounts[2].clone(),
+ args,
+ },
+ ),
+ })
+ }
SquadsInstructions::MultisigCreate(arg) => resolve_multisig_create(arg),
SquadsInstructions::MultisigCreateV2(arg) => resolve_multisig_create_v2(arg, accounts),
SquadsInstructions::ProposalCreate(arg) => resolve_proposal_create(arg, accounts),
### rust/apps/solana/src/solana_lib/jupiter_v6/instructions.rs
@@ -232,8 +232,12 @@ pub enum JupiterInstructions {
impl Dispatch for JupiterInstructions {
fn dispatch(instrucion_data: &[u8]) -> Result<Self, ProgramError> {
let data = instrucion_data;
- let ix_type = &data[..8];
- let ix_data = &data[8..];
+ let ix_type = data
+ .get(..8)
+ .ok_or(JupiterError::UnknownJupiterInstruction)?;
+ let ix_data = data
+ .get(8..)
+ .ok_or(JupiterError::UnknownJupiterInstruction)?;
let ix_type_hex = hex::encode(ix_type);
match ix_type_hex.as_str() {
"c1209b3341d69c81" => {
@@ -278,6 +282,13 @@ mod tests {
use super::*;
+ #[test]
+ fn rejects_short_discriminator_without_panicking() {
+ for len in 0..8 {
+ assert!(JupiterInstructions::dispatch(&vec![0x42; len]).is_err());
+ }
+ }
+
#[test]
fn test_generate_shared_accounts_route_sighash() {
let method_name = "shared_accounts_route";
@@ -1386,6 +1397,12 @@ mod tests {
"program_account": "JUP4Fb2cqiRUcaTHdrPC8h2gNsA2ETXiPDD33WcGuJB",
"program":"Unknown"
});
+ let mut expect_msg_detail = expect_msg_detail;
+ for account in expect_msg_detail["accounts"].as_array_mut().unwrap() {
+ if let Some((table, index)) = account.as_str().and_then(|s| s.split_once('#')) {
+ *account = json!({"Table": table, "Index": index.parse::<u8>().unwrap(), "Status": "Unresolved offline"});
+ }
+ }
assert_eq!(
expect_msg_detail,
serde_json::to_value(&msg_detail[5]).unwrap()
### rust/apps/solana/src/solana_lib/solana_program/mod.rs
@@ -30,24 +30,76 @@ pub mod clock {
pub mod program_utils {
use crate::solana_lib::solana_program::errors::InstructionError;
- const DECODE_LIMIT: usize = u64::MAX as usize;
-
/// Deserialize with a limit based the maximum amount of data a program can expect to get.
/// This function should be used in place of direct deserialization to help prevent OOM errors
- pub fn limited_deserialize<T>(
+ pub fn limited_deserialize<T, const LIMIT: usize>(
instruction_data: &[u8],
- _limit: u64,
) -> Result<T, InstructionError>
where
T: serde::de::DeserializeOwned,
{
+ if instruction_data.len() > LIMIT {
+ return Err(InstructionError::InvalidInstructionData);
+ }
let config = bincode::config::legacy()
- .with_limit::<DECODE_LIMIT>()
+ .with_limit::<LIMIT>()
.with_fixed_int_encoding(); // As per https://github.com/servo/bincode/issues/333, these two options are needed
- let (result, _) = bincode::serde::decode_from_slice(instruction_data, config)
+ let (result, consumed) = bincode::serde::decode_from_slice(instruction_data, config)
.map_err(|_| InstructionError::InvalidInstructionData)?;
+ if consumed != instruction_data.len() {
+ return Err(InstructionError::InvalidInstructionData);
+ }
Ok(result)
}
+
+ #[cfg(test)]
+ mod tests {
+ use super::*;
+ use alloc::{string::String, vec::Vec};
+
+ #[test]
+ fn rejects_oversized_declared_lengths() {
+ let oversized_length = u64::MAX.to_le_bytes();
+ assert!(limited_deserialize::<String, 1232>(&oversized_length).is_err());
+ assert!(limited_deserialize::<Vec<u8>, 1232>(&oversized_length).is_err());
+ }
+
+ #[test]
+ fn vote_sequences_reject_huge_hints_and_preserve_valid_wire_data() {
+ use crate::solana_lib::solana_program::vote::state::{Vote, VoteStateUpdate};
+ let huge = u64::MAX.to_le_bytes();
+ assert!(limited_deserialize::<Vote, 1232>(&huge).is_err());
+ assert!(limited_deserialize::<VoteStateUpdate, 1232>(&huge).is_err());
+ let mut vote = 1u64.to_le_bytes().to_vec();
+ vote.extend_from_slice(&42u64.to_le_bytes());
+ vote.extend_from_slice(&[0; 32]);
+ vote.push(0);
+ assert_eq!(
+ limited_deserialize::<Vote, 1232>(&vote).unwrap().slots,
+ [42]
+ );
+ let mut update = 1u64.to_le_bytes().to_vec();
+ update.extend_from_slice(&42u64.to_le_bytes());
+ update.extend_from_slice(&3u32.to_le_bytes());
+ update.push(0);
+ update.extend_from_slice(&[0; 32]);
+ update.push(0);
+ let parsed = limited_deserialize::<VoteStateUpdate, 1232>(&update).unwrap();
+ assert_eq!(parsed.lockouts[0].slot, 42);
+ assert_eq!(parsed.lockouts[0].confirmation_count, 3);
+ }
+
+ #[test]
+ fn enforces_decode_limit_and_exact_consumption() {
+ let mut data = 3u64.to_le_bytes().to_vec();
+ data.extend_from_slice(b"abc");
+ assert_eq!(limited_deserialize::<String, 11>(&data).unwrap(), "abc");
+ assert!(limited_deserialize::<String, 10>(&data).is_err());
+ data.push(0);
+ assert!(limited_deserialize::<String, 1232>(&data).is_err());
+ assert!(limited_deserialize::<String, 1232>(&1233u64.to_le_bytes()).is_err());
+ }
+ }
}
pub mod pubkey {
### rust/apps/solana/src/solana_lib/solana_program/vote.rs
@@ -7,6 +7,55 @@ pub mod state {
use alloc::vec::Vec;
use serde_derive::{Deserialize, Serialize};
+ fn bounded_sequence<'de, D, T, const MAX: usize>(deserializer: D) -> Result<Vec<T>, D::Error>
+ where
+ D: serde::Deserializer<'de>,
+ T: serde::Deserialize<'de>,
+ {
+ struct Visitor<T, const MAX: usize>(core::marker::PhantomData<T>);
+ impl<'de, T: serde::Deserialize<'de>, const MAX: usize> serde::de::Visitor<'de>
+ for Visitor<T, MAX>
+ {
+ type Value = Vec<T>;
+ fn expecting(&self, formatter: &mut core::fmt::Formatter) -> core::fmt::Result {
+ formatter.write_str("a bounded vote sequence")
+ }
+ fn visit_seq<A: serde::de::SeqAccess<'de>>(
+ self,
+ mut seq: A,
+ ) -> Result<Vec<T>, A::Error> {
+ if seq.size_hint().is_some_and(|size| size > MAX) {
+ return Err(serde::de::Error::custom(
+ "vote sequence exceeds instruction limit",
+ ));
+ }
+ let mut values = Vec::new();
+ while let Some(value) = seq.next_element()? {
+ if values.len() == MAX {
+ return Err(serde::de::Error::custom(
+ "vote sequence exceeds instruction limit",
+ ));
+ }
+ values.push(value);
+ }
+ Ok(values)
+ }
+ }
+ deserializer.deserialize_seq(Visitor::<T, MAX>(core::marker::PhantomData))
+ }
+
+ fn deserialize_slots<'de, D: serde::Deserializer<'de>>(
+ deserializer: D,
+ ) -> Result<Vec<Slot>, D::Error> {
+ bounded_sequence::<D, Slot, { 1232 / 8 }>(deserializer)
+ }
+
+ fn deserialize_lockouts<'de, D: serde::Deserializer<'de>>(
+ deserializer: D,
+ ) -> Result<VecDeque<Lockout>, D::Error> {
+ bounded_sequence::<D, Lockout, { 1232 / 12 }>(deserializer).map(VecDeque::from)
+ }
+
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
pub struct VoteInit {
pub node_pubkey: Pubkey,
@@ -45,6 +94,7 @@ pub mod state {
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
pub struct Vote {
/// A stack of votes starting with the oldest vote
+ #[serde(deserialize_with = "deserialize_slots")]
pub slots: Vec<Slot>,
/// signature of the bank's state at the last slot
pub hash: Hash,
@@ -61,6 +111,7 @@ pub mod state {
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
pub struct VoteStateUpdate {
/// The proposed tower
+ #[serde(deserialize_with = "deserialize_lockouts")]
pub lockouts: VecDeque<Lockout>,
/// The proposed root
pub root: Option<Slot>,
### rust/apps/solana/src/solana_lib/spl/token.rs
@@ -440,121 +440,111 @@ pub mod instruction {
use TokenError::InvalidInstruction;
let (&tag, rest) = input.split_first().ok_or(InvalidInstruction)?;
- Ok(match tag {
+ let (instruction, remaining) = match tag {
0 => {
let (&decimals, rest) = rest.split_first().ok_or(InvalidInstruction)?;
let (mint_authority, rest) = Self::unpack_pubkey(rest)?;
- let (freeze_authority, _rest) = Self::unpack_pubkey_option(rest)?;
- Self::InitializeMint {
- mint_authority,
- freeze_authority,
- decimals,
- }
+ let (freeze_authority, remaining) = Self::unpack_pubkey_option(rest)?;
+ (
+ Self::InitializeMint {
+ mint_authority,
+ freeze_authority,
+ decimals,
+ },
+ remaining,
+ )
}
- 1 => Self::InitializeAccount,
+ 1 => (Self::InitializeAccount, rest),
2 => {
- let &m = rest.get(0).ok_or(InvalidInstruction)?;
- Self::InitializeMultisig { m }
+ let (&m, remaining) = rest.split_first().ok_or(InvalidInstruction)?;
+ (Self::InitializeMultisig { m }, remaining)
}
3 | 4 | 7 | 8 => {
- let amount = rest
- .get(..8)
- .and_then(|slice| slice.try_into().ok())
+ let amount_bytes = rest.get(..8).ok_or(InvalidInstruction)?;
+ let amount = amount_bytes
+ .try_into()
+ .ok()
.map(u64::from_le_bytes)
.ok_or(InvalidInstruction)?;
- match tag {
+ let remaining = rest.get(8..).ok_or(InvalidInstruction)?;
+ let instruction = match tag {
3 => Self::Transfer { amount },
4 => Self::Approve { amount },
7 => Self::MintTo { amount },
8 => Self::Burn { amount },
_ => unreachable!(),
- }
+ };
+ (instruction, remaining)
}
- 5 => Self::Revoke,
+ 5 => (Self::Revoke, rest),
6 => {
let (authority_type, rest) = rest
.split_first()
.ok_or_else(|| ProgramError::from(InvalidInstruction))
.and_then(|(&t, rest)| Ok((AuthorityType::from(t)?, rest)))?;
- let (new_authority, _rest) = Self::unpack_pubkey_option(rest)?;
-
- Self::SetAuthority {
- authority_type,
- new_authority,
- }
- }
- 9 => Self::CloseAccount,
- 10 => Self::FreezeAccount,
- 11 => Self::ThawAccount,
- 12 => {
- let (amount, rest) = rest.split_at(8);
- let amount = amount
- .try_into()
- .ok()
- .map(u64::from_le_bytes)
- .ok_or(InvalidInstruction)?;
- let (&decimals, _rest) = rest.split_first().ok_or(InvalidInstruction)?;
-
- Self::TransferChecked { amount, decimals }
- }
- 13 => {
- let (amount, rest) = rest.split_at(8);
- let amount = amount
- .try_into()
- .ok()
- .map(u64::from_le_bytes)
- .ok_or(InvalidInstruction)?;
- let (&decimals, _rest) = rest.split_first().ok_or(InvalidInstruction)?;
-
- Self::ApproveChecked { amount, decimals }
- }
- 14 => {
- let (amount, rest) = rest.split_at(8);
- let amount = amount
- .try_into()
- .ok()
- .map(u64::from_le_bytes)
- .ok_or(InvalidInstruction)?;
- let (&decimals, _rest) = rest.split_first().ok_or(InvalidInstruction)?;
-
- Self::MintToChecked { amount, decimals }
+ let (new_authority, remaining) = Self::unpack_pubkey_option(rest)?;
+ (
+ Self::SetAuthority {
+ authority_type,
+ new_authority,
+ },
+ remaining,
+ )
}
- 15 => {
- let (amount, rest) = rest.split_at(8);
- let amount = amount
+ 9 => (Self::CloseAccount, rest),
+ 10 => (Self::FreezeAccount, rest),
+ 11 => (Self::ThawAccount, rest),
+ 12 | 13 | 14 | 15 => {
+ let amount_bytes = rest.get(..8).ok_or(InvalidInstruction)?;
+ let amount = amount_bytes
.try_into()
.ok()
.map(u64::from_le_bytes)
.ok_or(InvalidInstruction)?;
- let (&decimals, _rest) = rest.split_first().ok_or(InvalidInstruction)?;
-
- Self::BurnChecked { amount, decimals }
+ let rest = rest.get(8..).ok_or(InvalidInstruction)?;
+ let (&decimals, remaining) = rest.split_first().ok_or(InvalidInstruction)?;
+ let instruction = match tag {
+ 12 => Self::TransferChecked { amount, decimals },
+ 13 => Self::ApproveChecked { amount, decimals },
+ 14 => Self::MintToChecked { amount, decimals },
+ 15 => Self::BurnChecked { amount, decimals },
+ _ => unreachable!(),
+ };
+ (instruction, remaining)
}
16 => {
- let (owner, _rest) = Self::unpack_pubkey(rest)?;
- Self::InitializeAccount2 { owner }
+ let (owner, remaining) = Self::unpack_pubkey(rest)?;
+ (Self::InitializeAccount2 { owner }, remaining)
}
- 17 => Self::SyncNative,
+ 17 => (Self::SyncNative, rest),
18 => {
- let (owner, _rest) = Self::unpack_pubkey(rest)?;
- Self::InitializeAccount3 { owner }
+ let (owner, remaining) = Self::unpack_pubkey(rest)?;
+ (Self::InitializeAccount3 { owner }, remaining)
}
19 => {
- let &m = rest.get(0).ok_or(InvalidInstruction)?;
- Self::InitializeMultisig2 { m }
+ let (&m, remaining) = rest.split_first().ok_or(InvalidInstruction)?;
+ (Self::InitializeMultisig2 { m }, remaining)
}
20 => {
let (&decimals, rest) = rest.split_first().ok_or(InvalidInstruction)?;
let (mint_authority, rest) = Self::unpack_pubkey(rest)?;
- let (freeze_authority, _rest) = Self::unpack_pubkey_option(rest)?;
- Self::InitializeMint2 {
- mint_authority,
- freeze_authority,
- decimals,
- }
+ let (freeze_authority, remaining) = Self::unpack_pubkey_option(rest)?;
+ (
+ Self::InitializeMint2 {
+ mint_authority,
+ freeze_authority,
+ decimals,
+ },
+ remaining,
+ )
}
_ => return Err(TokenError::InvalidInstruction.into()),
- })
+ };
+
+ if !remaining.is_empty() {
+ return Err(InvalidInstruction.into());
+ }
+ Ok(instruction)
}
fn unpack_pubkey(input: &[u8]) -> Result<(Pubkey, &[u8]), ProgramError> {
@@ -579,4 +569,42 @@ pub mod instruction {
}
}
}
+
+ #[cfg(test)]
+ mod tests {
+ use super::TokenInstruction;
+
+ #[test]
+ fn checked_amount_instructions_reject_short_and_trailing_data() {
+ for tag in 12u8..=15 {
+ for payload_len in 0..8 {
+ let mut data = vec![tag];
+ data.extend(core::iter::repeat(0x11).take(payload_len));
+ assert!(
+ TokenInstruction::unpack(&data).is_err(),
+ "tag={tag}, len={payload_len}"
+ );
+ }
+
+ let mut valid = vec![tag];
+ valid.extend_from_slice(&1u64.to_le_bytes());
+ valid.push(6);
+ assert!(TokenInstruction::unpack(&valid).is_ok(), "tag={tag}");
+
+ valid.push(0xaa);
+ assert!(
+ TokenInstruction::unpack(&valid).is_err(),
+ "tag={tag} accepted trailing data"
+ );
+ }
+ }
+
+ #[test]
+ fn fixed_length_instructions_reject_trailing_data() {
+ for tag in [1u8, 5, 9, 10, 11, 17] {
+ assert!(TokenInstruction::unpack(&[tag]).is_ok(), "tag={tag}");
+ assert!(TokenInstruction::unpack(&[tag, 0xaa]).is_err(), "tag={tag}");
+ }
+ }
+ }
}
### rust/apps/solana/src/solana_lib/spl/token_lending/mod.rs
@@ -353,6 +353,17 @@ pub mod instruction {
let (&tag, rest) = input
.split_first()
.ok_or(LendingError::InstructionUnpackError)?;
+ let expected_len = match tag {
+ 0 => 64,
+ 1 => 32,
+ 2 => 32,
+ 3 | 6 | 7 => 0,
+ 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 => 8,
+ _ => return Err(LendingError::InstructionUnpackError.into()),
+ };
+ if rest.len() != expected_len {
+ return Err(LendingError::InstructionUnpackError.into());
+ }
Ok(match tag {
0 => {
let (owner, rest) = Self::unpack_pubkey(rest)?;
@@ -485,4 +496,42 @@ pub mod instruction {
Ok((pk, rest))
}
}
+
+ #[cfg(test)]
+ mod tests {
+ use super::LendingInstruction;
+
+ #[test]
+ fn rejects_short_and_trailing_lending_data() {
+ for (tag, body_len) in [
+ (0u8, 64usize),
+ (1, 32),
+ (2, 32),
+ (3, 0),
+ (4, 8),
+ (5, 8),
+ (6, 0),
+ (7, 0),
+ (8, 8),
+ (9, 8),
+ (10, 8),
+ (11, 8),
+ (12, 8),
+ (13, 8),
+ ] {
+ let mut valid = vec![tag];
+ valid.extend(core::iter::repeat(0).take(body_len));
+ assert!(LendingInstruction::unpack(&valid).is_ok(), "tag={tag}");
+
+ if body_len > 0 {
+ let mut short = valid.clone();
+ short.pop();
+ assert!(LendingInstruction::unpack(&short).is_err(), "tag={tag}");
+ }
+
+ valid.push(0xaa);
+ assert!(LendingInstruction::unpack(&valid).is_err(), "tag={tag}");
+ }
+ }
+ }
}
### rust/apps/solana/src/solana_lib/spl/token_swap/mod.rs
@@ -182,6 +182,15 @@ pub mod instruction {
/// Unpacks a byte buffer into a [SwapInstruction](enum.SwapInstruction.html).
pub fn unpack(input: &[u8]) -> Result<Self, ProgramError> {
let (&tag, rest) = input.split_first().ok_or(SwapError::InvalidInstruction)?;
+ let expected_len = match tag {
+ 0 => Fees::LEN + SwapCurve::LEN,
+ 1 | 4 | 5 => 16,
+ 2 | 3 => 24,
+ _ => return Err(SwapError::InvalidInstruction.into()),
+ };
+ if rest.len() != expected_len {
+ return Err(SwapError::InvalidInstruction.into());
+ }
Ok(match tag {
0 => {
if rest.len() >= Fees::LEN {
@@ -257,4 +266,25 @@ pub mod instruction {
}
}
}
+
+ #[cfg(test)]
+ mod tests {
+ use super::SwapInstruction;
+
+ #[test]
+ fn rejects_short_and_trailing_swap_data() {
+ for (tag, body_len) in [(1u8, 16usize), (2, 24), (3, 24), (4, 16), (5, 16)] {
+ let mut valid = vec![tag];
+ valid.extend(core::iter::repeat(0).take(body_len));
+ assert!(SwapInstruction::unpack(&valid).is_ok(), "tag={tag}");
+
+ let mut short = valid.clone();
+ short.pop();
+ assert!(SwapInstruction::unpack(&short).is_err(), "tag={tag}");
+
+ valid.push(0xaa);
+ assert!(SwapInstruction::unpack(&valid).is_err(), "tag={tag}");
+ }
+ }
+ }
}
### rust/apps/solana/src/solana_lib/squads_v4/instructions.rs
@@ -80,8 +80,94 @@ pub struct ProposalVoteArgs {
pub memo: Option<String>,
}
+#[derive(BorshDeserialize, Serialize, Debug, Clone)]
+pub struct ConfigTransactionCreateArgs {
+ pub actions: Vec<ConfigAction>,
+ pub memo: Option<String>,
+}
+
+fn serialize_pubkey<S: serde::Serializer>(
+ key: &Pubkey,
+ serializer: S,
+) -> core::result::Result<S::Ok, S::Error> {
+ serializer.collect_str(key)
+}
+
+fn serialize_pubkeys<S: serde::Serializer>(
+ keys: &[Pubkey],
+ serializer: S,
+) -> core::result::Result<S::Ok, S::Error> {
+ use alloc::string::ToString;
+ serde::Serialize::serialize(
+ &keys.iter().map(ToString::to_string).collect::<Vec<_>>(),
+ serializer,
+ )
+}
+
+fn serialize_optional_pubkey<S: serde::Serializer>(
+ key: &Option<Pubkey>,
+ serializer: S,
+) -> core::result::Result<S::Ok, S::Error> {
+ use alloc::string::ToString;
+ serde::Serialize::serialize(&key.as_ref().map(ToString::to_string), serializer)
+}
+
+#[derive(BorshDeserialize, Serialize, Debug, Clone)]
+pub struct ConfigMember {
+ #[serde(serialize_with = "serialize_pubkey")]
+ pub key: Pubkey,
+ pub permissions: Permissions,
+}
+
+#[derive(BorshDeserialize, Serialize, Debug, Clone)]
+pub enum ConfigAction {
+ AddMember {
+ new_member: ConfigMember,
+ },
+ RemoveMember {
+ #[serde(serialize_with = "serialize_pubkey")]
+ old_member: Pubkey,
+ },
+ ChangeThreshold {
+ new_threshold: u16,
+ },
+ SetTimeLock {
+ new_time_lock: u32,
+ },
+ AddSpendingLimit {
+ #[serde(serialize_with = "serialize_pubkey")]
+ create_key: Pubkey,
+ vault_index: u8,
+ #[serde(serialize_with = "serialize_pubkey")]
+ mint: Pubkey,
+ amount: u64,
+ period: SpendingLimitPeriod,
+ #[serde(serialize_with = "serialize_pubkeys")]
+ members: Vec<Pubkey>,
+ #[serde(serialize_with = "serialize_pubkeys")]
+ destinations: Vec<Pubkey>,
+ },
+ RemoveSpendingLimit {
+ #[serde(serialize_with = "serialize_pubkey")]
+ spending_limit: Pubkey,
+ },
+ SetRentCollector {
+ #[serde(serialize_with = "serialize_optional_pubkey")]
+ new_rent_collector: Option<Pubkey>,
+ },
+}
+
+#[derive(BorshDeserialize, Serialize, Debug, Clone)]
+pub enum SpendingLimitPeriod {
+ OneTime,
+ Day,
+ Week,
+ Month,
+}
+
#[derive(Debug)]
pub enum SquadsInstructions {
+ ConfigTransactionCreate(ConfigTransactionCreateArgs),
MultisigCreate(MultisigCreateArgs),
MultisigCreateV2(MultisigCreateArgsV2),
ProposalActivate,
@@ -102,6 +188,21 @@ impl Dispatch for SquadsInstructions {
let ix_type = &data[..8];
let ix_data = &data[8..];
match hex::encode(ix_type).as_str() {
+ "9bec57e4894b5127" => {
+ let args = from_slice::<ConfigTransactionCreateArgs>(ix_data)
+ .map_err(|_| SquadsV4Error::InvalidInstruction)?;
+ if args.actions.is_empty()
+ || args
+ .actions
+ .iter()
+ .filter(|action| matches!(action, ConfigAction::ChangeThreshold { .. }))
+ .count()
+ > 1
+ {
+ return Err(SquadsV4Error::InvalidInstruction.into());
+ }
+ Ok(SquadsInstructions::ConfigTransactionCreate(args))
+ }
"7a4d509f54585ac5" => {
// sighash(SIGHASH_GLOBAL_NAMESPACE, "multisig_create")
Ok(SquadsInstructions::MultisigCreate(
@@ -125,6 +226,9 @@ impl Dispatch for SquadsInstructions {
}
"0b225cf89a1b336a" => {
// sighash(SIGHASH_GLOBAL_NAMESPACE, "proposal_activate")
+ if !ix_data.is_empty() {
+ return Err(SquadsV4Error::InvalidInstruction.into());
+ }
Ok(SquadsInstructions::ProposalActivate)
}
"9025a488bcd82af8" => {
@@ -158,6 +262,9 @@ impl Dispatch for SquadsInstructions {
}
"c208a15799a419ab" => {
// sighash(SIGHASH_GLOBAL_NAMESPACE,VaultTransactionExecute)
+ if !ix_data.is_empty() {
+ return Err(SquadsV4Error::InvalidInstruction.into());
+ }
Ok(SquadsInstructions::VaultTransactionExecute)
}
_ => Err(SquadsV4Error::UnknownSquadV4Instruction.into()),
@@ -172,6 +279,114 @@ mod tests {
use super::*;
+ #[test]
+ fn rejects_repeated_threshold_changes_even_when_equal_or_separated() {
+ for actions in [
+ vec![2, 3, 0, 2, 1, 0],
+ vec![2, 3, 0, 2, 3, 0],
+ vec![2, 3, 0, 3, 60, 0, 0, 0, 2, 1, 0],
+ ] {
+ let count = if actions.len() == 6 { 2u32 } else { 3u32 };
+ let mut data = hex::decode("9bec57e4894b5127").unwrap();
+ data.extend_from_slice(&count.to_le_bytes());
+ data.extend_from_slice(&actions);
+ data.push(0);
+ assert!(SquadsInstructions::dispatch(&data).is_err());
+ }
+ let data = hex::decode("9bec57e4894b512702000000020300033c00000000").unwrap();
+ assert!(SquadsInstructions::dispatch(&data).is_ok());
+ }
+
+ #[test]
+ fn parses_config_transaction_create_and_rejects_malformed_fields() {
+ let data = hex::decode("9bec57e4894b51270100000001902cce4c0210897aa154b0529cdf3759e940e07449f7176e4656ca468ace8fbf010400000074657374").unwrap();
+ let SquadsInstructions::ConfigTransactionCreate(args) =
+ SquadsInstructions::dispatch(&data).unwrap()
+ else {
+ panic!("wrong instruction");
+ };
+ assert_eq!(args.memo.as_deref(), Some("test"));
+ assert_eq!(args.actions.len(), 1);
+ assert!(matches!(args.actions[0], ConfigAction::RemoveMember { .. }));
+ let json = serde_json::to_value(&args).unwrap();
+ assert!(json["actions"][0]["RemoveMember"]["old_member"].is_string());
+ for length in 0..data.len() {
+ assert!(SquadsInstructions::dispatch(&data[..length]).is_err());
+ }
+ let mut padded = data.clone();
+ padded.push(0);
+ assert!(SquadsInstructions::dispatch(&padded).is_err());
+ for action in [7u8, 255] {
+ let mut malformed = data.clone();
+ malformed[12] = action;
+ assert!(SquadsInstructions::dispatch(&malformed).is_err());
+ }
+ let mut empty = data[..8].to_vec();
+ empty.extend_from_slice(&[0, 0, 0, 0, 0]);
+ assert!(SquadsInstructions::dispatch(&empty).is_err());
+ }
+
+ #[test]
+ fn decodes_all_config_action_wire_variants() {
+ let key = [42u8; 32];
+ let mut add_member = vec![0];
+ add_member.extend_from_slice(&key);
+ add_member.push(7);
+ let mut remove_member = vec![1];
+ remove_member.extend_from_slice(&key);
+ let mut spending = vec![4];
+ spending.extend_from_slice(&key);
+ spending.push(0);
+ spending.extend_from_slice(&key);
+ spending.extend_from_slice(&100u64.to_le_bytes());
+ spending.push(1);
+ spending.extend_from_slice(&1u32.to_le_bytes());
+ spending.extend_from_slice(&key);
+ spending.extend_from_slice(&0u32.to_le_bytes());
+ let mut remove_spending = vec![5];
+ remove_spending.extend_from_slice(&key);
+ let mut rent = vec![6, 1];
+ rent.extend_from_slice(&key);
+ for (action, name) in [
+ (add_member, "AddMember"),
+ (remove_member, "RemoveMember"),
+ (vec![2, 2, 0], "ChangeThreshold"),
+ (vec![3, 60, 0, 0, 0], "SetTimeLock"),
+ (spending, "AddSpendingLimit"),
+ (remove_spending, "RemoveSpendingLimit"),
+ (rent, "SetRentCollector"),
+ (vec![6, 0], "SetRentCollector"),
+ ] {
+ let mut data = hex::decode("9bec57e4894b5127").unwrap();
+ data.extend_from_slice(&1u32.to_le_bytes());
+ data.extend_from_slice(&action);
+ data.push(0);
+ let SquadsInstructions::ConfigTransactionCreate(args) =
+ SquadsInstructions::dispatch(&data).unwrap()
+ else {
+ panic!("wrong instruction");
+ };
+ let json = serde_json::to_value(&args).unwrap();
+ assert!(json["actions"][0].get(name).is_some());
+ }
+ }
+
+ #[test]
+ fn no_argument_instructions_reject_trailing_bytes() {
+ for discriminator in ["0b225cf89a1b336a", "c208a15799a419ab"] {
+ let data = hex::decode(discriminator).unwrap();
+ assert!(SquadsInstructions::dispatch(&data).is_ok());
+ for length in 0..8 {
+ assert!(SquadsInstructions::dispatch(&data[..length]).is_err());
+ }
+ for suffix in [&[0][..], &[1, 2, 3][..]] {
+ let mut malformed = data.clone();
+ malformed.extend(suffix);
+ assert!(SquadsInstructions::dispatch(&malformed).is_err());
+ }
+ }
+ }
+
#[test]
fn test_parse_instruction_data() {
let data = "7a4d509f54585ac5000200050000002b8d8b3addd92759f55b840c2852f5bd50aee3552fe987ee0d4fe24b9043df8e07f219076b2850cbb770c807661d874e09a7224de024d6579e43cc1df392a12244073b08df2ea93b9fc9ecb8a965773e18c6c8c4f66696dda8eb6ea61ca420700c5607f8b770467b0eaae4e081f7e4b66db848c91d63a4f3de46092fe5ccff4427dec50793479bb7ee58060b82e4bdba7ec1a026bacabbb96a8d1c72f21f2a1dd98ad8de070000000001300000007b226e223a22544553544d554c5449534947222c2264223a2254455354204d554c544920534947222c2269223a22227d";
### rust/apps/solana/src/structs.rs
@@ -7,10 +7,16 @@ pub struct SolanaMessage {
pub raw_message: String,
pub utf8_message: String,
pub from: String,
+ pub message_length: usize,
}
impl SolanaMessage {
- pub fn from(raw_message: String, utf8_message: String, from: &String) -> Result<Self> {
+ pub fn from(
+ raw_message: String,
+ utf8_message: String,
+ from: &String,
+ message_length: usize,
+ ) -> Result<Self> {
let from_address = if from.is_empty() {
"".to_string()
} else {
@@ -20,6 +26,7 @@ impl SolanaMessage {
raw_message,
utf8_message,
from: from_address,
+ message_length,
})
}
}
### rust/apps/solana/src/utils.rs
@@ -41,29 +41,9 @@ pub fn format_token_amount(amount: &str, decimals: u8) -> Result<String> {
Ok(result)
}
-// tokenAmount to human readable
-pub fn token_amount_to_human_readable(token_amount: u64, decimals: u32) -> f64 {
- token_amount as f64 / 10u64.pow(decimals) as f64
-}
-
#[cfg(test)]
mod tests {
use super::*;
- // https://solscan.io/tx/63W8ceGvHycrseQaedkacoVnassLq4VpRdjx23fVYZnqRzwBQeTgjZL5GdNVf9B5gkJMgkF66W643T5BduWMWpis
- #[test]
- fn test_token_amount_to_human_readable() {
- assert_eq!(token_amount_to_human_readable(574810, 6), 0.57481);
- }
-
- #[test]
- fn test_token_amount_to_human_readable_2() {
- assert_eq!(token_amount_to_human_readable(10000, 8), 0.0001);
- }
-
- #[test]
- fn test_token_amount_to_human_readable_3() {
- assert_eq!(token_amount_to_human_readable(10000, 0), 10000.0);
- }
#[test]
fn formats_large_token_amounts_without_floating_point() {
### rust/apps/tron/src/address.rs
@@ -11,18 +11,22 @@ use keystore::algorithms::secp256k1::derive_public_key;
macro_rules! check_hd_path {
($t: expr) => {{
let mut result: Result<()> = Ok(());
- if $t.len() < 5 || $t.len() > 6 {
- result = Err(TronError::InvalidHDPath(format!("Length error: {:?}", $t)));
- } else {
- let coin_type_idx = if $t.len() == 6 { 2 } else { 1 };
- let coin_type = $t[coin_type_idx];
-
- if coin_type != "194'" && coin_type != "195'" {
- result = Err(TronError::InvalidHDPath(format!(
- "Coin type mismatch: {}",
- coin_type
- )));
- }
+ if $t.len() != 6
+ || ($t[0] != "m" && $t[0] != "M")
+ || $t[1] != "44'"
+ || $t[2] != "195'"
+ || $t[3] != "0'"
+ || $t[4] != "0"
+ || $t[5].is_empty()
+ || $t[5].ends_with("'")
+ || $t[5]
+ .parse::<u32>()
+ .map_or(true, |index| index >= (1 << 31))
+ {
+ result = Err(TronError::InvalidHDPath(format!(
+ "expected m/44'/195'/0'/0/index, got {:?}",
+ $t
+ )));
}
result
}};
@@ -43,16 +47,20 @@ macro_rules! derivation_address_path {
}};
}
-pub fn get_address(path: String, extended_pub_key: &String) -> Result<String> {
+pub fn validate_derivation_path(path: &str) -> Result<()> {
+ let parts = path.split('/').collect::<Vec<&str>>();
+ check_hd_path!(parts)
+}
+
+pub fn get_public_key(path: &str, extended_pub_key: &str) -> Result<PublicKey> {
let derivation_path = derivation_address_path!(path)?;
- let pubkey = derive_public_key(extended_pub_key, &derivation_path)?;
- let pubkey_bytes = pubkey.serialize_uncompressed();
- let hash = keccak256(&pubkey_bytes[1..]);
- let mut address_bytes = [0u8; 21];
- address_bytes[0] = 0x41;
- address_bytes[1..].copy_from_slice(&hash[hash.len() - 20..]);
- let address = base58::encode_check(&address_bytes);
- Ok(address.to_string())
+ let pubkey = derive_public_key(&extended_pub_key.to_string(), &derivation_path)?;
+ Ok(pubkey)
+}
+
+pub fn get_address(path: String, extended_pub_key: &String) -> Result<String> {
+ let pubkey = get_public_key(&path, extended_pub_key)?;
+ Ok(public_key_to_address(&pubkey))
}
pub fn public_key_to_address(public_key: &PublicKey) -> String {
@@ -91,5 +99,15 @@ mod tests {
let address = get_address(path.to_string(), &extended_pub_key.to_string()).unwrap();
assert_eq!("TYJPRrdB5APNeRs4R7fYZSwW3TcrTKw2gx".to_string(), address);
}
+ for invalid in [
+ "m/44'/195'/0'/0",
+ "m/44'/195'/1'/0/0",
+ "m/44'/194'/0'/0/0",
+ "m/44'/195'/0'/1/0",
+ "m/44'/195'/0'/0/0'",
+ "m/44'/195'/0'/0/2147483648",
+ ] {
+ assert!(get_address(invalid.to_string(), &extended_pub_key.to_string()).is_err());
+ }
}
}
### rust/apps/tron/src/lib.rs
@@ -19,7 +19,7 @@ pub mod structs;
mod transaction;
mod utils;
-pub use crate::address::get_address;
+pub use crate::address::{get_address, get_public_key, validate_derivation_path};
use crate::structs::PersonalMessage;
pub use crate::transaction::parser::{DetailTx, OverviewTx, ParsedTx, TxParser};
use crate::transaction::wrapped_tron::WrappedTron;
@@ -30,12 +30,24 @@ use bitcoin::secp256k1::PublicKey;
use transaction::checker::TxChecker;
use transaction::signer::Signer;
+pub const MAX_SIGN_DATA_LEN: usize = 16 * 1024;
+
+pub fn validate_sign_data_len(len: usize) -> Result<()> {
+ if len > MAX_SIGN_DATA_LEN {
+ return Err(TronError::InvalidRawTxCryptoBytes(
+ "TRON request exceeds 16 KiB".into(),
+ ));
+ }
+ Ok(())
+}
+
pub fn sign_raw_tx(
raw_tx: protoc::Payload,
context: keystone::ParseContext,
seed: &[u8],
) -> Result<(String, String)> {
let tx = WrappedTron::from_payload(raw_tx, &context)?;
+ tx.check(&context)?;
tx.sign(seed)
}
@@ -54,8 +66,14 @@ fn decode_to_wrapped(sign_data: &[u8], path: String) -> Result<WrappedTron> {
use crate::pb::protocol::Transaction;
use prost::Message;
+ validate_sign_data_len(sign_data.len())?;
let raw_content = RawData::decode(sign_data)
.map_err(|_| TronError::InvalidRawTxCryptoBytes("RawData decode failed".to_string()))?;
+ if raw_content.encode_to_vec() != sign_data {
+ return Err(TronError::InvalidRawTxCryptoBytes(
+ "non-canonical RawData encoding".to_string(),
+ ));
+ }
let raw_tx = Transaction {
raw_data: Some(raw_content),
@@ -93,6 +111,8 @@ pub fn sign_personal_message(
path: &String,
seed: &[u8],
) -> errors::Result<String> {
+ validate_derivation_path(path)?;
+ validate_sign_data_len(sign_data.len())?;
let prefix = b"\x19TRON Signed Message:\n";
let len_str = sign_data.len().to_string();
@@ -120,6 +140,7 @@ pub fn parse_personal_message(
tx_hex: &[u8],
from_key: Option<PublicKey>,
) -> Result<PersonalMessage> {
+ validate_sign_data_len(tx_hex.len())?;
let raw_message = hex::encode(tx_hex);
let utf8_message = match String::from_utf8(tx_hex.to_vec()) {
Ok(utf8_message) => {
@@ -155,11 +176,32 @@ mod test {
base.data.unwrap()
}
+ #[test]
+ fn rejects_oversized_sign_data_before_decoding_or_signing() {
+ assert!(validate_sign_data_len(MAX_SIGN_DATA_LEN).is_ok());
+ let data = vec![0xff; MAX_SIGN_DATA_LEN + 1];
+ let path = "m/44'/195'/0'/0/0".to_string();
+ assert!(parse_tx_request(&data, &path)
+ .unwrap_err()
+ .to_string()
+ .contains("request exceeds"));
+ assert!(parse_personal_message(&data, None)
+ .unwrap_err()
+ .to_string()
+ .contains("request exceeds"));
+ assert!(sign_personal_message(&data, &path, &[0; 64])
+ .unwrap_err()
+ .to_string()
+ .contains("request exceeds"));
+ assert!(parse_personal_message(&data[..MAX_SIGN_DATA_LEN], None).is_ok());
+ }
+
#[test]
fn test_sign_raw_tx() {
- let hex = "1f8b08000000000000030dcebb4ac3501c807153444a17b553e95482501142ce39f99f4b8b83362d74696cd38897eddca205db60ac22d95db49b4fe0e6e8e4e65bf80a6e3e80a083816ffb965fb552df9ce461666c6b9c67cb4c6757cd5fa75aa95739e283419f85eeb7535b4fe2a3a8bea3710a42748cc729621e60a43cc1c17801a2c03166444bd4dc1ef9006d1f7768db47653e6aad5e578f7f6877a3f7e234dd2499f2331adc4c212ff27eb83c97b3dbb8b8be3798c96568c971ecbac99416e32c84d3416f3ebceb47878bc509b91806a3c9a58e23368be77b6bc4c1dda8760046714cb148b154982949b400ad4a8f92960bc23ae5e20a510bda12c9d2006b0bd2d8148ca582045b0f9fcf8dc6cfd753291cbebdefb73ec6ff42b912d514010000";
- let pubkey_str = "xpub6C3ndD75jvoARyqUBTvrsMZaprs2ZRF84kRTt5r9oxKQXn5oFChRRgrP2J8QhykhKACBLF2HxwAh4wccFqFsuJUBBcwyvkyqfzJU5gfn5pY";
- let payload = prepare_payload(hex);
+ let hex = "1f8b08000000000000030dcfbd4ac34000c071220ea58bdaa9742a41a84bc87d27270e9ab61890c4268d54bb5dee2e26607b508b4a9fa26fe01bf8b128f812be82b383b8161703ffe9bffd1a5bad9d64d1374a77470bb334d2dc7436567d1b1e96540920ec6fabb99da5e7716b5f4a4e58ae91e36b221d8272ed088ca04399a058f8b2a09075f62297909e0b39edb9a0ce05dde79faf8f0d3868048f56c7ce2e86d3b13abb35833089f4f4be2a97ca04554cd8eaa13c9d5ca9d0b6b3315d8d4c9f5c0e83597837884fe6f309ba0e719494328d5995ce90050fe3e671c17c0ab9d2bc904011a031a502f202e414032e19c60c78be209e409aab1cfa9041e603c204821ad588ddd7f5baddfefd7c7aff03e1cbdbd13f2aab0f710f010000";
+ let pubkey_str = "xpub6D1AabNHCupeiLM65ZR9UStMhJ1vCpyV4XbZdyhMZBiJXALQtmn9p42VTQckoHVn8WNqS7dqnJokZHAHcHGoaQgmv8D45oNUKx6DZMNZBCd";
+ let mut payload = prepare_payload(hex);
+ payload.xfp = "73c5da0a".to_string();
let context = prepare_parse_context(pubkey_str);
let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
let result = sign_raw_tx(payload, context, &seed);
@@ -208,16 +250,45 @@ mod test {
#[test]
fn test_sign_tx_request() {
+ use crate::pb::protocol::{transaction, TransferContract};
+ use prost::Message;
+ use prost_types::Any;
+
let path = "m/44'/195'/0'/0/0".to_string();
- let mock_pb_hex = "0a0207902208e1b9de559665c6714080c49789bb2c5aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a1541ad8593979840130d222238380b080808080808081215410d292c98a5eca06c2085fff993996423cf66c93b2244a9059cbb0000000000000000000000009bbce520d984c3b95ad10cb4e32a9294e6338da300000000000000000000000000000000000000000000000000000000000f424070c0b6e087bb2c90018094ebdc03";
- let sign_data = hex::decode(mock_pb_hex).unwrap();
+ let transfer = TransferContract {
+ owner_address: bitcoin::base58::decode_check("TUEZSdKsoDHQMeZwihtdoBiN46zxhGWYdH")
+ .unwrap(),
+ to_address: bitcoin::base58::decode_check("TSeJkUh4Qv67VNFwY8LaAxERygNdy6NQZK")
+ .unwrap(),
+ amount: 1,
+ };
+ let raw = transaction::Raw {
+ ref_block_bytes: vec![0, 1],
+ ref_block_hash: vec![2; 8],
+ expiration: 2_000,
+ contract: vec![transaction::Contract {
+ r#type: transaction::contract::ContractType::TransferContract as i32,
+ parameter: Some(Any {
+ type_url: "type.googleapis.com/protocol.TransferContract".to_string(),
+ value: transfer.encode_to_vec(),
+ }),
+ ..Default::default()
+ }],
+ timestamp: 1_000,
+ ..Default::default()
+ };
+ let sign_data = raw.encode_to_vec();
let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
let result = sign_tx_request(&sign_data, &path, &seed);
assert!(result.is_ok());
let sig = result.unwrap();
assert!(!sig.is_empty());
assert_eq!(sig.len(), 130); // 65 bytes in hex = 130 chars
+
+ let mut non_canonical = sign_data.clone();
+ non_canonical.extend_from_slice(&[0xf8, 0x07, 0x01]);
+ assert!(decode_to_wrapped(&non_canonical, path).is_err());
}
#[test]
@@ -244,6 +315,67 @@ mod test {
assert!(matches!(result.unwrap_err(), TronError::NoMyInputs));
}
+ #[test]
+ fn personal_message_rejects_invalid_derivation_paths() {
+ let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
+ for path in [
+ "m/44'/194'/0'/0/0",
+ "m/44'/60'/0'/0/0",
+ "m/44'/195'/1'/0/0",
+ "m/44'/195'/0'/1/0",
+ "m/44'/195'/0'/0",
+ "m/44'/195'/0'/0/0/0",
+ "m/44'/195'/0'/0/0'",
+ "m/44'/195'/0'/0/2147483648",
+ ] {
+ assert!(
+ matches!(
+ sign_personal_message(b"Hello TRON", &path.to_string(), &seed),
+ Err(TronError::InvalidHDPath(_))
+ ),
+ "accepted {path}"
+ );
+ }
+ }
+
+ #[test]
+ fn personal_message_display_matches_recovered_signer() {
+ use bitcoin::bip32::{DerivationPath, Xpriv, Xpub};
+ use bitcoin::secp256k1::{
+ ecdsa::{RecoverableSignature, RecoveryId},
+ Message, Secp256k1,
+ };
+
+ let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
+ let secp = Secp256k1::new();
+ let account = Xpriv::new_master(bitcoin::Network::Bitcoin, &seed)
+ .unwrap()
+ .derive_priv(&secp, &DerivationPath::from_str("m/44'/195'/0'").unwrap())
+ .unwrap();
+ let xpub = Xpub::from_priv(&secp, &account).to_string();
+ for index in [0, 1, 2147483647] {
+ let path = alloc::format!("m/44'/195'/0'/0/{index}");
+ let displayed_key = get_public_key(&path, &xpub).unwrap();
+ let parsed = parse_personal_message(b"Hello TRON", Some(displayed_key)).unwrap();
+ let signature =
+ hex::decode(sign_personal_message(b"Hello TRON", &path, &seed).unwrap()).unwrap();
+ let signature = RecoverableSignature::from_compact(
+ &signature[..64],
+ RecoveryId::from_i32((signature[64] - 27) as i32).unwrap(),
+ )
+ .unwrap();
+ let digest = hashing::keccak256(b"\x19TRON Signed Message:\n10Hello TRON");
+ let recovered = secp
+ .recover_ecdsa(&Message::from_digest_slice(&digest).unwrap(), &signature)
+ .unwrap();
+ assert_eq!(displayed_key, recovered);
+ assert_eq!(
+ parsed.from,
+ Some(crate::address::public_key_to_address(&recovered))
+ );
+ }
+ }
+
#[test]
fn test_sign_personal_message() {
let path = "m/44'/195'/0'/0/0".to_string();
@@ -455,6 +587,6 @@ mod test {
let path = "m/44'/195'/0'/0/0".to_string();
let result = decode_to_wrapped(&encoded, path);
- assert!(result.is_ok());
+ assert!(result.is_err());
}
}
### rust/apps/tron/src/transaction/parser.rs
@@ -28,7 +28,21 @@ pub struct DetailTx {
pub token: String,
pub contract_address: String,
pub memo: String,
+ pub memo_hex: String,
+ pub memo_hash: String,
+ pub fee_limit: String,
+ pub timestamp: String,
pub expiration: String,
+ pub ref_block_num: String,
+ pub ref_block_bytes: String,
+ pub ref_block_hash: String,
+ pub permission_id: String,
+ pub raw_data_hash: String,
+ pub call_value: String,
+ pub call_token_value: String,
+ pub token_id: String,
+ pub call_data: String,
+ pub contract_warning: String,
}
pub trait TxParser {
@@ -60,7 +74,21 @@ impl TxParser for WrappedTron {
contract_address: self.contract_address.to_string(),
token: self.token.to_string(),
memo: self.memo.clone(),
+ memo_hex: self.memo_hex.clone(),
+ memo_hash: self.memo_hash.clone(),
+ fee_limit: self.fee_limit.to_string(),
+ timestamp: self.timestamp.clone(),
expiration: self.expiration.clone(),
+ ref_block_num: self.ref_block_num.clone(),
+ ref_block_bytes: self.ref_block_bytes.clone(),
+ ref_block_hash: self.ref_block_hash.clone(),
+ permission_id: self.permission_id.clone(),
+ raw_data_hash: self.raw_data_hash.clone(),
+ call_value: self.call_value.clone(),
+ call_token_value: self.call_token_value.clone(),
+ token_id: self.token_id.clone(),
+ call_data: self.call_data.clone(),
+ contract_warning: self.contract_warning.clone(),
};
Ok(ParsedTx { overview, detail })
}
@@ -105,6 +133,12 @@ mod tests {
assert_eq!("TRX Transfer".to_string(), parsed_tx.overview.method);
assert!(parsed_tx.detail.contract_address.is_empty());
assert!(parsed_tx.detail.token.is_empty());
+ assert!(!parsed_tx.detail.timestamp.is_empty());
+ assert!(!parsed_tx.detail.expiration.is_empty());
+ assert_eq!(4, parsed_tx.detail.ref_block_bytes.len());
+ assert_eq!(16, parsed_tx.detail.ref_block_hash.len());
+ assert_eq!(64, parsed_tx.detail.memo_hash.len());
+ assert_eq!(64, parsed_tx.detail.raw_data_hash.len());
}
#[test]
### rust/apps/tron/src/transaction/signer.rs
@@ -1,3 +1,4 @@
+use crate::address::public_key_to_address;
use crate::errors::{Result, TronError};
use crate::transaction::wrapped_tron::WrappedTron;
use alloc::borrow::ToOwned;
@@ -15,7 +16,24 @@ pub trait Signer {
}
impl WrappedTron {
+ fn validate_seed_signer(&self, seed: &[u8]) -> Result<()> {
+ let fingerprint = secp256k1::get_master_fingerprint_by_seed(seed)?;
+ if !self.xfp.is_empty()
+ && self.xfp.to_uppercase() != hex::encode(fingerprint).to_uppercase()
+ {
+ return Err(TronError::InvalidParseContext(
+ "request fingerprint does not match signing seed".to_string(),
+ ));
+ }
+ let public_key = secp256k1::get_public_key_by_seed(seed, &self.hd_path)?;
+ if public_key_to_address(&public_key) != self.from {
+ return Err(TronError::NoMyInputs);
+ }
+ Ok(())
+ }
+
fn do_sign_digest(&self, seed: &[u8]) -> Result<[u8; 65]> {
+ self.validate_seed_signer(seed)?;
let sig_hash = self.signature_hash()?;
let message = bitcoin::secp256k1::Message::from_digest_slice(sig_hash.as_slice())
@@ -56,65 +74,175 @@ impl Signer for WrappedTron {
#[cfg(test)]
mod tests {
-
+ use alloc::string::ToString;
use hex;
use crate::test::{prepare_parse_context, prepare_payload};
use crate::transaction::signer::Signer;
use crate::transaction::wrapped_tron::WrappedTron;
+ fn legacy_payload(token: &str, memo: &str) -> ur_registry::pb::protoc::Payload {
+ use ur_registry::pb::protoc::{self, payload, sign_transaction};
+ protoc::Payload {
+ r#type: payload::Type::SignTx as i32,
+ xfp: "73c5da0a".into(),
+ content: Some(payload::Content::SignTx(protoc::SignTransaction {
+ coin_code: "TRON".into(),
+ hd_path: "m/44'/195'/0'/0/0".into(),
+ transaction: Some(sign_transaction::Transaction::TronTx(protoc::TronTx {
+ token: token.into(),
+ contract_address: if token == "USDT" {
+ "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t".into()
+ } else {
+ "".into()
+ },
+ from: "TUEZSdKsoDHQMeZwihtdoBiN46zxhGWYdH".into(),
+ to: "TSeJkUh4Qv67VNFwY8LaAxERygNdy6NQZK".into(),
+ memo: memo.into(),
+ value: "1".into(),
+ latest_block: Some(protoc::LatestBlock {
+ hash: "02".repeat(32),
+ number: 1,
+ timestamp: 1000,
+ }),
+ ..Default::default()
+ })),
+ ..Default::default()
+ })),
+ }
+ }
+
#[test]
- fn test_sign_signature_only_trc20() {
+ fn legacy_trx_trc10_trc20_signatures_match_txid_and_owner() {
+ use bitcoin::secp256k1::{
+ ecdsa::{RecoverableSignature, RecoveryId},
+ Message, Secp256k1,
+ };
+ use cryptoxide::hashing::sha256;
+ use prost::Message as ProstMessage;
+ let xpub = "xpub6D1AabNHCupeiLM65ZR9UStMhJ1vCpyV4XbZdyhMZBiJXALQtmn9p42VTQckoHVn8WNqS7dqnJokZHAHcHGoaQgmv8D45oNUKx6DZMNZBCd";
+ let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
+ for (token, expected_txid) in [
+ (
+ "TRX",
+ "a76505a6accf647950420f1440ead53266b9b97adcd146719abfd4173d856120",
+ ),
+ (
+ "1002000",
+ "85bebc501d6c89b5895728bf54c6bea87d74c7c8f703ad8f2a67beabbffb4ddb",
+ ),
+ (
+ "USDT",
+ "040ddfb423a3e80dbab27562bcc41da547ec86c235aa25a94d0e54fd0bb722bf",
+ ),
+ ] {
+ let payload = legacy_payload(token, "");
+ crate::check_raw_tx(payload.clone(), prepare_parse_context(xpub)).unwrap();
+ let parsed = crate::parse_raw_tx(payload.clone(), prepare_parse_context(xpub)).unwrap();
+ let (signed, txid) =
+ crate::sign_raw_tx(payload, prepare_parse_context(xpub), &seed).unwrap();
+ assert_eq!(txid, expected_txid, "{token}");
+ let bytes = hex::decode(signed).unwrap();
+ let tx = crate::pb::protocol::Transaction::decode(bytes.as_slice()).unwrap();
+ let raw = tx.raw_data.unwrap().encode_to_vec();
+ assert_eq!(hex::encode(sha256(&raw)), expected_txid);
+ assert_eq!(parsed.detail.raw_data_hash, expected_txid);
+ assert_eq!(tx.signature.len(), 1);
+ let sig = &tx.signature[0];
+ let recovered = Secp256k1::new()
+ .recover_ecdsa(
+ &Message::from_digest_slice(&sha256(&raw)).unwrap(),
+ &RecoverableSignature::from_compact(
+ &sig[..64],
+ RecoveryId::from_i32(sig[64] as i32).unwrap(),
+ )
+ .unwrap(),
+ )
+ .unwrap();
+ assert_eq!(
+ crate::address::public_key_to_address(&recovered),
+ parsed.overview.from
+ );
+ assert_eq!(parsed.overview.from, "TUEZSdKsoDHQMeZwihtdoBiN46zxhGWYdH");
+ assert_eq!(
+ hex::encode(sig),
+ crate::sign_tx_request(&raw, &"m/44'/195'/0'/0/0".into(), &seed).unwrap()
+ );
+ }
+ }
+
+ #[test]
+ fn legacy_large_memo_obeys_total_request_limit() {
+ let xpub = "xpub6D1AabNHCupeiLM65ZR9UStMhJ1vCpyV4XbZdyhMZBiJXALQtmn9p42VTQckoHVn8WNqS7dqnJokZHAHcHGoaQgmv8D45oNUKx6DZMNZBCd";
+ for token in ["TRX", "1002000", "USDT"] {
+ assert!(crate::parse_raw_tx(
+ legacy_payload(token, &"a".repeat(2048)),
+ prepare_parse_context(xpub)
+ )
+ .is_ok());
+ let payload = legacy_payload(token, &"a".repeat(crate::MAX_SIGN_DATA_LEN));
+ assert!(
+ crate::parse_raw_tx(payload.clone(), prepare_parse_context(xpub))
+ .unwrap_err()
+ .to_string()
+ .contains("request exceeds")
+ );
+ assert!(crate::check_raw_tx(payload.clone(), prepare_parse_context(xpub)).is_err());
+ assert!(crate::sign_raw_tx(payload, prepare_parse_context(xpub), &[0; 64]).is_err());
+ }
+ }
+
+ #[test]
+ fn test_sign_signature_only_trc20_rejects_wrong_fingerprint() {
let hex = "1f8b08000000000000031590bf4ac3501c46359452bba871299d4a102a42c8bffbbbf7c6499b1403b6b14d52b42e92e426b5c53636462979029d7d01477707279f40147c0007df41707130856f3870a6f355387ebd9f1a098b1abd34c99230b9acbf70158eaf1099b4db26368427ae5af29c639bdf0e98a652d50fc4500922110121a21efb548c028010142d8814bdbed995106a4a8a0e4d492e26c98defb78ffb3f79a7dcfa5ae505cf21b6359f4447fdc5a1678ce99c9e0dd1558726999b8f269d09ceea82e7b96408dab58bd23c358deccc1fdf38f97cc114ec6746a40e1c41f05cc87b89814edbada9756bda07b3d9893ab2b46eff22746c3c76a6bb2b6a49d129d9b3abfb3e8be3400335f4090d3506818c303042402f0c669851888160504286502c2b408b001d01f5fd40d6286c3c7f3ed46a773fef45486bab5a1ab8a6c7af2d6f395f62ad6c3dfee2c66bef1f257dc3fe50010000";
let pubkey_str = "xpub6C3ndD75jvoARyqUBTvrsMZaprs2ZRF84kRTt5r9oxKQXn5oFChRRgrP2J8QhykhKACBLF2HxwAh4wccFqFsuJUBBcwyvkyqfzJU5gfn5pY";
let payload = prepare_payload(hex);
let context = prepare_parse_context(pubkey_str);
- let tx = WrappedTron::from_payload(payload, &context).unwrap();
+ let mut tx = WrappedTron::from_payload(payload, &context).unwrap();
+ tx.xfp = "73c5da0a".to_string();
let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
- let sig = tx.sign_signature_only(&seed).unwrap();
- assert_eq!("d01233804064a481a7e50cfa81007b6a5de8c933e0c08e09fd9bf045c7b70b7f20e262098f42a121cd3de494962215a835e38d220d25eeeefb7df1376bf74b8600", sig);
- assert_eq!(sig.len(), 130);
- assert!(sig.chars().all(|c| c.is_ascii_hexdigit()));
+ assert!(matches!(
+ tx.sign_signature_only(&seed),
+ Err(crate::errors::TronError::NoMyInputs)
+ ));
}
#[test]
- fn test_sign_trx_transfer() {
+ fn test_sign_trx_transfer_rejects_wrong_owner() {
// https://tronscan.org/#/transaction/0f89c6365796afa96ae05fab57207a4d8c5cc801b92ac2099c7dd9dcd5a91df0
// txHex: 0a7c0a02ea0522082c84cb547bae782640b8f3c28bfc305a65080112610a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412300a1541bf90ce9c87c42a58699b1a2e3f65e88181436d53121541b0ca665130d03c977823834e3fcbe63af2421fa1180112411634795a1461b2775648062bcee3675033158557e497f1187d0312ae8e4589d07a22cf3334f4b5c49133ada012ccf308baefb8062e24d22d62f8da0a40716da301
// txId: 0f89c6365796afa96ae05fab57207a4d8c5cc801b92ac2099c7dd9dcd5a91df0
let hex = "1f8b08000000000000030dcebb4ac3501c807153444a17b553e95482501142ce39f99f4b8b83362d74696cd38897eddca205db60ac22d95db49b4fe0e6e8e4e65bf80a6e3e80a083816ffb965fb552df9ce461666c6b9c67cb4c6757cd5fa75aa95739e283419f85eeb7535b4fe2a3a8bea3710a42748cc729621e60a43cc1c17801a2c03166444bd4dc1ef9006d1f7768db47653e6aad5e578f7f6877a3f7e234dd2499f2331adc4c212ff27eb83c97b3dbb8b8be3798c96568c971ecbac99416e32c84d3416f3ebceb47878bc509b91806a3c9a58e23368be77b6bc4c1dda8760046714cb148b154982949b400ad4a8f92960bc23ae5e20a510bda12c9d2006b0bd2d8148ca582045b0f9fcf8dc6cfd753291cbebdefb73ec6ff42b912d514010000";
let pubkey_str = "xpub6C3ndD75jvoARyqUBTvrsMZaprs2ZRF84kRTt5r9oxKQXn5oFChRRgrP2J8QhykhKACBLF2HxwAh4wccFqFsuJUBBcwyvkyqfzJU5gfn5pY";
let payload = prepare_payload(hex);
let context = prepare_parse_context(pubkey_str);
- let tx = WrappedTron::from_payload(payload, &context).unwrap();
+ let mut tx = WrappedTron::from_payload(payload, &context).unwrap();
+ tx.xfp = "73c5da0a".to_string();
let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
- let (raw_hex, tx_id) = tx.sign(&seed).unwrap();
- assert_eq!("0a7c0a02ea0522082c84cb547bae782640b8f3c28bfc305a65080112610a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412300a1541bf90ce9c87c42a58699b1a2e3f65e88181436d53121541b0ca665130d03c977823834e3fcbe63af2421fa118011241fe599fc2386cabae4f7a9478d4ab8116513cb849644b997521f9192e4be74fec7efa3449c806bf0307e53d8ad659bf9d18795c87a059acecbce28de58c43631e01", raw_hex);
- assert_eq!(
- "0f89c6365796afa96ae05fab57207a4d8c5cc801b92ac2099c7dd9dcd5a91df0",
- tx_id
- );
+ assert!(matches!(
+ tx.sign(&seed),
+ Err(crate::errors::TronError::NoMyInputs)
+ ));
}
#[test]
- fn test_sign_trc10_transfer() {
+ fn test_sign_trc10_transfer_rejects_wrong_owner() {
// txHex: 0a8b010a02dd71220897877879243d8e1840d8a6f586fc305a74080212700a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e736665724173736574436f6e7472616374123a0a0731303032303030121541bf90ce9c87c42a58699b1a2e3f65e88181436d531a1541b0ca665130d03c977823834e3fcbe63af2421fa120e80712411c161e9365db1c8e361ba5ba1be8c13ca7dd01b68d9410f62597245fba9955d11cc5999622db1ecf455c84d51ab785dd1e560c078d7886cd85b4839e1d94ac2900
// txId: ce840b7d819b37069268232b4ed4fd49d8ec38141f20301648703cfe4ea0f321
let hex = "1f8b0800000000000003158f3d4bc350188535961ab26833954e21081521e4bd37f723d7499316ba34b669c48f45927b532dd8066315e9eee4e8a24efe0e41f1e7b83ab92898c2339ce53c9ca36be6c6b00c0b955b83b29817b2b86cbd68ba66ea1c78b7db61a1fda019b5243e88ccad2c932af541390c98ef108eb9937a923852082214521268d66af45d42da2e12b4ed42850bd6dfd7c7fd2f6cd783cf55631d01600068d94932e227d4bb1e91725176c2f9693ab9891757770ab1741ee6f830b6ed644417832224c7dd60dabbed44fbb3d9113eef79fde1858c233689a73b2bb85629613732f628833c0720922a210021c17d5e2130f1949f235f88713e56482a9a519a12ce709a7a385355dda33e929bdf6f8fcde6d3f3726dd030d6822431f5e5f5b32a35ebbdd71f66bd0ffe01545edbc933010000";
let pubkey_str = "xpub6C3ndD75jvoARyqUBTvrsMZaprs2ZRF84kRTt5r9oxKQXn5oFChRRgrP2J8QhykhKACBLF2HxwAh4wccFqFsuJUBBcwyvkyqfzJU5gfn5pY";
let payload = prepare_payload(hex);
let context = prepare_parse_context(pubkey_str);
- let tx = WrappedTron::from_payload(payload, &context).unwrap();
+ let mut tx = WrappedTron::from_payload(payload, &context).unwrap();
+ tx.xfp = "73c5da0a".to_string();
let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
- let (raw_hex, tx_id) = tx.sign(&seed).unwrap();
- assert_eq!("0a8b010a02dd71220897877879243d8e1840d8a6f586fc305a74080212700a32747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e736665724173736574436f6e7472616374123a0a0731303032303030121541bf90ce9c87c42a58699b1a2e3f65e88181436d531a1541b0ca665130d03c977823834e3fcbe63af2421fa120e807124143da1e7a627c789e69c340f343b0983244cff5e0cb4214e0372897f1c486a6d62bc0a8c0c9bf6f7210bd4a63ad5205a7f6afa3afa58d1821134f54df52914cd801", raw_hex);
- assert_eq!(
- "ce840b7d819b37069268232b4ed4fd49d8ec38141f20301648703cfe4ea0f321",
- tx_id
- );
+ assert!(matches!(
+ tx.sign(&seed),
+ Err(crate::errors::TronError::NoMyInputs)
+ ));
}
#[test]
- fn test_sign_trc20_transfer() {
+ fn test_sign_trc20_transfer_rejects_wrong_fingerprint() {
{
// txHex: 0ad4010a02e8b32208b0465d7759adf6d640c881858bfc305aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a1541bf90ce9c87c42a58699b1a2e3f65e88181436d53121541a614f803b6fd780986a42c78ec9c7f77e6ded13c2244a9059cbb000000000000000000000000b0ca665130d03c977823834e3fcbe63af2421fa100000000000000000000000000000000000000000000000000000000000007c37088f4cd89fc3090018094ebdc0312413da7ea834760bb30c578c9d58aae22f04c172345e3dc5fa20ebe135e6f4e43776fc74151d2f8a35a93c9e644e6f79b2e4facb8d4803f5ad51455da35e69f60b101
// txId: 762dee17f934b7520a8c83396a823690921355d5160d6848728834fd15dea5c4
@@ -124,12 +252,10 @@ mod tests {
let context = prepare_parse_context(pubkey_str);
let tx = WrappedTron::from_payload(payload, &context).unwrap();
let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
- let (raw_hex, tx_id) = tx.sign(&seed).unwrap();
- assert_eq!("0ad4010a02e8b32208b0465d7759adf6d640c881858bfc305aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a1541bf90ce9c87c42a58699b1a2e3f65e88181436d53121541a614f803b6fd780986a42c78ec9c7f77e6ded13c2244a9059cbb000000000000000000000000b0ca665130d03c977823834e3fcbe63af2421fa100000000000000000000000000000000000000000000000000000000000007c37088f4cd89fc3090018094ebdc031241d01233804064a481a7e50cfa81007b6a5de8c933e0c08e09fd9bf045c7b70b7f20e262098f42a121cd3de494962215a835e38d220d25eeeefb7df1376bf74b8600", raw_hex);
- assert_eq!(
- "762dee17f934b7520a8c83396a823690921355d5160d6848728834fd15dea5c4",
- tx_id
- );
+ assert!(matches!(
+ tx.sign(&seed),
+ Err(crate::errors::TronError::InvalidParseContext(_))
+ ));
}
}
}
### rust/apps/tron/src/transaction/wrapped_tron.rs
@@ -10,7 +10,6 @@ use alloc::vec::Vec;
use alloc::{format, vec};
use app_utils::keystone;
use ascii::AsciiStr;
-use core::str::FromStr;
use cryptoxide::hashing;
use ethabi::{
ethereum_types::{H160, U256},
@@ -36,10 +35,23 @@ pub struct WrappedTron {
pub(crate) value: String,
pub(crate) method: String,
pub(crate) token_short_name: Option<String>,
- pub(crate) divider: f64,
+ pub(crate) decimals: u8,
pub(crate) fee_limit: u64,
pub(crate) memo: String,
+ pub(crate) memo_hex: String,
+ pub(crate) memo_hash: String,
+ pub(crate) timestamp: String,
pub(crate) expiration: String,
+ pub(crate) ref_block_num: String,
+ pub(crate) ref_block_bytes: String,
+ pub(crate) ref_block_hash: String,
+ pub(crate) permission_id: String,
+ pub(crate) raw_data_hash: String,
+ pub(crate) call_value: String,
+ pub(crate) call_token_value: String,
+ pub(crate) token_id: String,
+ pub(crate) call_data: String,
+ pub(crate) contract_warning: String,
}
#[macro_export]
@@ -57,49 +69,80 @@ macro_rules! derivation_account_path {
}};
}
-const KNOWN_TOKENS: &[(&str, &str, f64)] = &[
- ("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "USDT", 1_000_000.0), // 6 decimals
- ("TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8", "USDC", 1_000_000.0), // 6 decimals
- (
- "TUpMhErZL2fhh4sVNULAbNKLokS4GjC1F4",
- "TUSD",
- 1_000_000_000_000_000_000.0,
- ), // 18 decimals
- (
- "TAFjULxiVgT4qWk6UZwjqwZXTSaGaqnVp4",
- "BTT",
- 1_000_000_000_000_000_000.0,
- ), // 18 decimals
- (
- "TCFLL5dx5ZJdKnWuesXxi1VPwjLVmWZZy9",
- "JST",
- 1_000_000_000_000_000_000.0,
- ), // 18 decimals
- ("TFczxzPhnThNSqr5by8tvxsdCFRRz6cPNq", "NFT", 1_000_000.0), // 6 decimals
- (
- "TSSMHYeV2uE9qYH95DqyoCuNCzEL1NvU3S",
- "SUN",
- 1_000_000_000_000_000_000.0,
- ), // 18 decimals
- ("TYhWwKpw43ENFWBTGpzLHn3882f2au7SMi", "WBTC", 100_000_000.0), // 8 decimals
- ("TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR", "WTRX", 1_000_000.0), // 6 decimals
- ("TLa2f6VPqDgRE67v1736s7bJ8Ray5wYjU7", "WIN", 1_000_000.0), // 6 decimals
- (
- "TXDk8mbtRbXeYuMNS83CfKPaYYT8XWv9Hz",
- "USDD",
- 1_000_000_000_000_000_000.0,
- ), // 18 decimals
+const KNOWN_TOKENS: &[(&str, &str, u8)] = &[
+ ("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "USDT", 6),
+ ("TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8", "USDC", 6),
+ ("TUpMhErZL2fhh4sVNULAbNKLokS4GjC1F4", "TUSD", 18),
+ ("TAFjULxiVgT4qWk6UZwjqwZXTSaGaqnVp4", "BTT", 18),
+ ("TCFLL5dx5ZJdKnWuesXxi1VPwjLVmWZZy9", "JST", 18),
+ ("TFczxzPhnThNSqr5by8tvxsdCFRRz6cPNq", "NFT", 6),
+ ("TSSMHYeV2uE9qYH95DqyoCuNCzEL1NvU3S", "SUN", 18),
+ ("TYhWwKpw43ENFWBTGpzLHn3882f2au7SMi", "WBTC", 8),
+ ("TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR", "WTRX", 6),
+ ("TLa2f6VPqDgRE67v1736s7bJ8Ray5wYjU7", "WIN", 6),
+ ("TXDk8mbtRbXeYuMNS83CfKPaYYT8XWv9Hz", "USDD", 18),
];
-fn known_token_metadata(contract_address: &str) -> Option<(&'static str, f64)> {
+fn known_token_metadata(contract_address: &str) -> Option<(&'static str, u8)> {
KNOWN_TOKENS
.iter()
.find(|token| token.0 == contract_address)
.map(|token| (token.1, token.2))
}
+fn invalid_raw(message: &str) -> TronError {
+ TronError::InvalidRawTxCryptoBytes(message.to_string())
+}
+
+fn validate_address_bytes(address: &[u8], field: &str) -> Result<()> {
+ if address.len() != 21 || address[0] != 0x41 {
+ return Err(invalid_raw(&format!("invalid {field} address")));
+ }
+ Ok(())
+}
+
+fn format_decimal_units(raw: &str, decimals: u8) -> Result<String> {
+ if raw.is_empty() || !raw.bytes().all(|b| b.is_ascii_digit()) {
+ return Err(invalid_raw("amount is not an unsigned decimal integer"));
+ }
+ let normalized = raw.trim_start_matches('0');
+ let digits = if normalized.is_empty() {
+ "0"
+ } else {
+ normalized
+ };
+ if decimals == 0 {
+ return Ok(digits.to_string());
+ }
+ let decimals = decimals as usize;
+ let mut formatted = if digits.len() <= decimals {
+ format!("0.{:0>width$}", digits, width = decimals)
+ } else {
+ let split = digits.len() - decimals;
+ format!("{}.{}", &digits[..split], &digits[split..])
+ };
+ while formatted.ends_with('0') {
+ formatted.pop();
+ }
+ if formatted.ends_with('.') {
+ formatted.pop();
+ }
+ Ok(formatted)
+}
+
impl WrappedTron {
pub fn from_raw_transaction(raw_tx: Transaction, path: String) -> Result<Self> {
+ if let Some(raw) = raw_tx.raw_data.as_ref() {
+ crate::validate_sign_data_len(raw.encoded_len())?;
+ if !raw.auths.is_empty() || !raw.scripts.is_empty() {
+ return Err(invalid_raw("unsupported TRON auths or scripts"));
+ }
+ if raw.ref_block_num < 0 {
+ return Err(invalid_raw("negative ref block number"));
+ }
+ }
+ let path_parts = path.split('/').collect::<Vec<&str>>();
+ crate::check_hd_path!(path_parts)?;
let mut instance = Self {
tron_tx: raw_tx,
hd_path: path,
@@ -111,130 +154,180 @@ impl WrappedTron {
to: String::new(),
value: "0".to_string(),
method: String::new(),
- divider: DIVIDER,
+ decimals: DEFAULT_DECIMALS,
token_short_name: None,
fee_limit: 0,
memo: String::new(),
+ memo_hex: String::new(),
+ memo_hash: String::new(),
+ timestamp: String::new(),
expiration: String::new(),
+ ref_block_num: String::new(),
+ ref_block_bytes: String::new(),
+ ref_block_hash: String::new(),
+ permission_id: String::new(),
+ raw_data_hash: String::new(),
+ call_value: String::new(),
+ call_token_value: String::new(),
+ token_id: String::new(),
+ call_data: String::new(),
+ contract_warning: String::new(),
};
- if let Some(raw) = &instance.tron_tx.raw_data {
- instance.fee_limit = raw.fee_limit as u64;
- instance.memo = String::from_utf8_lossy(&raw.data).to_string();
- if raw.contract.len() > 1 {
- return Err(TronError::InvalidRawTxCryptoBytes(
- "multiple contracts require a complete review".to_string(),
- ));
+ let raw = instance
+ .tron_tx
+ .raw_data
+ .as_ref()
+ .ok_or_else(|| invalid_raw("empty raw data"))?;
+ if raw.contract.len() != 1 {
+ return Err(invalid_raw("exactly one contract is required"));
+ }
+ if raw.ref_block_bytes.len() != 2 || raw.ref_block_hash.len() != 8 {
+ return Err(invalid_raw("invalid ref block fields"));
+ }
+ if raw.timestamp <= 0 || raw.expiration <= raw.timestamp || raw.fee_limit < 0 {
+ return Err(invalid_raw("invalid timestamp, expiration, or fee limit"));
+ }
+
+ instance.fee_limit = raw.fee_limit as u64;
+ instance.memo = String::from_utf8(raw.data.clone())
+ .ok()
+ .filter(|memo| !memo.contains('\0'))
+ .unwrap_or_default();
+ instance.memo_hex = hex::encode(&raw.data);
+ instance.memo_hash = hex::encode(hashing::sha256(&raw.data));
+ instance.timestamp = raw.timestamp.to_string();
+ instance.expiration = raw.expiration.to_string();
+ instance.ref_block_num = raw.ref_block_num.to_string();
+ instance.ref_block_bytes = hex::encode(&raw.ref_block_bytes);
+ instance.ref_block_hash = hex::encode(&raw.ref_block_hash);
+ let raw_bytes = raw.encode_to_vec();
+ instance.raw_data_hash = hex::encode(hashing::sha256(&raw_bytes));
+
+ let contract = &raw.contract[0];
+ if !contract.provider.is_empty()
+ || !contract.contract_name.is_empty()
+ || contract.permission_id < 0
+ {
+ return Err(invalid_raw("unsupported contract metadata"));
+ }
+ instance.permission_id = contract.permission_id.to_string();
+ let param = contract
+ .parameter
+ .as_ref()
+ .ok_or_else(|| invalid_raw("missing contract parameter"))?;
+ use crate::pb::protocol::transaction::contract::ContractType;
+ let c_type = ContractType::from_i32(contract.r#type)
+ .ok_or_else(|| invalid_raw("unsupported contract type"))?;
+
+ match c_type {
+ ContractType::TransferContract => {
+ if param.type_url != "type.googleapis.com/protocol.TransferContract" {
+ return Err(invalid_raw("TransferContract type_url mismatch"));
+ }
+ let ct = TransferContract::decode(param.value.as_slice())
+ .map_err(|_| invalid_raw("TransferContract decode failed"))?;
+ if ct.encode_to_vec() != param.value {
+ return Err(invalid_raw("non-canonical TransferContract encoding"));
+ }
+ validate_address_bytes(&ct.owner_address, "owner")?;
+ validate_address_bytes(&ct.to_address, "recipient")?;
+ if ct.amount < 0 {
+ return Err(invalid_raw("negative transfer amount"));
+ }
+ instance.from = bitcoin::base58::encode_check(&ct.owner_address);
+ instance.to = bitcoin::base58::encode_check(&ct.to_address);
+ instance.value = ct.amount.to_string();
+ instance.token = String::new();
+ instance.decimals = DEFAULT_DECIMALS;
}
- if let Some(contract) = raw.contract.get(0) {
- use crate::pb::protocol::transaction::contract::ContractType;
- let c_type = ContractType::from_i32(contract.r#type).ok_or(
- TronError::InvalidRawTxCryptoBytes(format!(
- "unsupported contract type {}",
- contract.r#type
- )),
- )?;
-
- if let Some(param) = &contract.parameter {
- match c_type {
- // A. TRX Transfer
- ContractType::TransferContract => {
- let ct =
- TransferContract::decode(param.value.as_slice()).map_err(|_| {
- TronError::InvalidRawTxCryptoBytes(
- "TransferContract decode failed".to_string(),
- )
- })?;
- instance.from = bitcoin::base58::encode_check(&ct.owner_address);
- instance.to = bitcoin::base58::encode_check(&ct.to_address);
- instance.value = ct.amount.to_string();
- instance.token = "TRX".to_string();
- instance.divider = DIVIDER;
- }
-
- // B. TRC-20 Transfer
- ContractType::TriggerSmartContract => {
- let ct = TriggerSmartContract::decode(param.value.as_slice()).map_err(
- |_| {
- TronError::InvalidRawTxCryptoBytes(
- "TriggerSmartContract decode failed".to_string(),
- )
- },
- )?;
- instance.from = bitcoin::base58::encode_check(&ct.owner_address);
- instance.contract_address =
- bitcoin::base58::encode_check(&ct.contract_address);
-
- if ct.data.len() >= 68 && &ct.data[0..4] == &[0xa9, 0x05, 0x9c, 0xbb] {
- instance.method = "TRC-20 Transfer".to_string();
- let mut to_addr_bytes = vec![0x41u8];
- to_addr_bytes.extend_from_slice(&ct.data[16..36]);
- instance.to = bitcoin::base58::encode_check(&to_addr_bytes);
-
- let amount_bytes = &ct.data[36..68];
- instance.value =
- ethabi::ethereum_types::U256::from_big_endian(amount_bytes)
- .to_string();
-
- if let Some((token, divider)) =
- known_token_metadata(&instance.contract_address)
- {
- instance.token = token.to_string();
- instance.divider = divider;
- } else {
- // Unknown token metadata must stay in raw units. A
- // hard-coded decimal count would make the displayed
- // amount look authoritative even though the contract
- // has not been verified.
- instance.token = "TRC20 Token (raw)".to_string();
- instance.divider = 1.0;
- }
- } else if ct.data.len() >= 68
- && &ct.data[0..4] == &[0x09, 0x5e, 0xa7, 0xb3]
- {
- instance.method = "TRC-20 Approve".to_string();
- let mut spender_bytes = vec![0x41u8];
- spender_bytes.extend_from_slice(&ct.data[16..36]);
- instance.to = bitcoin::base58::encode_check(&spender_bytes);
- instance.value =
- U256::from_big_endian(&ct.data[36..68]).to_string();
- if let Some((token, divider)) =
- known_token_metadata(&instance.contract_address)
- {
- instance.token = token.to_string();
- instance.divider = divider;
- } else {
- instance.token = "TRC20 Token (raw)".to_string();
- instance.divider = 1.0;
- }
- } else {
- instance.method = "Contract Call".to_string();
- }
- }
-
- // C. TRC-10 Transfer
- ContractType::TransferAssetContract => {
- let ct = TransferAssetContract::decode(param.value.as_slice())
- .map_err(|_| {
- TronError::InvalidRawTxCryptoBytes(
- "TransferAssetContract decode failed".to_string(),
- )
- })?;
- instance.from = bitcoin::base58::encode_check(&ct.owner_address);
- instance.to = bitcoin::base58::encode_check(&ct.to_address);
- instance.value = ct.amount.to_string();
- instance.token = String::from_utf8_lossy(&ct.asset_name).to_string();
- instance.divider = DIVIDER;
- }
- _ => {
- return Err(TronError::InvalidRawTxCryptoBytes(format!(
- "unsupported contract type {}",
- contract.r#type
- )))
- }
+ ContractType::TriggerSmartContract => {
+ if param.type_url != "type.googleapis.com/protocol.TriggerSmartContract" {
+ return Err(invalid_raw("TriggerSmartContract type_url mismatch"));
+ }
+ let ct = TriggerSmartContract::decode(param.value.as_slice())
+ .map_err(|_| invalid_raw("TriggerSmartContract decode failed"))?;
+ if ct.encode_to_vec() != param.value {
+ return Err(invalid_raw("non-canonical TriggerSmartContract encoding"));
+ }
+ validate_address_bytes(&ct.owner_address, "owner")?;
+ validate_address_bytes(&ct.contract_address, "contract")?;
+ if ct.call_value < 0 || ct.call_token_value < 0 || ct.token_id < 0 {
+ return Err(invalid_raw("negative smart contract value fields"));
+ }
+ if ct.call_token_value > 0 && ct.token_id == 0 {
+ return Err(invalid_raw("missing attached TRC-10 token ID"));
+ }
+ instance.from = bitcoin::base58::encode_check(&ct.owner_address);
+ instance.contract_address = bitcoin::base58::encode_check(&ct.contract_address);
+ instance.call_value = format!(
+ "{} TRX",
+ format_decimal_units(&ct.call_value.to_string(), DEFAULT_DECIMALS)?
+ );
+ if ct.token_id != 0 {
+ instance.call_token_value = ct.call_token_value.to_string();
+ instance.token_id = ct.token_id.to_string();
+ }
+ instance.call_data = format!("0x{}", hex::encode(&ct.data));
+ let selector = ct.data.get(..4);
+ let transfer = selector == Some(&[0xa9, 0x05, 0x9c, 0xbb][..]);
+ let approve = selector == Some(&[0x09, 0x5e, 0xa7, 0xb3][..]);
+ if transfer || approve {
+ if ct.data.len() != 68 || ct.data[4..16].iter().any(|byte| *byte != 0) {
+ return Err(invalid_raw("non-canonical TRC-20 calldata"));
+ }
+ instance.method = if transfer {
+ "TRC-20 Transfer"
+ } else {
+ "TRC-20 Approve"
}
+ .to_string();
+ let mut destination = vec![0x41u8];
+ destination.extend_from_slice(&ct.data[16..36]);
+ instance.to = bitcoin::base58::encode_check(&destination);
+ instance.value = U256::from_big_endian(&ct.data[36..68]).to_string();
+ if let Some((token, decimals)) =
+ known_token_metadata(&instance.contract_address)
+ {
+ instance.token = token.to_string();
+ instance.decimals = decimals;
+ } else {
+ instance.token = "TRC20 Token (raw)".to_string();
+ instance.decimals = 0;
+ }
+ } else {
+ instance.method = "Contract Call".to_string();
+ instance.to = instance.contract_address.clone();
+ instance.value = ct.call_value.to_string();
+ instance.contract_warning = "Unrecognized contract call. The device cannot determine its effects. Verify the contract, attached assets and call data before signing.".to_string();
+ }
+ }
+ ContractType::TransferAssetContract => {
+ if param.type_url != "type.googleapis.com/protocol.TransferAssetContract" {
+ return Err(invalid_raw("TransferAssetContract type_url mismatch"));
+ }
+ let ct = TransferAssetContract::decode(param.value.as_slice())
+ .map_err(|_| invalid_raw("TransferAssetContract decode failed"))?;
+ if ct.encode_to_vec() != param.value {
+ return Err(invalid_raw("non-canonical TransferAssetContract encoding"));
+ }
+ validate_address_bytes(&ct.owner_address, "owner")?;
+ validate_address_bytes(&ct.to_address, "recipient")?;
+ if ct.amount < 0 {
+ return Err(invalid_raw("negative asset transfer amount"));
+ }
+ instance.from = bitcoin::base58::encode_check(&ct.owner_address);
+ instance.to = bitcoin::base58::encode_check(&ct.to_address);
+ instance.value = ct.amount.to_string();
+ instance.token = String::from_utf8(ct.asset_name)
+ .map_err(|_| invalid_raw("invalid TRC-10 asset id"))?;
+ if instance.token.is_empty() || !instance.token.bytes().all(|b| b.is_ascii_digit())
+ {
+ return Err(invalid_raw("invalid TRC-10 asset id"));
}
+ instance.decimals = DEFAULT_DECIMALS;
}
+ _ => return Err(invalid_raw("unsupported contract type")),
}
Ok(instance)
}
@@ -336,27 +429,32 @@ impl WrappedTron {
latest_block: LatestBlock,
is_trc_20: bool,
) -> Result<Transaction> {
- let number_buf: [u8; 8] = (latest_block.number as u64).to_be_bytes();
- let hash_buf = hex::decode(&latest_block.hash).map_err(|_e| {
- TronError::InvalidRawTxCryptoBytes(format!(
- "invalid latest block hash {}",
- latest_block.hash
- ))
- })?;
- let mut generated_block_id = [0u8; 32];
- generated_block_id[..8].copy_from_slice(&number_buf);
- generated_block_id[8..31].copy_from_slice(&hash_buf[8..hash_buf.len() - 1]);
- if let Some(mut raw_data) = tx.raw_data.to_owned() {
- raw_data.ref_block_hash = generated_block_id[8..16].to_vec();
- raw_data.ref_block_bytes = generated_block_id[6..8].to_vec();
- if is_trc_20 {
- raw_data.fee_limit = 1000000000;
- raw_data.timestamp = latest_block.timestamp;
- }
- raw_data.expiration = latest_block.timestamp + 600 * 5 * 1000;
- tx.raw_data = Some(raw_data);
- };
- Ok(tx.to_owned())
+ if latest_block.number < 0 || latest_block.timestamp <= 0 {
+ return Err(invalid_raw("invalid latest block number or timestamp"));
+ }
+ let number_buf = (latest_block.number as u64).to_be_bytes();
+ let hash_buf = hex::decode(&latest_block.hash)
+ .map_err(|_| invalid_raw("invalid latest block hash"))?;
+ if hash_buf.len() != 32 {
+ return Err(invalid_raw("latest block hash must be 32 bytes"));
+ }
+ let expiration = latest_block
+ .timestamp
+ .checked_add(600 * 5 * 1000)
+ .ok_or_else(|| invalid_raw("latest block timestamp overflow"))?;
+ let mut raw_data = tx
+ .raw_data
+ .clone()
+ .ok_or_else(|| invalid_raw("empty raw data"))?;
+ raw_data.ref_block_hash = hash_buf[8..16].to_vec();
+ raw_data.ref_block_bytes = number_buf[6..8].to_vec();
+ raw_data.timestamp = latest_block.timestamp;
+ raw_data.expiration = expiration;
+ if is_trc_20 {
+ raw_data.fee_limit = 1_000_000_000;
+ }
+ tx.raw_data = Some(raw_data);
+ Ok(tx.clone())
}
fn build_transfer_tx(tx_data: &protoc::TronTx) -> Result<Transaction> {
@@ -370,6 +468,9 @@ impl WrappedTron {
tx_data.value
))
})?;
+ if value < 0 {
+ return Err(invalid_raw("negative transfer value"));
+ }
let tx = &mut WrappedTron::build_transfer_transaction(
token,
tx_data.from.to_owned(),
@@ -462,105 +563,32 @@ impl WrappedTron {
.ok_or(TronError::InvalidRawTxCryptoBytes(
"empty transaction field for payload content".to_string(),
))?;
- // `override` is supplied by the sender and is not part of the signed
- // transaction. Only the contract-address allowlist below may provide
- // human-readable token metadata.
- let token_short_name: Option<String> = None;
- let mut divider = DIVIDER;
+ if content.coin_code.to_uppercase() != "TRON" {
+ return Err(invalid_raw("invalid coin code"));
+ }
match tx {
TronTx(tx) => {
- let contract_address = tx.contract_address.to_string();
- let mut token = tx.token.to_string();
- if !contract_address.is_empty() {
- if let Some((known_token, known_divider)) =
- known_token_metadata(&contract_address)
- {
- token = known_token.to_string();
- divider = known_divider;
- } else {
- token = "TRC20 Token (raw)".to_string();
- divider = 1.0;
- }
- }
+ crate::validate_sign_data_len(tx.encoded_len())?;
let mut tron_tx = if tx.contract_address.is_empty() {
Self::build_transfer_tx(tx)
} else {
Self::generate_trc20_tx(tx)
}?;
- let fee_limit = if let Some(raw) = &tron_tx.raw_data {
- raw.fee_limit as u64
- } else {
- 0
- };
- let mut expiration = "".to_string();
-
- if !tx.memo.is_empty() {
- if let Some(ref mut raw) = tron_tx.raw_data {
- raw.data = tx.memo.as_bytes().to_vec();
- expiration = (raw.expiration).to_string();
- }
+ if let Some(ref mut raw) = tron_tx.raw_data {
+ raw.data = tx.memo.as_bytes().to_vec();
}
-
- Ok(Self {
- hd_path: content.hd_path,
- extended_pubkey: context.extended_public_key.to_string(),
- tron_tx,
- xfp: payload.xfp,
- token,
- contract_address,
- from: tx.from.to_string(),
- to: tx.to.to_string(),
- value: tx.value.to_string(),
- method: String::new(),
- divider,
- token_short_name,
- fee_limit,
- memo: tx.memo.clone(),
- expiration,
- })
+ let mut wrapped = Self::from_raw_transaction(tron_tx, content.hd_path)?;
+ wrapped.extended_pubkey = context.extended_public_key.to_string();
+ wrapped.xfp = payload.xfp;
+ Ok(wrapped)
}
- _ => Err(TronError::InvalidRawTxCryptoBytes(
- "invalid transaction type".to_string(),
- )),
+ _ => Err(invalid_raw("invalid transaction type")),
}
}
pub fn format_amount(&self) -> Result<String> {
- let raw_val = f64::from_str(self.value.as_str())?;
- let amount = raw_val / self.divider;
- let unit = self.format_unit()?;
-
- // Calculate precision from divider (power of 10)
- let precision = if self.divider <= 1.0 {
- 0
- } else {
- let mut count = 0;
- let mut d = self.divider;
- while d >= 9.99999 {
- // Account for float precision
- d /= 10.0;
- count += 1;
- }
- count
- };
-
- let formatted = format!("{:.*}", precision, amount);
- let trimmed = if formatted.contains('.') {
- formatted
- .trim_end_matches('0')
- .trim_end_matches('.')
- .to_string()
- } else {
- formatted
- };
-
- let final_value = if trimmed == "0" && raw_val > 0.0 {
- format!("{:.*}", precision, amount)
- } else {
- trimmed
- };
-
- Ok(format!("{} {}", final_value, unit))
+ let amount = format_decimal_units(&self.value, self.decimals)?;
+ Ok(format!("{} {}", amount, self.format_unit()?))
}
pub fn format_method(&self) -> Result<String> {
@@ -579,15 +607,17 @@ impl WrappedTron {
if let Some(ref name) = self.token_short_name {
return Ok(name.clone());
}
- if !self.token.is_empty() {
+ if self.token == "1002000" {
+ Ok("BTT".to_string())
+ } else if !self.token.is_empty() {
Ok(self.token.clone())
} else {
Ok("TRX".to_string())
}
}
}
-pub const DIVIDER: f64 = 1000000_f64;
+pub const DEFAULT_DECIMALS: u8 = 6;
pub const NETWORK: &str = "Tron Mainnet";
#[cfg(test)]
@@ -601,6 +631,128 @@ mod tests {
use core::str::FromStr;
use ur_registry::pb::protoc::{payload, Payload, SignMessage};
+ fn valid_trigger_transaction(data: Vec<u8>) -> Transaction {
+ let trigger = TriggerSmartContract {
+ owner_address: [vec![0x41], vec![0x11; 20]].concat(),
+ contract_address: bitcoin::base58::decode_check("TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t")
+ .unwrap(),
+ data,
+ ..Default::default()
+ };
+ Transaction {
+ raw_data: Some(transaction::Raw {
+ ref_block_bytes: vec![0, 1],
+ ref_block_hash: vec![2; 8],
+ expiration: 2_000,
+ contract: vec![transaction::Contract {
+ r#type: transaction::contract::ContractType::TriggerSmartContract as i32,
+ parameter: Some(Any {
+ type_url: "type.googleapis.com/protocol.TriggerSmartContract".to_string(),
+ value: trigger.encode_to_vec(),
+ }),
+ ..Default::default()
+ }],
+ timestamp: 1_000,
+ ..Default::default()
+ }),
+ ..Default::default()
+ }
+ }
+
+ fn canonical_transfer_calldata() -> Vec<u8> {
+ let mut data = vec![0xa9, 0x05, 0x9c, 0xbb];
+ data.extend_from_slice(&[0; 12]);
+ data.extend_from_slice(&[0x22; 20]);
+ data.extend_from_slice(&[0; 31]);
+ data.push(1);
+ data
+ }
+
+ fn review_limit_raw(data_len: usize, memo_len: usize) -> transaction::Raw {
+ let mut tx = valid_trigger_transaction(vec![0xab; data_len]);
+ let raw = tx.raw_data.as_mut().unwrap();
+ raw.data = vec![b'a'; memo_len];
+ let param = raw.contract[0].parameter.as_mut().unwrap();
+ let mut ct = TriggerSmartContract::decode(param.value.as_slice()).unwrap();
+ ct.owner_address =
+ bitcoin::base58::decode_check("TUEZSdKsoDHQMeZwihtdoBiN46zxhGWYdH").unwrap();
+ param.value = ct.encode_to_vec();
+ tx.raw_data.unwrap()
+ }
+
+ fn assert_raw_rejected(raw: transaction::Raw, reason: &str) {
+ let bytes = raw.encode_to_vec();
+ let path = "m/44'/195'/0'/0/0".to_string();
+ let xpub = "xpub6D1AabNHCupeiLM65ZR9UStMhJ1vCpyV4XbZdyhMZBiJXALQtmn9p42VTQckoHVn8WNqS7dqnJokZHAHcHGoaQgmv8D45oNUKx6DZMNZBCd";
+ let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
+ assert!(crate::parse_tx_request(&bytes, &path)
+ .unwrap_err()
+ .to_string()
+ .contains(reason));
+ assert!(crate::check_tx_request(&bytes, &path, xpub)
+ .unwrap_err()
+ .to_string()
+ .contains(reason));
+ assert!(crate::sign_tx_request(&bytes, &path, &seed)
+ .unwrap_err()
+ .to_string()
+ .contains(reason));
+ }
+
+ #[test]
+ fn bounds_total_raw_bytes_including_memo_and_calldata() {
+ let path = "m/44'/195'/0'/0/0".to_string();
+ let raw = review_limit_raw(9 * 1024, 2 * 1024);
+ let parsed = crate::parse_tx_request(&raw.encode_to_vec(), &path).unwrap();
+ assert_eq!(parsed.detail.memo_hex.len(), 4 * 1024);
+ assert_eq!(parsed.detail.call_data.len(), 2 + 18 * 1024);
+ let mut raw = review_limit_raw(4, crate::MAX_SIGN_DATA_LEN - 256);
+ while raw.encoded_len() < crate::MAX_SIGN_DATA_LEN {
+ raw.data.push(b'a');
+ }
+ assert_eq!(raw.encoded_len(), crate::MAX_SIGN_DATA_LEN);
+ assert!(crate::parse_tx_request(&raw.encode_to_vec(), &path).is_ok());
+ let xpub = "xpub6D1AabNHCupeiLM65ZR9UStMhJ1vCpyV4XbZdyhMZBiJXALQtmn9p42VTQckoHVn8WNqS7dqnJokZHAHcHGoaQgmv8D45oNUKx6DZMNZBCd";
+ let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
+ crate::check_tx_request(&raw.encode_to_vec(), &path, xpub).unwrap();
+ crate::sign_tx_request(&raw.encode_to_vec(), &path, &seed).unwrap();
+ raw.data.push(b'a');
+ assert_raw_rejected(raw, "request exceeds");
+ assert_raw_rejected(
+ review_limit_raw(crate::MAX_SIGN_DATA_LEN, 0),
+ "request exceeds",
+ );
+ }
+
+ #[test]
+ fn rejects_unreviewed_raw_auths_and_scripts() {
+ let mut raw = review_limit_raw(4, 0);
+ raw.auths.push(Default::default());
+ assert_raw_rejected(raw, "unsupported TRON auths or scripts");
+ let mut raw = review_limit_raw(4, 0);
+ raw.scripts.push(1);
+ assert_raw_rejected(raw, "unsupported TRON auths or scripts");
+ let mut raw = review_limit_raw(4, 0);
+ raw.ref_block_num = -1;
+ assert_raw_rejected(raw, "negative ref block number");
+ }
+
+ #[test]
+ fn displays_signed_ref_block_number_without_precision_loss() {
+ let mut raw = review_limit_raw(4, 0);
+ raw.ref_block_num = i64::MAX;
+ let bytes = raw.encode_to_vec();
+ let path = "m/44'/195'/0'/0/0".to_string();
+ let parsed = crate::parse_tx_request(&bytes, &path).unwrap();
+ assert_eq!(parsed.detail.ref_block_num, "9223372036854775807");
+ assert_eq!(
+ parsed.detail.raw_data_hash,
+ hex::encode(hashing::sha256(&bytes))
+ );
+ let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
+ assert!(crate::sign_tx_request(&bytes, &path, &seed).is_ok());
+ }
+
#[test]
fn test_from_raw_transaction_decode_failures() {
let mut tron_tx = Transaction::default();
@@ -652,10 +804,23 @@ mod tests {
value: "".to_string(),
method: "".to_string(),
token_short_name: None,
- divider: 1.0,
+ decimals: 0,
fee_limit: 0,
memo: String::new(),
+ memo_hex: String::new(),
+ memo_hash: String::new(),
+ timestamp: String::new(),
expiration: String::new(),
+ ref_block_num: String::new(),
+ ref_block_bytes: String::new(),
+ ref_block_hash: String::new(),
+ permission_id: String::new(),
+ raw_data_hash: String::new(),
+ call_value: String::new(),
+ call_token_value: String::new(),
+ token_id: String::new(),
+ call_data: String::new(),
+ contract_warning: String::new(),
};
assert!(tx_no_raw.signature_hash().is_err());
}
@@ -706,10 +871,23 @@ mod tests {
value: "".to_string(),
method: "".to_string(),
token_short_name: None,
- divider: 1.0,
+ decimals: 0,
fee_limit: 0,
memo: String::new(),
+ memo_hex: String::new(),
+ memo_hash: String::new(),
+ timestamp: String::new(),
expiration: String::new(),
+ ref_block_num: String::new(),
+ ref_block_bytes: String::new(),
+ ref_block_hash: String::new(),
+ permission_id: String::new(),
+ raw_data_hash: String::new(),
+ call_value: String::new(),
+ call_token_value: String::new(),
+ token_id: String::new(),
+ call_data: String::new(),
+ contract_warning: String::new(),
};
let result = tx.signature_hash();
assert!(result.is_err());
@@ -843,13 +1021,13 @@ mod tests {
let mut tx = WrappedTron::from_payload(payload, &context).unwrap();
// Test 18 decimals (like TUSD)
- tx.divider = 1_000_000_000_000_000_000.0;
+ tx.decimals = 18;
tx.value = "1000000000000000000".to_string();
let formatted = tx.format_amount().unwrap();
assert!(formatted.contains("1"));
// Test 8 decimals (like WBTC)
- tx.divider = 100_000_000.0;
+ tx.decimals = 8;
tx.value = "100000000".to_string();
let formatted = tx.format_amount().unwrap();
assert!(formatted.contains("1"));
@@ -866,11 +1044,7 @@ mod tests {
tron_tx.raw_data = Some(raw);
let result = WrappedTron::from_raw_transaction(tron_tx, "m/44'/195'/0'/0/0".to_string());
- assert!(matches!(
- result,
- Err(TronError::InvalidRawTxCryptoBytes(message))
- if message.contains("unsupported contract type")
- ));
+ assert!(result.is_err());
}
#[test]
@@ -884,11 +1058,7 @@ mod tests {
tron_tx.raw_data = Some(raw);
let result = WrappedTron::from_raw_transaction(tron_tx, "m/44'/195'/0'/0/0".to_string());
- assert!(matches!(
- result,
- Err(TronError::InvalidRawTxCryptoBytes(message))
- if message.contains("multiple contracts")
- ));
+ assert!(result.is_err());
}
#[test]
@@ -899,8 +1069,8 @@ mod tests {
let mut data = vec![0x09, 0x5e, 0xa7, 0xb3];
data.extend_from_slice(&[0u8; 12]);
data.extend_from_slice(&spender[1..]);
- data.extend_from_slice(&[0u8; 31]);
- data.push(1);
+ data.extend_from_slice(&[0u8; 29]);
+ data.extend_from_slice(&[0x0f, 0x42, 0x40]);
let trigger = TriggerSmartContract {
owner_address: owner,
@@ -920,19 +1090,35 @@ mod tests {
};
let tx = Transaction {
raw_data: Some(transaction::Raw {
+ ref_block_bytes: vec![0x00, 0x01],
+ ref_block_hash: vec![0x22; 8],
+ expiration: 2_000,
contract: vec![contract],
+ timestamp: 1_000,
..Default::default()
}),
..Default::default()
};
- let parsed = WrappedTron::from_raw_transaction(tx, "m/44'/195'/0'/0/0".to_string())
+ let parsed = WrappedTron::from_raw_transaction(tx.clone(), "m/44'/195'/0'/0/0".to_string())
.unwrap()
.parse()
.unwrap();
assert_eq!("TRC-20 Approve", parsed.detail.method);
assert_eq!("1 USDT", parsed.detail.value);
assert_eq!(bitcoin::base58::encode_check(&spender), parsed.detail.to);
+
+ let mut non_canonical = tx;
+ non_canonical.raw_data.as_mut().unwrap().contract[0]
+ .parameter
+ .as_mut()
+ .unwrap()
+ .value
+ .extend_from_slice(&[0x80, 0x06, 0x01]);
+ assert!(
+ WrappedTron::from_raw_transaction(non_canonical, "m/44'/195'/0'/0/0".to_string(),)
+ .is_err()
+ );
}
#[test]
@@ -1004,10 +1190,7 @@ mod tests {
tron_tx.raw_data = Some(raw);
let result = WrappedTron::from_raw_transaction(tron_tx, "m/44'/195'/0'/0/0".to_string());
- assert!(result.is_ok());
- let wrapped = result.unwrap();
- // Should not parse TRC-20 data if it's too short
- assert_eq!(wrapped.value, "0");
+ assert!(result.is_err());
}
#[test]
@@ -1030,9 +1213,7 @@ mod tests {
tron_tx.raw_data = Some(raw);
let result = WrappedTron::from_raw_transaction(tron_tx, "m/44'/195'/0'/0/0".to_string());
- assert!(result.is_ok());
- let wrapped = result.unwrap();
- assert_eq!(wrapped.value, "0");
+ assert!(result.is_err());
}
#[test]
@@ -1043,10 +1224,7 @@ mod tests {
tron_tx.raw_data = Some(raw);
let result = WrappedTron::from_raw_transaction(tron_tx, "m/44'/195'/0'/0/0".to_string());
- assert!(result.is_ok());
- let wrapped = result.unwrap();
- assert_eq!(wrapped.from, "");
- assert_eq!(wrapped.value, "0");
+ assert!(result.is_err());
}
#[test]
@@ -1057,14 +1235,12 @@ mod tests {
let context = prepare_parse_context(pubkey_str);
let mut tx = WrappedTron::from_payload(payload, &context).unwrap();
- // Test with custom divider (not 6 or 18)
- tx.divider = 1_000.0; // 3 decimals
+ tx.decimals = 3;
tx.value = "1000".to_string();
let formatted = tx.format_amount().unwrap();
assert!(formatted.contains("1"));
- // Test with divider = 1 (no decimals)
- tx.divider = 1.0;
+ tx.decimals = 0;
tx.value = "100".to_string();
let formatted = tx.format_amount().unwrap();
assert!(formatted.contains("100"));
@@ -1084,4 +1260,193 @@ mod tests {
let raw_data = tx.tron_tx.raw_data.as_ref().expect("raw_data should exist");
assert_eq!(tx.memo.as_bytes().to_vec(), raw_data.data);
}
+
+ #[test]
+ fn formats_u256_amount_without_float_rounding() {
+ let raw = "115792089237316195423570985008687907853269984665640564039457584007913129639935";
+ let formatted = format_decimal_units(raw, 6).unwrap();
+ assert_eq!(formatted.replace('.', ""), raw);
+ assert!(formatted.ends_with(".639935"));
+ assert!(!formatted.contains('e'));
+ }
+
+ #[test]
+ fn rejects_non_canonical_trc20_calldata() {
+ let mut trailing = canonical_transfer_calldata();
+ trailing.push(0);
+ assert!(WrappedTron::from_raw_transaction(
+ valid_trigger_transaction(trailing),
+ "m/44'/195'/0'/0/0".to_string(),
+ )
+ .is_err());
+
+ let mut padding = canonical_transfer_calldata();
+ padding[4] = 1;
+ assert!(WrappedTron::from_raw_transaction(
+ valid_trigger_transaction(padding),
+ "m/44'/195'/0'/0/0".to_string(),
+ )
+ .is_err());
+ }
+
+ fn set_trigger_values(
+ tx: &mut Transaction,
+ owner: Option<Vec<u8>>,
+ trx: i64,
+ tokens: i64,
+ token_id: i64,
+ ) {
+ let parameter = tx.raw_data.as_mut().unwrap().contract[0]
+ .parameter
+ .as_mut()
+ .unwrap();
+ let mut trigger = TriggerSmartContract::decode(parameter.value.as_slice()).unwrap();
+ if let Some(owner) = owner {
+ trigger.owner_address = owner;
+ }
+ trigger.call_value = trx;
+ trigger.call_token_value = tokens;
+ trigger.token_id = token_id;
+ parameter.value = trigger.encode_to_vec();
+ }
+
+ #[test]
+ fn displays_attached_assets_through_parse_check_and_sign() {
+ let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
+ let path = "m/44'/195'/0'/0/0".to_string();
+ let xpub = "xpub6D1AabNHCupeiLM65ZR9UStMhJ1vCpyV4XbZdyhMZBiJXALQtmn9p42VTQckoHVn8WNqS7dqnJokZHAHcHGoaQgmv8D45oNUKx6DZMNZBCd";
+ let owner = bitcoin::base58::decode_check("TUEZSdKsoDHQMeZwihtdoBiN46zxhGWYdH").unwrap();
+ for selector in [
+ vec![0xde, 0xad, 0xbe, 0xef],
+ vec![0xa9, 0x05, 0x9c, 0xbb],
+ vec![0x09, 0x5e, 0xa7, 0xb3],
+ ] {
+ let mut data = canonical_transfer_calldata();
+ data[..4].copy_from_slice(&selector);
+ let baseline = valid_trigger_transaction(data.clone());
+ let baseline = WrappedTron::from_raw_transaction(baseline, path.clone());
+ let expected_token_amount = baseline.unwrap().format_amount().unwrap();
+ let mut tx = valid_trigger_transaction(data.clone());
+ set_trigger_values(
+ &mut tx,
+ Some(owner.clone()),
+ 1_000_000_000_000,
+ i64::MAX,
+ 1_000_001,
+ );
+ let raw = tx.raw_data.unwrap().encode_to_vec();
+ let parsed = crate::parse_tx_request(&raw, &path).unwrap();
+ assert_eq!(parsed.detail.call_value, "1000000 TRX");
+ assert_eq!(parsed.detail.call_token_value, i64::MAX.to_string());
+ assert_eq!(parsed.detail.token_id, "1000001");
+ assert_eq!(parsed.detail.call_data, format!("0x{}", hex::encode(data)));
+ assert_eq!(
+ parsed.detail.raw_data_hash,
+ hex::encode(hashing::sha256(&raw))
+ );
+ if selector[0] == 0xde {
+ assert_eq!(parsed.overview.value, "1000000 TRX");
+ assert_eq!(parsed.overview.to, parsed.detail.contract_address);
+ assert!(!parsed.detail.contract_warning.is_empty());
+ } else {
+ assert_eq!(parsed.overview.value, expected_token_amount);
+ assert!(parsed.detail.contract_warning.is_empty());
+ }
+ crate::check_tx_request(&raw, &path, xpub).unwrap();
+ let signature =
+ hex::decode(crate::sign_tx_request(&raw, &path, &seed).unwrap()).unwrap();
+ use bitcoin::secp256k1::{
+ ecdsa::{RecoverableSignature, RecoveryId},
+ Message, Secp256k1,
+ };
+ let sig = RecoverableSignature::from_compact(
+ &signature[..64],
+ RecoveryId::from_i32(signature[64] as i32).unwrap(),
+ )
+ .unwrap();
+ let digest = hashing::sha256(&raw);
+ let key = Secp256k1::new()
+ .recover_ecdsa(&Message::from_digest_slice(&digest).unwrap(), &sig)
+ .unwrap();
+ assert_eq!(
+ crate::address::public_key_to_address(&key),
+ "TUEZSdKsoDHQMeZwihtdoBiN46zxhGWYdH"
+ );
+ }
+ }
+
+ #[test]
+ fn displays_empty_short_and_long_contract_data_without_truncation() {
+ for data in [vec![], vec![0xde], vec![0xde, 0xad, 0xbe], vec![0xab; 4096]] {
+ let mut tx = valid_trigger_transaction(data.clone());
+ set_trigger_values(&mut tx, None, 1, 0, 0);
+ let parsed = WrappedTron::from_raw_transaction(tx, "m/44'/195'/0'/0/0".to_string())
+ .unwrap()
+ .parse()
+ .unwrap();
+ assert_eq!(parsed.overview.value, "0.000001 TRX");
+ assert_eq!(parsed.detail.call_data, format!("0x{}", hex::encode(data)));
+ assert!(parsed.detail.call_token_value.is_empty());
+ assert!(parsed.detail.token_id.is_empty());
+ assert!(!parsed.detail.contract_warning.is_empty());
+ }
+ }
+
+ #[test]
+ fn rejects_negative_or_unidentified_attached_assets() {
+ for (trx, tokens, id) in [(-1, 0, 0), (0, -1, 1), (0, 1, -1), (0, 1, 0)] {
+ let mut tx = valid_trigger_transaction(canonical_transfer_calldata());
+ set_trigger_values(&mut tx, None, trx, tokens, id);
+ assert!(
+ WrappedTron::from_raw_transaction(tx, "m/44'/195'/0'/0/0".to_string()).is_err()
+ );
+ }
+ }
+
+ #[test]
+ fn rejects_mismatched_or_hidden_contract_metadata() {
+ let mut wrong_type = valid_trigger_transaction(canonical_transfer_calldata());
+ wrong_type.raw_data.as_mut().unwrap().contract[0]
+ .parameter
+ .as_mut()
+ .unwrap()
+ .type_url = "type.googleapis.com/protocol.TransferContract".to_string();
+ assert!(
+ WrappedTron::from_raw_transaction(wrong_type, "m/44'/195'/0'/0/0".to_string(),)
+ .is_err()
+ );
+
+ let mut provider = valid_trigger_transaction(canonical_transfer_calldata());
+ provider.raw_data.as_mut().unwrap().contract[0].provider = vec![1];
+ assert!(
+ WrappedTron::from_raw_transaction(provider, "m/44'/195'/0'/0/0".to_string(),).is_err()
+ );
+ }
+
+ #[test]
+ fn rejects_invalid_transaction_header_and_path() {
+ let mut tx = valid_trigger_transaction(canonical_transfer_calldata());
+ tx.raw_data.as_mut().unwrap().expiration = 1_000;
+ assert!(WrappedTron::from_raw_transaction(tx, "m/44'/195'/0'/0/0".to_string(),).is_err());
+ assert!(WrappedTron::from_raw_transaction(
+ valid_trigger_transaction(canonical_transfer_calldata()),
+ "m/44'/60'/0'/0/0".to_string(),
+ )
+ .is_err());
+ }
+
+ #[test]
+ fn preserves_non_text_memo_as_hex_and_hash() {
+ for memo in [vec![0xff, 0xfe], vec![b'a', 0, b'b']] {
+ let mut tx = valid_trigger_transaction(canonical_transfer_calldata());
+ tx.raw_data.as_mut().unwrap().data = memo.clone();
+ let parsed = WrappedTron::from_raw_transaction(tx, "m/44'/195'/0'/0/0".to_string())
+ .unwrap()
+ .parse()
+ .unwrap();
+ assert!(parsed.detail.memo.is_empty());
+ assert_eq!(parsed.detail.memo_hex, hex::encode(memo));
+ assert_eq!(parsed.detail.memo_hash.len(), 64);
+ }
+ }
}
### rust/apps/wallets/src/keeper.rs
[binary or diff unavailable]
### rust/apps/wallets/src/lib.rs
@@ -17,12 +17,12 @@ pub mod bitget;
pub mod blue_wallet;
mod common;
pub mod core_wallet;
+pub mod keeper;
pub mod keplr;
pub mod keystone_connect;
pub mod metamask;
pub mod okx;
pub mod thor_wallet;
-pub mod tonkeeper;
mod utils;
pub mod xrp_toolkit;
pub mod zcash;
### rust/apps/zcash/src/address_verification.rs
@@ -0,0 +1,305 @@
+use zcash_vendor::{
+ zcash_keys::{
+ address::Address,
+ keys::{ReceiverRequirement, UnifiedAddressRequest, UnifiedFullViewingKey},
+ },
+ zcash_protocol::consensus,
+ zip32::DiversifierIndex,
+};
+
+#[derive(Debug, PartialEq, Eq)]
+pub enum VerificationResult {
+ Owned,
+ NotOwned,
+ InvalidAddress,
+ UnsupportedReceiver,
+ KeyUnavailable,
+}
+
+pub fn verify<P: consensus::Parameters>(params: &P, ufvk: &str, text: &str) -> VerificationResult {
+ use VerificationResult::*;
+ let normalized;
+ let text = if ["u1", "utest1", "uregtest1"].iter().any(|prefix| {
+ text.get(..prefix.len())
+ .is_some_and(|head| head.eq_ignore_ascii_case(prefix))
+ }) && text.bytes().any(|b| b.is_ascii_uppercase())
+ {
+ if text.bytes().any(|b| b.is_ascii_lowercase()) {
+ return InvalidAddress;
+ }
+ normalized = text.to_ascii_lowercase();
+ normalized.as_str()
+ } else {
+ text
+ };
+ let ua = match Address::decode(params, text) {
+ Some(Address::Unified(ua)) => ua,
+ Some(_) => return UnsupportedReceiver,
+ None => return InvalidAddress,
+ };
+ if !ua.unknown().is_empty() || ua.has_sapling() {
+ return UnsupportedReceiver;
+ }
+ let receiver = match ua.orchard() {
+ Some(receiver) => receiver,
+ None => return UnsupportedReceiver,
+ };
+ let ufvk = match UnifiedFullViewingKey::decode(params, ufvk) {
+ Ok(ufvk) => ufvk,
+ Err(_) => return KeyUnavailable,
+ };
+ let incoming = ufvk.to_unified_incoming_viewing_key();
+ let orchard = match incoming.orchard().as_ref() {
+ Some(orchard) => orchard,
+ None => return KeyUnavailable,
+ };
+ let index = match orchard.diversifier_index(receiver) {
+ Some(index) => DiversifierIndex::from(*index.as_bytes()),
+ None => return NotOwned,
+ };
+ let request = UnifiedAddressRequest::custom(
+ ReceiverRequirement::Require,
+ ReceiverRequirement::Omit,
+ if ua.has_transparent() {
+ ReceiverRequirement::Require
+ } else {
+ ReceiverRequirement::Omit
+ },
+ )
+ .expect("Orchard is required");
+ match incoming.address(index, request) {
+ Ok(expected)
+ if expected.orchard() == ua.orchard() && expected.transparent() == ua.transparent() =>
+ {
+ Owned
+ }
+ _ => NotOwned,
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use alloc::{vec, vec::Vec};
+ use keystore::algorithms::zcash::derive_ufvk;
+ use zcash_vendor::zip32::Scope;
+ use zcash_vendor::{
+ zcash_address::unified::{self, Container, Encoding, Receiver},
+ zcash_protocol::consensus::{MainNetwork, NetworkType, TestNetwork},
+ };
+
+ #[test]
+ fn official_mainnet_vector_is_owned() {
+ let ufvk = "uview1dgucetjuudl3msv6tcecj0getnxsdpk5j60h74nckdtrrqs5p4gvf8a3s3lflxednpr774sx7tyaqfxw0s8mnnl7nk7h4m5m3y8xl7efgjprar8sdq6k3mha9l9cln5wy3s6k4g7ma0tc7y30x5xwl7ezxrzhvnrgd8q9zzh4l088mta932ml7wll39y3s82qmse58ulr7p6rj59lh9v0g7evcpghu3ntnh6jr2jzj2vdc904ahhlkq6sn0jdyt3l4s0ch6af7nvh4emlspt32hgk5t59mg3nuxnjqpvpx26vwcfvpuhm8vmpy0ray4mhwhtz9de8gvwg423rpw7l899fvyu0wmr5lp5lu46ckufa2gpt9msjpxxach5cnuwaxph00e65tfmelxyed78t57t4g7f8v9q9fq0378g23yql2t9tp78g3mp0xl30q623rmxglhknl79e7ltwurfvpw7w4k57yzv97exq9h0fv0urgvffu6dqmk5";
+ let address = "u1ukslldhknrzmvpdmn03u03edgfy976w3muurfs9asvh3n9uh9h6sgle6m7yjgf3wafxtvke08u735v4nd3kjqnyulw7cvxh6ke357knyjudgqtes6kcw7y28e6kewr03pjah5mh26na";
+ assert_eq!(
+ verify(&MainNetwork, ufvk, address),
+ VerificationResult::Owned
+ );
+ assert_eq!(
+ verify(&MainNetwork, ufvk, &address.to_ascii_uppercase()),
+ VerificationResult::Owned
+ );
+ assert_eq!(
+ verify(&TestNetwork, ufvk, address),
+ VerificationResult::InvalidAddress
+ );
+ }
+
+ #[test]
+ fn uppercase_addresses_are_owned_but_mixed_case_is_invalid() {
+ let key = key(1);
+ let ufvk = key.encode(&MainNetwork);
+ let (address, _) = key.default_address(UnifiedAddressRequest::ORCHARD).unwrap();
+ let text = address.encode(&MainNetwork);
+ assert_eq!(
+ verify(&MainNetwork, &ufvk, &text.to_ascii_uppercase()),
+ VerificationResult::Owned
+ );
+ let mixed = alloc::format!("U{}", &text[1..]);
+ assert_eq!(
+ verify(&MainNetwork, &ufvk, &mixed),
+ VerificationResult::InvalidAddress
+ );
+ let mut broken = text.to_ascii_uppercase();
+ broken.pop();
+ broken.push('!');
+ assert_eq!(
+ verify(&MainNetwork, &ufvk, &broken),
+ VerificationResult::InvalidAddress
+ );
+ let testnet = address.encode(&TestNetwork).to_ascii_uppercase();
+ assert_eq!(
+ verify(&MainNetwork, &ufvk, &testnet),
+ VerificationResult::InvalidAddress
+ );
+ }
+
+ fn key(seed: u8) -> UnifiedFullViewingKey {
+ UnifiedFullViewingKey::decode(
+ &MainNetwork,
+ &derive_ufvk(&MainNetwork, &[seed; 32], "m/32'/133'/0'").unwrap(),
+ )
+ .unwrap()
+ }
+
+ fn check(key: &UnifiedFullViewingKey, receivers: Vec<Receiver>) -> VerificationResult {
+ let text = unified::Address::try_from_items(receivers)
+ .unwrap()
+ .encode(&NetworkType::Main);
+ verify(&MainNetwork, &key.encode(&MainNetwork), &text)
+ }
+
+ #[test]
+ fn default_and_rotated_addresses_are_owned() {
+ let key = key(1);
+ for i in [0u32, 1, 42, 1729704000] {
+ let address = key
+ .address(i.into(), UnifiedAddressRequest::AllAvailableKeys)
+ .unwrap();
+ assert_eq!(
+ verify(
+ &MainNetwork,
+ &key.encode(&MainNetwork),
+ &address.encode(&MainNetwork)
+ ),
+ VerificationResult::Owned
+ );
+ }
+ }
+
+ #[test]
+ fn orchard_only_supports_full_diversifier_range() {
+ let key = key(1);
+ let index = DiversifierIndex::from([0xff; 11]);
+ let address = key.address(index, UnifiedAddressRequest::ORCHARD).unwrap();
+ assert_eq!(
+ verify(
+ &MainNetwork,
+ &key.encode(&MainNetwork),
+ &address.encode(&MainNetwork)
+ ),
+ VerificationResult::Owned
+ );
+ }
+
+ #[test]
+ fn other_wallet_and_internal_address_are_not_owned() {
+ let key = key(1);
+ let other = key
+ .address(0u32.into(), UnifiedAddressRequest::AllAvailableKeys)
+ .unwrap();
+ assert_eq!(
+ verify(
+ &MainNetwork,
+ &self::key(2).encode(&MainNetwork),
+ &other.encode(&MainNetwork)
+ ),
+ VerificationResult::NotOwned
+ );
+ let internal = key
+ .orchard()
+ .unwrap()
+ .to_ivk(Scope::Internal)
+ .address_at(0u32);
+ assert_eq!(
+ check(
+ &key,
+ vec![Receiver::Orchard(internal.to_raw_address_bytes())]
+ ),
+ VerificationResult::NotOwned
+ );
+ }
+
+ #[test]
+ fn mixed_receivers_and_wrong_transparent_index_are_rejected() {
+ let key = key(1);
+ let ua = key
+ .address(0u32.into(), UnifiedAddressRequest::AllAvailableKeys)
+ .unwrap();
+ let orchard = Receiver::Orchard(ua.orchard().unwrap().to_raw_address_bytes());
+ for other in [
+ self::key(2)
+ .address(0u32.into(), UnifiedAddressRequest::AllAvailableKeys)
+ .unwrap(),
+ key.address(1u32.into(), UnifiedAddressRequest::AllAvailableKeys)
+ .unwrap(),
+ ] {
+ let (_, raw) = unified::Address::decode(&other.encode(&MainNetwork)).unwrap();
+ let transparent = raw
+ .items_as_parsed()
+ .iter()
+ .find(|r| matches!(r, Receiver::P2pkh(_)))
+ .unwrap()
+ .clone();
+ assert_eq!(
+ check(&key, vec![orchard.clone(), transparent]),
+ VerificationResult::NotOwned
+ );
+ }
+ assert_eq!(
+ check(&key, vec![orchard, Receiver::P2sh([1; 20])]),
+ VerificationResult::NotOwned
+ );
+ }
+
+ #[test]
+ fn unverified_receivers_never_report_success() {
+ let key = key(1);
+ let ua = key
+ .address(0u32.into(), UnifiedAddressRequest::ORCHARD)
+ .unwrap();
+ let orchard = Receiver::Orchard(ua.orchard().unwrap().to_raw_address_bytes());
+ assert_eq!(
+ check(
+ &key,
+ vec![
+ orchard.clone(),
+ Receiver::Unknown {
+ typecode: 65535,
+ data: vec![1; 20]
+ }
+ ]
+ ),
+ VerificationResult::UnsupportedReceiver
+ );
+ assert_eq!(
+ check(&key, vec![orchard, Receiver::Sapling([0; 43])]),
+ VerificationResult::UnsupportedReceiver
+ );
+ assert_ne!(
+ check(&key, vec![Receiver::Sapling([0; 43])]),
+ VerificationResult::Owned
+ );
+ }
+
+ #[test]
+ fn invalid_encoding_network_and_viewing_key_are_rejected() {
+ let key = key(1);
+ let ua = key
+ .address(0u32.into(), UnifiedAddressRequest::ORCHARD)
+ .unwrap();
+ let ufvk = key.encode(&MainNetwork);
+ for text in ["", "u1invalid", "zcash:u1invalid"] {
+ assert_eq!(
+ verify(&MainNetwork, &ufvk, text),
+ VerificationResult::InvalidAddress
+ );
+ }
+ assert_eq!(
+ verify(&MainNetwork, &ufvk, &ua.encode(&TestNetwork)),
+ VerificationResult::InvalidAddress
+ );
+ assert_eq!(
+ verify(&MainNetwork, "", &ua.encode(&MainNetwork)),
+ VerificationResult::KeyUnavailable
+ );
+ let mut corrupt = ua.encode(&MainNetwork).into_bytes();
+ let last = corrupt.len() - 1;
+ corrupt[last] = if corrupt[last] == b'q' { b'p' } else { b'q' };
+ assert_eq!(
+ verify(&MainNetwork, &ufvk, core::str::from_utf8(&corrupt).unwrap()),
+ VerificationResult::InvalidAddress
+ );
+ }
+}
### rust/apps/zcash/src/lib.rs
@@ -1,6 +1,8 @@
#![no_std]
extern crate alloc;
+#[cfg(feature = "cypherpunk")]
+pub mod address_verification;
pub mod errors;
pub mod pczt;
pub mod version;
### rust/keystore/src/algorithms/ed25519/bip32_ed25519.rs
@@ -53,6 +53,12 @@ pub fn sign_message_by_entropy(
//https://cips.cardano.org/cips/cip3/icarus.md
pub fn get_icarus_master_key_by_entropy(entropy: &[u8], passphrase: &[u8]) -> Result<XPrv> {
+ if !matches!(entropy.len(), 16 | 20 | 24 | 28 | 32) {
+ return Err(KeystoreError::SeedError(format!(
+ "invalid entropy length: {}, expected 16, 20, 24, 28, or 32 bytes",
+ entropy.len()
+ )));
+ }
let mut hash = [0u8; 96];
let digest = Sha512::new();
let iter_count = 4096;
### rust/keystore/src/algorithms/ed25519/slip10_ed25519.rs
@@ -6,14 +6,11 @@ use bitcoin::bip32::{ChildNumber, DerivationPath};
use zeroize::Zeroize;
use crate::algorithms::crypto::hmac_sha512;
-use crate::algorithms::utils::{is_all_zero_or_ff, normalize_path};
+use crate::algorithms::utils::{ensure_valid_seed, normalize_path};
use crate::errors::{KeystoreError, Result};
fn ensure_non_trivial_seed(seed: &[u8]) -> Result<()> {
- if is_all_zero_or_ff(seed) {
- return Err(KeystoreError::SeedError("invalid seed".to_string()));
- }
- Ok(())
+ ensure_valid_seed(seed)
}
/// Derives an Ed25519 private key from a seed using SLIP-10 derivation.
### rust/keystore/src/algorithms/secp256k1.rs
@@ -11,7 +11,7 @@ use bitcoin::secp256k1;
use bitcoin::Network;
use secp256k1::Message;
-use crate::algorithms::utils::{is_all_zero_or_ff, normalize_path};
+use crate::algorithms::utils::{ensure_valid_seed, normalize_path};
use crate::errors::{KeystoreError, Result};
@@ -62,10 +62,7 @@ pub fn get_master_fingerprint_by_seed(seed: &[u8]) -> Result<Fingerprint> {
}
fn ensure_non_trivial_seed(seed: &[u8]) -> Result<()> {
- if is_all_zero_or_ff(seed) {
- return Err(KeystoreError::SeedError("invalid seed".to_string()));
- }
- Ok(())
+ ensure_valid_seed(seed)
}
pub fn sign_message_by_seed(
@@ -217,6 +214,18 @@ mod tests {
assert!(matches!(result, Err(KeystoreError::SeedError(_))));
}
+ #[test]
+ fn test_reject_wrong_length_seed() {
+ for len in [0usize, 15, 17, 31, 33, 63, 65] {
+ let seed: alloc::vec::Vec<u8> = (0..len).map(|i| (i as u8).wrapping_add(1)).collect();
+ let result = get_master_fingerprint_by_seed(&seed);
+ assert!(
+ matches!(result, Err(KeystoreError::SeedError(_))),
+ "len {len}"
+ );
+ }
+ }
+
#[test]
fn test_derive_extend_public_key() {
let extended_pubkey_str = "xpub6GPqFm1j3L6SppDC1WSMRcUSB4Rt5oPkiHfTsbRTk9o1pzTFN2SrAvbX8a42j48vNrxRbVG8s7RZcNBWBo89yp7iohDAZAuszvnUo7DvJdx";
### rust/keystore/src/algorithms/utils.rs
@@ -1,4 +1,6 @@
-use alloc::string::String;
+use alloc::string::{String, ToString};
+
+use crate::errors::{KeystoreError, Result};
pub fn normalize_path(path: &str) -> String {
let mut p = path.to_lowercase();
@@ -8,6 +10,19 @@ pub fn normalize_path(path: &str) -> String {
p
}
+pub fn ensure_valid_seed(seed: &[u8]) -> Result<()> {
+ if !matches!(seed.len(), 16 | 32 | 64) {
+ return Err(KeystoreError::SeedError(format!(
+ "invalid seed length: {}, expected 16, 32, or 64 bytes",
+ seed.len()
+ )));
+ }
+ if is_all_zero_or_ff(seed) {
+ return Err(KeystoreError::SeedError("invalid seed".to_string()));
+ }
+ Ok(())
+}
+
pub fn is_all_zero_or_ff(bytes: &[u8]) -> bool {
if bytes.is_empty() {
return false;
### rust/keystore/src/algorithms/zcash/mod.rs
@@ -8,7 +8,7 @@ use zcash_vendor::{
zip32::{self, fingerprint::SeedFingerprint},
};
-use crate::algorithms::utils::is_all_zero_or_ff;
+use crate::algorithms::utils::ensure_valid_seed;
use crate::errors::{KeystoreError, Result};
@@ -49,10 +49,7 @@ pub fn derive_ufvk<P: consensus::Parameters>(
}
fn ensure_non_trivial_seed(seed: &[u8]) -> Result<()> {
- if is_all_zero_or_ff(seed) {
- return Err(KeystoreError::SeedError("invalid seed".to_string()));
- }
- Ok(())
+ ensure_valid_seed(seed)
}
pub fn calculate_seed_fingerprint(seed: &[u8]) -> Result<[u8; 32]> {
### rust/rust_c/Cargo.toml
@@ -144,6 +144,7 @@ default = ["debug-cypherpunk"]
[dev-dependencies]
keystore = { path = "../keystore" }
+ur = { package = "keystone-ur", version = "=0.1.1", default-features = false }
[build-dependencies]
cbindgen = "0.27.0"
### rust/rust_c/src/allocator.rs
@@ -15,10 +15,29 @@ fn oom(_layout: core::alloc::Layout) -> ! {
#[panic_handler]
fn panic(e: &PanicInfo) -> ! {
- let message = match e.location() {
- Some(location) => alloc::format!("rust panic at {}:{}", location.file(), location.line()),
- None => alloc::string::String::from("rust panic"),
- };
- unsafe { crate::bindings::LogRustPanic(crate::common::utils::convert_c_char(message)) }
+ #[cfg(any(
+ feature = "production-multi-coins",
+ feature = "production-btc-only",
+ feature = "production-cypherpunk"
+ ))]
+ {
+ let _ = e;
+ static PANIC_MESSAGE: &[u8] = b"rust panic\0";
+ unsafe { crate::bindings::LogRustPanic(PANIC_MESSAGE.as_ptr() as *mut cty::c_char) };
+ }
+ #[cfg(not(any(
+ feature = "production-multi-coins",
+ feature = "production-btc-only",
+ feature = "production-cypherpunk"
+ )))]
+ {
+ let message = match e.location() {
+ Some(location) => {
+ alloc::format!("rust panic at {}:{}", location.file(), location.line())
+ }
+ None => alloc::string::String::from("rust panic"),
+ };
+ unsafe { crate::bindings::LogRustPanic(crate::common::utils::convert_c_char(message)) }
+ }
loop {}
}
### rust/rust_c/src/bitcoin/psbt.rs
@@ -67,7 +67,13 @@ pub unsafe extern "C" fn utxo_parse_extend_psbt(
let mfp = extract_array!(master_fingerprint, u8, 4);
let public_keys = recover_c_array(public_keys);
- parse_psbt(mfp, public_keys, psbt, None)
+ parse_psbt_with_coin(
+ mfp,
+ public_keys,
+ psbt,
+ None,
+ Some(crypto_psbt.get_coin_id()),
+ )
}
#[no_mangle]
@@ -395,13 +401,25 @@ pub unsafe extern "C" fn utxo_check_psbt_extend(
let crypto_psbt = extract_ptr_with_type!(ptr, CryptoPSBTExtend);
let psbt = crypto_psbt.get_psbt();
- btc_check_psbt_common(
+ let mfp = extract_array!(master_fingerprint, u8, length as usize);
+ let keys = recover_c_array(public_keys);
+ let verify = if verify_code.is_null() {
+ None
+ } else {
+ Some(recover_c_char(verify_code))
+ };
+ let wallet = if multisig_wallet_config.is_null() {
+ None
+ } else {
+ Some(recover_c_char(multisig_wallet_config))
+ };
+ check_psbt_with_coin(
+ mfp,
+ keys,
psbt,
- master_fingerprint,
- length,
- public_keys,
- verify_code,
- multisig_wallet_config,
+ verify,
+ wallet,
+ Some(crypto_psbt.get_coin_id()),
)
}
@@ -568,6 +586,16 @@ unsafe fn parse_psbt(
public_keys: &[ExtendedPublicKey],
psbt: Vec<u8>,
multisig_wallet_config: Option<String>,
+) -> *mut TransactionParseResult<DisplayTx> {
+ parse_psbt_with_coin(mfp, public_keys, psbt, multisig_wallet_config, None)
+}
+
+unsafe fn parse_psbt_with_coin(
+ mfp: &[u8],
+ public_keys: &[ExtendedPublicKey],
+ psbt: Vec<u8>,
+ multisig_wallet_config: Option<String>,
+ coin_id: Option<Option<i128>>,
) -> *mut TransactionParseResult<DisplayTx> {
let master_fingerprint = bitcoin::bip32::Fingerprint::from_str(hex::encode(mfp).as_str())
.map_err(|_e| RustCError::InvalidMasterFingerprint);
@@ -598,7 +626,10 @@ unsafe fn parse_psbt(
Err(e) => return TransactionParseResult::from(e).c_ptr(),
};
let context = ParseContext::new(fp, keys, None, wallet_config);
- let parsed_psbt = app_bitcoin::parse_psbt(psbt, context);
+ let parsed_psbt = match coin_id {
+ Some(coin) => app_bitcoin::parse_psbt_extend(psbt, context, coin),
+ None => app_bitcoin::parse_psbt(psbt, context),
+ };
match parsed_psbt {
Ok(res) => {
TransactionParseResult::success(Box::into_raw(Box::new(DisplayTx::from(res))))
@@ -617,6 +648,24 @@ unsafe fn check_psbt(
psbt: Vec<u8>,
verify_code: Option<String>,
multisig_wallet_config: Option<String>,
+) -> PtrT<TransactionCheckResult> {
+ check_psbt_with_coin(
+ mfp,
+ public_keys,
+ psbt,
+ verify_code,
+ multisig_wallet_config,
+ None,
+ )
+}
+
+unsafe fn check_psbt_with_coin(
+ mfp: &[u8],
+ public_keys: &[ExtendedPublicKey],
+ psbt: Vec<u8>,
+ verify_code: Option<String>,
+ multisig_wallet_config: Option<String>,
+ coin_id: Option<Option<i128>>,
) -> PtrT<TransactionCheckResult> {
let master_fingerprint = bitcoin::bip32::Fingerprint::from_str(hex::encode(mfp).as_str())
.map_err(|_e| RustCError::InvalidMasterFingerprint);
@@ -647,7 +696,10 @@ unsafe fn check_psbt(
Err(e) => return TransactionCheckResult::from(e).c_ptr(),
};
let context = ParseContext::new(fp, keys, verify_code, wallet_config);
- let check_result = app_bitcoin::check_psbt(psbt, context);
+ let check_result = match coin_id {
+ Some(coin) => app_bitcoin::check_psbt_extend(psbt, context, coin),
+ None => app_bitcoin::check_psbt(psbt, context),
+ };
match check_result {
Ok(_) => TransactionCheckResult::new().c_ptr(),
Err(e) => TransactionCheckResult::from(e).c_ptr(),
@@ -693,7 +745,7 @@ unsafe fn utxo_sign_psbt_extend_dynamic(
};
let seed = extract_array!(seed, u8, seed_len as usize);
- let result = app_bitcoin::sign_psbt(psbt, seed, master_fingerprint);
+ let result = app_bitcoin::sign_psbt_extend(psbt, seed, master_fingerprint, coin_id);
match result {
Ok(psbt_data) => match CryptoPSBTExtend::new(psbt_data, coin_id) {
### rust/rust_c/src/cardano/mod.rs
@@ -1,4 +1,4 @@
-use alloc::{format, slice};
+use alloc::{collections::BTreeSet, format, slice};
use alloc::{
string::{String, ToString},
vec,
@@ -348,7 +348,7 @@ pub unsafe extern "C" fn cardano_parse_sign_tx_hash(
let sign_hash_request = extract_ptr_with_type!(ptr, CardanoSignTxHashRequest);
let message = sign_hash_request.get_tx_hash();
let crypto_key_paths = sign_hash_request.get_paths();
- let paths = match crypto_key_paths
+ let mut paths = match crypto_key_paths
.iter()
.map(|v| v.get_path())
.collect::<Option<Vec<String>>>()
@@ -361,13 +361,11 @@ pub unsafe extern "C" fn cardano_parse_sign_tx_hash(
.c_ptr()
}
};
- let address_list = sign_hash_request.get_address_list();
- if paths.len() != address_list.len() {
- return TransactionParseResult::from(RustCError::InvalidData(
- "address and derivation path count mismatch".to_string(),
- ))
- .c_ptr();
- }
+ let mut seen_paths = BTreeSet::new();
+ paths.retain(|path| seen_paths.insert(path.clone()));
+ let mut address_list = sign_hash_request.get_address_list();
+ let mut seen_addresses = BTreeSet::new();
+ address_list.retain(|address| seen_addresses.insert(address.clone()));
let network = "Cardano".to_string();
let result = DisplayCardanoSignTxHash::new(network, paths, message, address_list);
TransactionParseResult::success(result.c_ptr()).c_ptr()
### rust/rust_c/src/cardano/structs.rs
@@ -397,7 +397,7 @@ impl From<ParsedCardanoTx> for DisplayCardanoTx {
impl DisplayCardanoTx {
pub fn from_with_raw_data(value: ParsedCardanoTx, raw_data: &[u8]) -> Self {
let mut display = Self::from(value);
- let mut raw = String::with_capacity(raw_data.len().saturating_mul(2));
+ let mut raw = String::with_capacity(raw_data.len().saturating_mul(2).saturating_add(1));
append_hex(&mut raw, raw_data);
display.raw_data = convert_c_char(raw);
display
### rust/rust_c/src/common/mod.rs
@@ -35,6 +35,7 @@ pub mod qrcode;
pub mod structs;
pub mod types;
pub mod ur;
+mod ur_budget;
mod ur_ext;
pub mod utils;
pub mod web_auth;
### rust/rust_c/src/common/qrcode/mod.rs
@@ -32,6 +32,25 @@ pub unsafe extern "C" fn parse_qrcode_text(qr: PtrString) -> Ptr<URParseResult>
if !is_ok {
return URParseResult::from(RustCError::InvalidMessage).c_ptr();
}
+ #[cfg(feature = "cypherpunk")]
+ if ["u1", "utest1", "uregtest1"].iter().any(|prefix| {
+ value
+ .get(..prefix.len())
+ .is_some_and(|head| head.eq_ignore_ascii_case(prefix))
+ }) {
+ if value.len() > 1024 {
+ return URParseResult::from(RustCError::InvalidMessage).c_ptr();
+ }
+ if let Ok(address) = cstr_core::CString::new(value.as_bytes()) {
+ return URParseResult::single(
+ super::ur::ViewType::ZcashAddressCheck,
+ super::ur::QRCodeType::ZcashAddressText,
+ address,
+ )
+ .c_ptr();
+ }
+ return URParseResult::from(RustCError::InvalidMessage).c_ptr();
+ }
if value.to_lowercase().starts_with("signmessage") {
if let Some((headers, message)) = value.split_once(':') {
if message.is_empty() {
### rust/rust_c/src/common/ur.rs
@@ -88,18 +88,24 @@ unsafe extern "C" {
struct KeystoneURDecoder {
decoder: ur::Decoder,
+ budget: super::ur_budget::FragmentBudget,
}
impl KeystoneURDecoder {
fn from_first_part(part: &str) -> Result<Self, URError> {
- let mut decoder = ur::Decoder::default();
- decoder
- .receive(part)
- .map_err(|error| URError::UrDecodeError(error.to_string()))?;
- Ok(Self { decoder })
+ let mut decoder = Self {
+ decoder: ur::Decoder::default(),
+ budget: Default::default(),
+ };
+ decoder.receive(part)?;
+ Ok(decoder)
}
fn receive(&mut self, part: &str) -> Result<(), URError> {
+ if let Err(reason) = self.budget.receive(part) {
+ self.decoder = ur::Decoder::default();
+ return Err(URError::UrDecodeError(reason.to_string()));
+ }
self.decoder
.receive(part)
.map_err(|error| URError::UrDecodeError(error.to_string()))
@@ -127,9 +133,10 @@ fn validate_reassembled_cbor(cbor: &[u8]) -> Result<(), URError> {
let mut status = sandbox_parser::ValidationStatus::InvalidInput as u32;
let available = unsafe { MpuSandboxValidateCbor(cbor.as_ptr(), cbor.len(), &mut status) };
if !available {
- return Err(URError::CborDecodeError(
- "sandbox CBOR validation unavailable".to_string(),
- ));
+ return Err(URError::CborDecodeError(format!(
+ "sandbox CBOR validation unavailable ({} bytes)",
+ cbor.len()
+ )));
}
status
};
@@ -387,6 +394,8 @@ pub enum ViewType {
MultisigCryptoImportXpub,
#[cfg(feature = "btc-only")]
MultisigBytesImportXpub,
+ #[cfg(feature = "cypherpunk")]
+ ZcashAddressCheck,
ViewTypeUnKnown,
}
@@ -403,6 +412,8 @@ pub enum QRCodeType {
#[cfg(feature = "bitcoin")]
BtcSignRequest,
SeedSignerMessage,
+ #[cfg(feature = "cypherpunk")]
+ ZcashAddressText,
#[cfg(feature = "multi-coins")]
KeystoneSignRequest,
#[cfg(feature = "ethereum")]
@@ -601,6 +612,10 @@ impl Free for URParseResult {
unsafe fn free_ur(ur_type: &QRCodeType, data: PtrUR) {
match ur_type {
+ #[cfg(feature = "cypherpunk")]
+ QRCodeType::ZcashAddressText => {
+ free_ptr_with_type!(data, CString);
+ }
#[cfg(feature = "bitcoin")]
QRCodeType::CryptoPSBT => {
free_ptr_with_type!(data, CryptoPSBT);
@@ -781,6 +796,80 @@ impl_response!(URParseMultiResult);
#[cfg(test)]
mod tests {
+ #[cfg(feature = "cypherpunk")]
+ #[test]
+ fn zcash_address_text_qr_owns_and_releases_its_payload() {
+ use crate::common::qrcode::parse_qrcode_text;
+ use crate::zcash::{verify_zcash_address, zcash_address_qr_text, ZcashAddressVerification};
+ let key = keystore::algorithms::zcash::derive_ufvk(
+ &zcash_vendor::zcash_protocol::consensus::MainNetwork,
+ &[1; 32],
+ "m/32'/133'/0'",
+ )
+ .unwrap();
+ let text =
+ app_zcash::get_address(&zcash_vendor::zcash_protocol::consensus::MainNetwork, &key)
+ .unwrap();
+ let input = CString::new(text.as_bytes()).unwrap();
+ let key = CString::new(key).unwrap();
+ unsafe {
+ for _ in 0..8 {
+ let parsed = Box::from_raw(parse_qrcode_text(input.as_ptr() as PtrString));
+ assert_eq!(parsed.error_code, 0);
+ assert_eq!(parsed.t, ViewType::ZcashAddressCheck);
+ assert!(matches!(parsed.ur_type, QRCodeType::ZcashAddressText));
+ let borrowed = zcash_address_qr_text(parsed.data);
+ assert_eq!(cstr_core::CStr::from_ptr(borrowed).to_str().unwrap(), text);
+ assert!(matches!(
+ verify_zcash_address(key.as_ptr() as PtrString, borrowed as PtrString),
+ ZcashAddressVerification::ZcashAddressOwned
+ ));
+ parsed.free();
+ }
+ for (candidate, owned) in [
+ (text.to_ascii_uppercase(), true),
+ (format!("U{}", &text[1..]), false),
+ ("UTEST1INVALID".to_string(), false),
+ ("UREGTEST1INVALID".to_string(), false),
+ ] {
+ let input = CString::new(candidate.as_bytes()).unwrap();
+ let parsed = Box::from_raw(parse_qrcode_text(input.as_ptr() as PtrString));
+ assert_eq!(parsed.error_code, 0);
+ assert_eq!(parsed.t, ViewType::ZcashAddressCheck);
+ let borrowed = zcash_address_qr_text(parsed.data);
+ assert_eq!(
+ cstr_core::CStr::from_ptr(borrowed).to_str().unwrap(),
+ candidate
+ );
+ let result = verify_zcash_address(key.as_ptr() as PtrString, borrowed as PtrString);
+ if owned {
+ assert!(matches!(
+ result,
+ ZcashAddressVerification::ZcashAddressOwned
+ ));
+ } else {
+ assert!(matches!(
+ result,
+ ZcashAddressVerification::ZcashAddressInvalid
+ ));
+ }
+ parsed.free();
+ }
+ for text in [
+ "zcash:u1invalid".to_string(),
+ format!("u1{}", "q".repeat(1024)),
+ ] {
+ let text = CString::new(text).unwrap();
+ let parsed = Box::from_raw(parse_qrcode_text(text.as_ptr() as PtrString));
+ assert_ne!(parsed.error_code, 0);
+ parsed.free();
+ }
+ assert!(matches!(
+ verify_zcash_address(core::ptr::null_mut(), core::ptr::null_mut()),
+ ZcashAddressVerification::ZcashAddressKeyUnavailable
+ ));
+ }
+ }
use alloc::vec;
use super::*;
@@ -911,12 +1000,15 @@ fn sandbox_cbor_error(status: sandbox_parser::ValidationStatus) -> URError {
}
fn validate_single_part_cbor(value: &str) -> Result<(), URError> {
+ #[cfg(feature = "tron")]
+ if super::ur_budget::is_tron(value) {
+ super::ur_budget::validate_text_len(value).map_err(URError::UrDecodeError)?;
+ }
let (kind, cbor) =
ur::decode(value).map_err(|error| URError::UrDecodeError(error.to_string()))?;
if kind != ur::ur::Kind::SinglePart {
return Ok(());
}
-
let status = sandbox_parser::validate_cbor(&cbor);
if status != sandbox_parser::ValidationStatus::Ok {
return Err(sandbox_cbor_error(status));
@@ -1039,6 +1131,8 @@ pub fn decode_ur(ur: String) -> URParseResult {
QRCodeType::AvaxSignRequest => _decode_ur::<AvaxSignRequest>(ur, ur_type),
#[cfg(not(feature = "btc-only"))]
QRCodeType::QRHardwareCall => _decode_ur::<QRHardwareCall>(ur, ur_type),
+ #[cfg(feature = "cypherpunk")]
+ QRCodeType::ZcashAddressText => URParseResult::from(RustCError::InvalidMessage),
QRCodeType::URTypeUnKnown | QRCodeType::SeedSignerMessage => URParseResult::from(
URError::NotSupportURTypeError("UnKnown ur type".to_string()),
),
@@ -1153,6 +1247,8 @@ fn receive_ur(ur: String, decoder: &mut KeystoneURDecoder) -> URParseMultiResult
QRCodeType::XmrTxUnsignedRequest => _receive_ur::<XmrTxUnsigned>(ur, ur_type, decoder),
#[cfg(feature = "avalanche")]
QRCodeType::AvaxSignRequest => _receive_ur::<AvaxSignRequest>(ur, ur_type, decoder),
+ #[cfg(feature = "cypherpunk")]
+ QRCodeType::ZcashAddressText => URParseMultiResult::from(RustCError::InvalidMessage),
QRCodeType::URTypeUnKnown | QRCodeType::SeedSignerMessage => URParseMultiResult::from(
URError::NotSupportURTypeError("UnKnown ur type".to_string()),
),
@@ -1211,3 +1307,149 @@ pub unsafe extern "C" fn receive(ur: PtrString, decoder: PtrDecoder) -> *mut URP
let decoder = extract_ptr_with_type!(decoder, KeystoneURDecoder);
receive_ur(ur, decoder).c_ptr()
}
+
+#[cfg(all(test, feature = "tron"))]
+mod tron_limit_tests {
+ use super::*;
+ use alloc::vec;
+
+ fn fragment(parts: u32, message_len: u32, data: &[u8]) -> String {
+ let mut e = minicbor::Encoder::new(Vec::new());
+ e.array(5)
+ .unwrap()
+ .u32(1)
+ .unwrap()
+ .u32(parts)
+ .unwrap()
+ .u32(message_len)
+ .unwrap()
+ .u32(0)
+ .unwrap()
+ .bytes(data)
+ .unwrap();
+ ur::encode(&e.into_writer(), "tron-sign-request").replacen(
+ "tron-sign-request/",
+ &format!("tron-sign-request/1-{parts}/"),
+ 1,
+ )
+ }
+
+ #[test]
+ fn tron_limits_enforce_frame_text_length() {
+ for (payload_len, accepted) in [(750, true), (751, false)] {
+ let mut encoder = minicbor::Encoder::new(Vec::new());
+ encoder.bytes(&vec![0; payload_len]).unwrap();
+ let single = ur::encode(&encoder.into_writer(), "tron-sign-request");
+ assert_eq!(single.len(), if accepted { 1535 } else { 1537 });
+ assert_eq!(validate_single_part_cbor(&single).is_ok(), accepted);
+ assert_eq!(
+ super::super::ur_budget::validate_text_len(&single.to_uppercase()).is_ok(),
+ accepted
+ );
+ }
+ let oversized_part = fragment(2, 2000, &[0; 1000]);
+ assert!(validate_single_part_cbor(&oversized_part).is_err());
+ assert!(KeystoneURDecoder::from_first_part(&oversized_part).is_err());
+ }
+
+ #[test]
+ fn tron_limits_reject_oversized_single_and_fountain_metadata() {
+ let max_cbor_bytes = app_tron::MAX_SIGN_DATA_LEN + 1024;
+ let too_big = ur::encode(&vec![0; max_cbor_bytes + 1], "tron-sign-request");
+ assert!(validate_single_part_cbor(&too_big)
+ .unwrap_err()
+ .to_string()
+ .contains("1536-byte limit"));
+ for bad in [
+ fragment(100, max_cbor_bytes as u32 + 1, &[0; 200]),
+ fragment(129, 129, &[0]),
+ fragment(u32::MAX, 1, &[0]),
+ fragment(0, 1, &[0]),
+ fragment(2, 1, &[0]),
+ fragment(2, 3, &[0]),
+ ] {
+ assert!(KeystoneURDecoder::from_first_part(&bad).is_err());
+ }
+ }
+
+ #[test]
+ fn tron_limits_reassemble_full_size_request_with_reordered_parts() {
+ use ur_registry::crypto_key_path::CryptoKeyPath;
+ use ur_registry::tron::tron_sign_request::DataType;
+ let req = TronSignRequest::new(
+ None,
+ vec![b'a'; app_tron::MAX_SIGN_DATA_LEN],
+ DataType::PersonalMessage,
+ CryptoKeyPath::from_path("m/44'/195'/0'/0/0".into(), Some([0x73, 0xc5, 0xda, 0x0a]))
+ .unwrap(),
+ None,
+ None,
+ );
+ let cbor = minicbor::to_vec(req).unwrap();
+ let mut encoder = ur::Encoder::new(&cbor, 200, "tron-sign-request").unwrap();
+ let mut parts: Vec<String> = (0..encoder.fragment_count())
+ .map(|_| encoder.next_part().unwrap())
+ .collect();
+ parts.reverse();
+ let first = encoder.next_part().unwrap();
+ let mut decoder = KeystoneURDecoder::from_first_part(&first).unwrap();
+ for part in parts {
+ decoder.receive(&part).unwrap();
+ }
+ assert!(decoder.complete());
+ assert_eq!(decoder.message().unwrap(), cbor);
+ let decoded = TronSignRequest::try_from(decoder.message().unwrap()).unwrap();
+ assert_eq!(decoded.get_sign_data().len(), app_tron::MAX_SIGN_DATA_LEN);
+ assert!(validate_single_part_cbor(&ur::encode(&cbor, "tron-sign-request")).is_err());
+ }
+
+ #[test]
+ fn tron_limits_bound_redundant_fragments_and_prevent_type_switching() {
+ let cbor = vec![0; 1024];
+ let mut encoder = ur::Encoder::new(&cbor, 200, "tron-sign-request").unwrap();
+ let part = encoder.next_part().unwrap();
+ let mut decoder = KeystoneURDecoder::from_first_part(&part).unwrap();
+ for _ in 0..2000 {
+ decoder.receive(&part).unwrap();
+ }
+ let mut rejected = false;
+ for _ in 0..2000 {
+ if decoder.receive(&encoder.next_part().unwrap()).is_err() {
+ rejected = true;
+ break;
+ }
+ }
+ assert!(rejected);
+ assert!(!decoder.complete());
+ assert!(decoder.message().is_err());
+ let other = part.replacen("tron-sign-request", "bytes", 1);
+ let mut decoder = KeystoneURDecoder::from_first_part(&other).unwrap();
+ assert!(decoder.receive(&part).is_err());
+ let mut decoder = KeystoneURDecoder::from_first_part(&part).unwrap();
+ assert!(decoder.receive(&other).is_err());
+ }
+}
+
+#[cfg(all(test, feature = "monero"))]
+mod monero_budget_tests {
+ use super::*;
+
+ #[test]
+ fn monero_reassembly_boundaries() {
+ let cbor = vec![0; app_monero::utils::io::MAX_REQUEST_BYTES];
+ let mut encoder = ur::Encoder::new(&cbor, 200, "xmr-txunsigned").unwrap();
+ let mut parts: Vec<String> = (0..encoder.fragment_count())
+ .map(|_| encoder.next_part().unwrap())
+ .collect();
+ parts.reverse();
+ let mut decoder = KeystoneURDecoder::from_first_part(&parts[0]).unwrap();
+ for part in &parts[1..] {
+ decoder.receive(part).unwrap();
+ }
+ assert!(decoder.complete());
+ assert_eq!(decoder.message().unwrap(), cbor);
+ let too_large = vec![0; cbor.len() + 1];
+ let mut encoder = ur::Encoder::new(&too_large, 200, "xmr-txunsigned").unwrap();
+ assert!(KeystoneURDecoder::from_first_part(&encoder.next_part().unwrap()).is_err());
+ }
+}
### rust/rust_c/src/common/ur_budget.rs
@@ -0,0 +1,135 @@
+use alloc::format;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+
+const MAX_PARTS: usize = 256;
+const MAX_WORK: usize = 512 * 1024;
+const MAX_UR_TEXT_LEN: usize = 1536;
+
+#[cfg(feature = "tron")]
+const MAX_TRON_CBOR_BYTES: usize = app_tron::MAX_SIGN_DATA_LEN + 1024;
+#[cfg(feature = "tron")]
+const MAX_TRON_PARTS: usize = 128;
+#[cfg(feature = "tron")]
+const MAX_TRON_WORK: usize = 192 * 1024;
+
+#[cfg(feature = "tron")]
+pub(super) fn is_tron(value: &str) -> bool {
+ let prefix = "ur:tron-sign-request/";
+ value
+ .get(..prefix.len())
+ .is_some_and(|s| s.eq_ignore_ascii_case(prefix))
+}
+
+pub(super) fn validate_text_len(value: &str) -> Result<(), String> {
+ if value.len() > MAX_UR_TEXT_LEN {
+ return Err(format!("UR fragment exceeds {MAX_UR_TEXT_LEN}-byte limit"));
+ }
+ Ok(())
+}
+
+#[derive(Default)]
+pub(super) struct FragmentBudget {
+ identity: Option<(String, u32, u32, u32, usize)>,
+ work: usize,
+ seen_sequences: Vec<u32>,
+ failed: bool,
+}
+
+impl FragmentBudget {
+ pub(super) fn receive(&mut self, value: &str) -> Result<(), String> {
+ if self.failed {
+ return Err("UR session rejected; restart scanning".into());
+ }
+ let result = self.check(value);
+ if result.is_err() {
+ self.failed = true;
+ }
+ result
+ }
+
+ fn check(&mut self, value: &str) -> Result<(), String> {
+ validate_text_len(value)?;
+ let prefix = value.split('/').next().ok_or("missing UR type")?;
+ let limit = if cfg!(feature = "cypherpunk")
+ && (prefix.eq_ignore_ascii_case("ur:zcash-pczt")
+ || prefix.eq_ignore_ascii_case("ur:zcash-sign-batch"))
+ {
+ 32 * 1024
+ } else {
+ 14 * 1024
+ };
+ let (max_parts, max_work) = (MAX_PARTS, MAX_WORK);
+ #[cfg(feature = "tron")]
+ let (limit, max_parts, max_work) = if is_tron(value) {
+ (MAX_TRON_CBOR_BYTES, MAX_TRON_PARTS, MAX_TRON_WORK)
+ } else {
+ (limit, max_parts, max_work)
+ };
+ #[cfg(feature = "monero")]
+ let (limit, max_parts, max_work) = if prefix
+ .get(..7)
+ .is_some_and(|s| s.eq_ignore_ascii_case("ur:xmr-"))
+ {
+ (app_monero::utils::io::MAX_REQUEST_BYTES, 128, 192 * 1024)
+ } else {
+ (limit, max_parts, max_work)
+ };
+ let (kind, cbor) = ur::decode(value).map_err(|_| "invalid UR fragment")?;
+ if kind != ur::ur::Kind::MultiPart {
+ return Err("expected multipart UR".into());
+ }
+ let mut d = minicbor::Decoder::new(&cbor);
+ let mut read = || -> Result<_, minicbor::decode::Error> {
+ if d.array()? != Some(5) {
+ return Err(minicbor::decode::Error::message("invalid fountain part"));
+ }
+ Ok((d.u32()?, d.u32()?, d.u32()?, d.u32()?, d.bytes()?.len()))
+ };
+ let (sequence, parts, message_len, checksum, bytes) =
+ read().map_err(|_| "invalid fountain metadata")?;
+ if message_len as usize > limit {
+ return Err(format!(
+ "reconstructed CBOR exceeds device size limit: type={}, bytes={}, limit={}",
+ prefix, message_len, limit
+ ));
+ }
+ if sequence == 0
+ || parts == 0
+ || parts as usize > max_parts
+ || message_len == 0
+ || bytes == 0
+ || d.position() != cbor.len()
+ || message_len as usize > parts as usize * bytes
+ || message_len as usize <= (parts as usize - 1) * bytes
+ {
+ return Err(format!("invalid fountain dimensions: sequence={}, parts={} (max {}), message_bytes={}, fragment_bytes={}", sequence, parts, max_parts, message_len, bytes));
+ }
+ if let Some((ref old_type, old_parts, old_length, old_checksum, old_bytes)) = self.identity
+ {
+ if !old_type.eq_ignore_ascii_case(prefix)
+ || old_parts != parts
+ || old_length != message_len
+ || old_checksum != checksum
+ || old_bytes != bytes
+ {
+ return Err("UR fragment changed session metadata".into());
+ }
+ } else {
+ self.identity = Some((prefix.to_string(), parts, message_len, checksum, bytes));
+ }
+ if self.seen_sequences.contains(&sequence) {
+ return Ok(());
+ }
+ let index_bound = if sequence <= parts { 1 } else { parts as usize };
+ self.work = self
+ .work
+ .checked_add(bytes + index_bound * 8 + 128)
+ .ok_or("UR fragment budget overflow")?;
+ if self.work > max_work {
+ return Err("UR fragment work budget exhausted; restart scanning".into());
+ }
+ self.seen_sequences.push(sequence);
+ Ok(())
+ }
+}
### rust/rust_c/src/common/ur_ext.rs
@@ -90,7 +90,7 @@ impl InferViewType for CryptoPSBTExtend {
match self.get_coin_id() {
Some(2) => Ok(ViewType::LtcTx),
Some(3) => Ok(ViewType::DogeTx),
- Some(4) => Ok(ViewType::DashTx),
+ Some(5) => Ok(ViewType::DashTx),
Some(145) => Ok(ViewType::BchTx),
_ => Ok(ViewType::BtcTx),
}
@@ -466,6 +466,55 @@ impl InferViewType for QRHardwareCall {
#[cfg(test)]
mod tests {
+ #[cfg(feature = "multi-coins")]
+ #[test]
+ fn dash_psbt_extend_uses_coin_id_five() {
+ use super::CryptoPSBTExtend;
+ let request = CryptoPSBTExtend::try_from(hex::decode("a20142aabb0205").unwrap()).unwrap();
+ assert_eq!(request.get_coin_id(), Some(5));
+ assert!(matches!(request.infer(), Ok(ViewType::DashTx)));
+ }
+
+ #[cfg(feature = "solana")]
+ #[test]
+ fn solana_view_type_follows_the_payload_not_the_type_hint() {
+ use super::{InferViewType, SolSignRequest, ViewType};
+ use ur_registry::solana::sol_sign_request::SignType;
+ let dataset: serde_json::Value =
+ serde_json::from_str(include_str!("../../tests/fixtures/solana-security.json"))
+ .unwrap();
+ for fixture in dataset["fixtures"].as_array().unwrap() {
+ let mut decoder = ur::Decoder::default();
+ for frame in fixture["ur"].as_array().unwrap() {
+ decoder
+ .receive(&frame.as_str().unwrap().to_lowercase())
+ .unwrap();
+ }
+ let mut request =
+ SolSignRequest::try_from(decoder.message().unwrap().unwrap()).unwrap();
+ let expected = match app_solana::classify_payload(&request.get_sign_data()) {
+ app_solana::SolanaPayloadType::Message => ViewType::SolanaMessage,
+ app_solana::SolanaPayloadType::Transaction
+ | app_solana::SolanaPayloadType::MalformedTransaction => ViewType::SolanaTx,
+ };
+ assert_eq!(
+ request.infer().ok().as_ref(),
+ Some(&expected),
+ "{}",
+ fixture["id"]
+ );
+ request.set_sign_type(match request.get_sign_type() {
+ SignType::Transaction => SignType::Message,
+ SignType::Message => SignType::Transaction,
+ });
+ assert_eq!(
+ request.infer().ok().as_ref(),
+ Some(&expected),
+ "type hint changed the view type of {}",
+ fixture["id"]
+ );
+ }
+ }
use alloc::vec::Vec;
use hex::FromHex;
### rust/rust_c/src/monero/mod.rs
@@ -16,6 +16,7 @@ use crate::common::types::{PtrBytes, PtrString, PtrT, PtrUR};
use crate::common::utils::{convert_c_char, recover_c_char};
use crate::extract_array;
use crate::extract_ptr_with_type;
+use core::ffi::c_void;
use cty::c_char;
use rand_core::OsRng;
use structs::{DisplayMoneroOutput, DisplayMoneroUnsignedTx};
@@ -24,6 +25,7 @@ use ur_registry::monero::xmr_output::XmrOutput;
use ur_registry::monero::xmr_txsigned::XmrTxSigned;
use ur_registry::monero::xmr_txunsigned::XmrTxUnsigned;
use ur_registry::traits::{RegistryItem, To};
+use zeroize::{Zeroize, Zeroizing};
mod structs;
@@ -35,16 +37,33 @@ pub unsafe extern "C" fn monero_get_address(
minor: u32,
is_subaddress: bool,
) -> *mut SimpleResponse<c_char> {
- let spend_key = recover_c_char(pub_spend_key);
- let pvk = hex::decode(recover_c_char(private_view_key)).unwrap();
-
- match app_monero::address::generate_address(
- &PublicKey::from_str(spend_key.as_str()).unwrap(),
- &PrivateKey::from_bytes(&pvk),
- major,
- minor,
- is_subaddress,
- ) {
+ if pub_spend_key.is_null() {
+ return SimpleResponse::from(RustCError::InvalidXPub).simple_c_ptr();
+ }
+ let spend_key = cstr_core::CStr::from_ptr(pub_spend_key).to_bytes();
+ let pvk_bytes = match parse_view_key(private_view_key) {
+ Ok(key) => key,
+ Err(e) => return SimpleResponse::from(e).simple_c_ptr(),
+ };
+ let pvk = match PrivateKey::try_from_slice(&*pvk_bytes) {
+ Ok(key) => key,
+ Err(_) => {
+ return SimpleResponse::from(RustCError::InvalidData("invalid view key".into()))
+ .simple_c_ptr()
+ }
+ };
+ let public_spend = match hex::decode(spend_key)
+ .ok()
+ .and_then(|bytes| PublicKey::from_bytes(&bytes).ok())
+ {
+ Some(key) => key,
+ _ => {
+ return SimpleResponse::from(RustCError::InvalidData("invalid data".to_string()))
+ .simple_c_ptr()
+ }
+ };
+
+ match app_monero::address::generate_address(&public_spend, &pvk, major, minor, is_subaddress) {
Ok(address) => SimpleResponse::success(convert_c_char(address.to_string()) as *mut c_char)
.simple_c_ptr(),
_ => {
@@ -53,14 +72,27 @@ pub unsafe extern "C" fn monero_get_address(
}
}
-unsafe fn safe_parse_key(decrypt_key: PtrBytes) -> Result<[u8; PRVKEY_LEH], RustCError> {
- let decrypt_key = extract_array!(decrypt_key, u8, PRVKEY_LEH);
-
- if decrypt_key.len() != PRVKEY_LEH {
+unsafe fn safe_parse_key(decrypt_key: PtrBytes) -> Result<Zeroizing<[u8; PRVKEY_LEH]>, RustCError> {
+ if decrypt_key.is_null() {
return Err(RustCError::InvalidMasterFingerprint);
}
+ let bytes = extract_array!(decrypt_key, u8, PRVKEY_LEH);
+ Ok(Zeroizing::new(
+ bytes
+ .try_into()
+ .map_err(|_| RustCError::InvalidMasterFingerprint)?,
+ ))
+}
- Ok(decrypt_key.try_into().unwrap())
+unsafe fn parse_view_key(ptr: PtrString) -> Result<Zeroizing<[u8; PRVKEY_LEH]>, RustCError> {
+ if ptr.is_null() {
+ return Err(RustCError::InvalidMasterFingerprint);
+ }
+ let mut key = Zeroizing::new([0; PRVKEY_LEH]);
+ let text = cstr_core::CStr::from_ptr(ptr).to_bytes();
+ hex::decode_to_slice(text, &mut *key).map_err(|_| RustCError::InvalidMasterFingerprint)?;
+ PrivateKey::try_from_slice(&*key).map_err(|_| RustCError::InvalidMasterFingerprint)?;
+ Ok(key)
}
#[no_mangle]
@@ -69,18 +101,27 @@ pub unsafe extern "C" fn monero_output_request_check(
decrypt_key: PtrBytes,
pvk: PtrString,
) -> PtrT<TransactionCheckResult> {
+ if ptr.is_null() {
+ return TransactionCheckResult::from(RustCError::InvalidData(
+ "missing request data".into(),
+ ))
+ .c_ptr();
+ }
let request = extract_ptr_with_type!(ptr, XmrOutput);
let decrypt_key = match safe_parse_key(decrypt_key) {
Ok(decrypt_key) => decrypt_key,
_ => return TransactionCheckResult::from(RustCError::InvalidMasterFingerprint).c_ptr(),
};
- let pvk = hex::decode(recover_c_char(pvk)).unwrap();
+ let pvk = match parse_view_key(pvk) {
+ Ok(pvk) => pvk,
+ _ => return TransactionCheckResult::from(RustCError::InvalidMasterFingerprint).c_ptr(),
+ };
let payload = request.get_payload();
match app_monero::utils::decrypt_data_with_decrypt_key(
- decrypt_key,
- pvk.try_into().unwrap(),
+ *decrypt_key,
+ *pvk,
payload,
OUTPUT_EXPORT_MAGIC,
) {
@@ -94,24 +135,52 @@ pub unsafe extern "C" fn monero_unsigned_request_check(
ptr: PtrUR,
decrypt_key: PtrBytes,
pvk: PtrString,
+ pub_spend_key: PtrString,
) -> PtrT<TransactionCheckResult> {
+ clear_approved_unsigned_tx();
+ if ptr.is_null() {
+ return TransactionCheckResult::from(RustCError::InvalidData(
+ "missing request data".into(),
+ ))
+ .c_ptr();
+ }
let request = extract_ptr_with_type!(ptr, XmrTxUnsigned);
let decrypt_key = match safe_parse_key(decrypt_key) {
- Ok(decrypt_key) => decrypt_key,
- _ => return TransactionCheckResult::from(RustCError::InvalidMasterFingerprint).c_ptr(),
+ Ok(key) => key,
+ Err(_) => {
+ return TransactionCheckResult::from(RustCError::InvalidMasterFingerprint).c_ptr()
+ }
};
- let pvk = hex::decode(recover_c_char(pvk)).unwrap();
-
- let payload = request.get_payload();
-
- match app_monero::utils::decrypt_data_with_decrypt_key(
- decrypt_key,
- pvk.try_into().unwrap(),
- payload,
- UNSIGNED_TX_PREFIX,
+ if pvk.is_null() || pub_spend_key.is_null() {
+ return TransactionCheckResult::from(RustCError::InvalidData(
+ "missing wallet keys".to_string(),
+ ))
+ .c_ptr();
+ }
+ let pvk = match parse_view_key(pvk) {
+ Ok(key) => key,
+ Err(_) => {
+ return TransactionCheckResult::from(RustCError::InvalidMasterFingerprint).c_ptr()
+ }
+ };
+ let public_spend: [u8; 32] = match hex::decode(recover_c_char(pub_spend_key))
+ .ok()
+ .and_then(|v| v.try_into().ok())
+ {
+ Some(key) => key,
+ None => return TransactionCheckResult::from(RustCError::InvalidXPub).c_ptr(),
+ };
+ match app_monero::transfer::check_unsigned(
+ request.get_payload(),
+ *decrypt_key,
+ *pvk,
+ public_spend,
) {
Ok(_) => TransactionCheckResult::new().c_ptr(),
- Err(_) => TransactionCheckResult::from(RustCError::InvalidMasterFingerprint).c_ptr(),
+ Err(app_monero::errors::MoneroError::MismatchedMfp) => {
+ TransactionCheckResult::from(RustCError::InvalidMasterFingerprint).c_ptr()
+ }
+ Err(e) => TransactionCheckResult::from(RustCError::InvalidData(e.to_string())).c_ptr(),
}
}
@@ -139,51 +208,172 @@ pub unsafe extern "C" fn monero_parse_output(
decrypt_key: PtrBytes,
pvk: PtrString,
) -> PtrT<TransactionParseResult<DisplayMoneroOutput>> {
+ if ptr.is_null() {
+ return TransactionParseResult::from(RustCError::InvalidData(
+ "missing request data".into(),
+ ))
+ .c_ptr();
+ }
let request = extract_ptr_with_type!(ptr, XmrOutput);
let decrypt_key = match safe_parse_key(decrypt_key) {
Ok(decrypt_key) => decrypt_key,
_ => return TransactionParseResult::from(RustCError::InvalidMasterFingerprint).c_ptr(),
};
- let pvk = hex::decode(recover_c_char(pvk)).unwrap();
+ let pvk = match parse_view_key(pvk) {
+ Ok(key) => key,
+ Err(e) => return TransactionParseResult::from(e).c_ptr(),
+ };
- match app_monero::outputs::parse_display_info(
- &request.get_payload(),
- decrypt_key,
- pvk.try_into().unwrap(),
- ) {
+ match app_monero::outputs::parse_display_info(&request.get_payload(), *decrypt_key, *pvk) {
Ok(display) => TransactionParseResult::success(Box::into_raw(Box::new(
DisplayMoneroOutput::from(display),
)))
.c_ptr(),
- Err(_) => TransactionParseResult::from(RustCError::InvalidData("invalid data".to_string()))
- .c_ptr(),
+ Err(error) => {
+ TransactionParseResult::from(RustCError::InvalidData(error.to_string())).c_ptr()
+ }
+ }
+}
+
+struct ApprovalState {
+ locked: core::sync::atomic::AtomicBool,
+ digest: core::cell::UnsafeCell<(u64, Option<[u8; 32]>)>,
+}
+unsafe impl Sync for ApprovalState {}
+static APPROVED_UNSIGNED_TX: ApprovalState = ApprovalState {
+ locked: core::sync::atomic::AtomicBool::new(false),
+ digest: core::cell::UnsafeCell::new((0, None)),
+};
+
+fn with_approval_state<T>(f: impl FnOnce(&mut (u64, Option<[u8; 32]>)) -> T) -> T {
+ use core::sync::atomic::Ordering;
+ #[cfg(target_arch = "arm")]
+ let interrupt_mask: u32;
+ #[cfg(target_arch = "arm")]
+ unsafe {
+ core::arch::asm!("mrs {}, PRIMASK", "cpsid i", out(reg) interrupt_mask);
+ }
+ while APPROVED_UNSIGNED_TX
+ .locked
+ .compare_exchange_weak(false, true, Ordering::Acquire, Ordering::Relaxed)
+ .is_err()
+ {
+ core::hint::spin_loop();
}
+ struct Guard {
+ #[cfg(target_arch = "arm")]
+ interrupt_mask: u32,
+ }
+ impl Drop for Guard {
+ fn drop(&mut self) {
+ APPROVED_UNSIGNED_TX.locked.store(false, Ordering::Release);
+ #[cfg(target_arch = "arm")]
+ unsafe {
+ core::arch::asm!("msr PRIMASK, {}", in(reg) self.interrupt_mask);
+ }
+ }
+ }
+ let _guard = Guard {
+ #[cfg(target_arch = "arm")]
+ interrupt_mask,
+ };
+ f(unsafe { &mut *APPROVED_UNSIGNED_TX.digest.get() })
+}
+
+fn remember_approved_unsigned_tx(payload: &[u8], generation: u64) -> bool {
+ let digest = app_monero::transfer::payload_digest(payload);
+ with_approval_state(|state| {
+ if state.0 != generation {
+ return false;
+ }
+ state.1 = Some(digest);
+ true
+ })
+}
+
+#[cfg(test)]
+fn approved_unsigned_tx_matches(payload: &[u8]) -> bool {
+ let digest = app_monero::transfer::payload_digest(payload);
+ with_approval_state(|state| state.1 == Some(digest))
+}
+
+fn take_approved_unsigned_tx(payload: &[u8]) -> bool {
+ let digest = app_monero::transfer::payload_digest(payload);
+ with_approval_state(|state| {
+ state.0 = state.0.wrapping_add(1);
+ state.1.take() == Some(digest)
+ })
+}
+
+fn clear_approved_unsigned_tx() -> u64 {
+ with_approval_state(|state| {
+ state.0 = state.0.wrapping_add(1);
+ state.1 = None;
+ state.0
+ })
+}
+
+#[no_mangle]
+pub extern "C" fn monero_clear_transaction_state() {
+ clear_approved_unsigned_tx();
}
#[no_mangle]
pub unsafe extern "C" fn monero_parse_unsigned_tx(
ptr: PtrUR,
decrypt_key: PtrBytes,
pvk: PtrString,
+ pub_spend_key: PtrString,
) -> PtrT<TransactionParseResult<DisplayMoneroUnsignedTx>> {
+ let generation = clear_approved_unsigned_tx();
+ if pvk.is_null() || pub_spend_key.is_null() {
+ return TransactionParseResult::from(RustCError::InvalidData("missing wallet keys".into()))
+ .c_ptr();
+ }
+ if ptr.is_null() {
+ return TransactionParseResult::from(RustCError::InvalidData(
+ "missing request data".into(),
+ ))
+ .c_ptr();
+ }
let request = extract_ptr_with_type!(ptr, XmrTxUnsigned);
let decrypt_key = match safe_parse_key(decrypt_key) {
Ok(decrypt_key) => decrypt_key,
_ => return TransactionParseResult::from(RustCError::InvalidMasterFingerprint).c_ptr(),
};
- let pvk = hex::decode(recover_c_char(pvk)).unwrap();
+ let pvk = match parse_view_key(pvk) {
+ Ok(pvk) => pvk,
+ _ => return TransactionParseResult::from(RustCError::InvalidMasterFingerprint).c_ptr(),
+ };
+ let public_spend = match hex::decode(recover_c_char(pub_spend_key)) {
+ Ok(key) if key.len() == PRVKEY_LEH => key,
+ _ => return TransactionParseResult::from(RustCError::InvalidXPub).c_ptr(),
+ };
+
+ let payload = request.get_payload();
match app_monero::transfer::parse_unsigned(
- request.get_payload(),
- decrypt_key,
- pvk.try_into().unwrap(),
+ payload.clone(),
+ *decrypt_key,
+ *pvk,
+ public_spend.try_into().unwrap(),
) {
- Ok(display) => TransactionParseResult::success(Box::into_raw(Box::new(
- DisplayMoneroUnsignedTx::from(display),
- )))
- .c_ptr(),
- Err(_) => TransactionParseResult::from(RustCError::InvalidData("invalid data".to_string()))
- .c_ptr(),
+ Ok(display) => {
+ if !remember_approved_unsigned_tx(&payload, generation) {
+ return TransactionParseResult::from(RustCError::InvalidData(
+ "transaction session ended".into(),
+ ))
+ .c_ptr();
+ }
+ TransactionParseResult::success(Box::into_raw(Box::new(DisplayMoneroUnsignedTx::from(
+ display,
+ ))))
+ .c_ptr()
+ }
+ Err(error) => {
+ clear_approved_unsigned_tx();
+ TransactionParseResult::from(RustCError::InvalidData(error.to_string())).c_ptr()
+ }
}
}
@@ -194,9 +384,19 @@ pub unsafe extern "C" fn monero_generate_keyimage(
seed_len: u32,
major: u32,
) -> PtrT<UREncodeResult> {
+ if ptr.is_null() || seed.is_null() || seed_len == 0 {
+ return UREncodeResult::from(RustCError::InvalidData("missing request data".into()))
+ .c_ptr();
+ }
let request = extract_ptr_with_type!(ptr, XmrOutput);
let seed = extract_array!(seed, u8, seed_len as usize);
- let keypair = app_monero::key::generate_keypair(seed, major).unwrap();
+ let keypair = match app_monero::key::generate_keypair(seed, major) {
+ Ok(keypair) => keypair,
+ _ => {
+ return UREncodeResult::from(RustCError::InvalidData("invalid seed".to_string()))
+ .c_ptr()
+ }
+ };
match app_monero::key_images::generate_export_ur_data(keypair, request.get_payload(), OsRng) {
Ok(data) => {
let data = XmrKeyImage::new(data);
@@ -219,10 +419,33 @@ pub unsafe extern "C" fn monero_generate_signature(
seed_len: u32,
major: u32,
) -> PtrT<UREncodeResult> {
+ if ptr.is_null() || seed.is_null() || seed_len == 0 {
+ clear_approved_unsigned_tx();
+ return UREncodeResult::from(RustCError::InvalidData("missing request data".into()))
+ .c_ptr();
+ }
let request = extract_ptr_with_type!(ptr, XmrTxUnsigned);
let seed = extract_array!(seed, u8, seed_len as usize);
- let keypair = app_monero::key::generate_keypair(seed, major).unwrap();
- match app_monero::transfer::sign_tx(keypair, request.get_payload()) {
+ let payload = request.get_payload();
+ let matches = take_approved_unsigned_tx(&payload);
+ if !matches {
+ return UREncodeResult::from(RustCError::InvalidData(
+ "unapproved transaction".to_string(),
+ ))
+ .c_ptr();
+ }
+
+ let keypair = match app_monero::key::generate_keypair(seed, major) {
+ Ok(keypair) => keypair,
+ _ => {
+ return UREncodeResult::from(RustCError::InvalidData("invalid seed".to_string()))
+ .c_ptr()
+ }
+ };
+ let result = app_monero::transfer::sign_tx(keypair, payload);
+ clear_approved_unsigned_tx();
+
+ match result {
Ok(data) => {
let data = XmrTxSigned::new(data);
@@ -239,13 +462,35 @@ pub unsafe extern "C" fn monero_generate_signature(
#[no_mangle]
pub unsafe extern "C" fn monero_generate_decrypt_key(pvk: PtrString) -> *mut SimpleResponse<u8> {
- let pvk = hex::decode(recover_c_char(pvk)).unwrap();
+ if pvk.is_null() {
+ return SimpleResponse::from(RustCError::InvalidMasterFingerprint).simple_c_ptr();
+ }
+ let pvk = match parse_view_key(pvk) {
+ Ok(pvk) => pvk,
+ _ => return SimpleResponse::from(RustCError::InvalidMasterFingerprint).simple_c_ptr(),
+ };
- let key = app_monero::utils::generate_decrypt_key(pvk.try_into().unwrap());
+ let key = app_monero::utils::generate_decrypt_key(*pvk);
SimpleResponse::success(Box::into_raw(Box::new(key)) as *mut u8).simple_c_ptr()
}
+#[no_mangle]
+pub unsafe extern "C" fn monero_free_decrypt_key_response(response: *mut c_void) {
+ if response.is_null() {
+ return;
+ }
+
+ let response = response as *mut SimpleResponse<u8>;
+ let data = (*response).data;
+ if !data.is_null() {
+ let mut key = Box::from_raw(data as *mut [u8; PRVKEY_LEH]);
+ key.zeroize();
+ }
+ (*response).data = core::ptr::null_mut();
+ crate::common::free::free_simple_response_u8(response);
+}
+
#[no_mangle]
pub unsafe extern "C" fn get_extended_monero_pubkeys_by_seed(
seed: PtrBytes,
@@ -267,3 +512,123 @@ pub unsafe extern "C" fn get_extended_monero_pubkeys_by_seed(
SimpleResponse::success(convert_c_char(result.to_string())).simple_c_ptr()
}
+
+#[cfg(test)]
+mod request_boundary_tests {
+ use super::*;
+
+ #[test]
+ fn receive_address_ffi_key_boundaries() {
+ unsafe {
+ let view = cstr_core::CString::new(alloc::format!("01{}", "00".repeat(31))).unwrap();
+ for bytes in [
+ alloc::vec![b'f'; 64],
+ alloc::vec![b'0'; 64],
+ alloc::format!("01{}", "00".repeat(31)).into_bytes(),
+ alloc::vec![0xff; 64],
+ ] {
+ let spend = cstr_core::CString::new(bytes).unwrap();
+ for subaddress in [false, true] {
+ let result = monero_get_address(
+ spend.as_ptr() as PtrString,
+ view.as_ptr() as PtrString,
+ 0,
+ 1,
+ subaddress,
+ );
+ assert!(!result.is_null());
+ assert!((*result).data.is_null());
+ crate::common::free::free_simple_response_c_char(result);
+ }
+ }
+ let spend = cstr_core::CString::new(alloc::format!("58{}", "66".repeat(31))).unwrap();
+ for subaddress in [false, true] {
+ let result = monero_get_address(
+ spend.as_ptr() as PtrString,
+ view.as_ptr() as PtrString,
+ 0,
+ 1,
+ subaddress,
+ );
+ assert!(!(*result).data.is_null());
+ crate::common::free::free_simple_response_c_char(result);
+ }
+ }
+ }
+
+ #[test]
+ fn view_key_text_boundaries() {
+ unsafe {
+ let invalid = cstr_core::CString::new(alloc::vec![0xff; 64]).unwrap();
+ assert!(parse_view_key(invalid.as_ptr() as PtrString).is_err());
+ let zero = cstr_core::CString::new("00".repeat(32)).unwrap();
+ assert!(parse_view_key(zero.as_ptr() as PtrString).is_err());
+ let valid = cstr_core::CString::new(alloc::format!("01{}", "00".repeat(31))).unwrap();
+ let key = parse_view_key(valid.as_ptr() as PtrString).unwrap();
+ assert_eq!(key[0], 1);
+ }
+ }
+
+ #[test]
+ fn missing_keys_clear_parse_state() {
+ unsafe {
+ let generation = clear_approved_unsigned_tx();
+ assert!(remember_approved_unsigned_tx(b"request", generation));
+ assert!(!take_approved_unsigned_tx(b"other"));
+ assert!(!approved_unsigned_tx_matches(b"request"));
+ let generation = clear_approved_unsigned_tx();
+ monero_clear_transaction_state();
+ assert!(!remember_approved_unsigned_tx(b"request", generation));
+ let generation = clear_approved_unsigned_tx();
+ assert!(remember_approved_unsigned_tx(b"request", generation));
+ assert!(take_approved_unsigned_tx(b"request"));
+ assert!(!take_approved_unsigned_tx(b"request"));
+ let generation = clear_approved_unsigned_tx();
+ assert!(remember_approved_unsigned_tx(b"request", generation));
+ let result = monero_parse_unsigned_tx(
+ core::ptr::null_mut(),
+ core::ptr::null_mut(),
+ core::ptr::null_mut(),
+ core::ptr::null_mut(),
+ );
+ assert!(!approved_unsigned_tx_matches(b"request"));
+ (*result).free();
+ drop(Box::from_raw(result));
+ for result in [
+ monero_output_request_check(
+ core::ptr::null_mut(),
+ core::ptr::null_mut(),
+ core::ptr::null_mut(),
+ ),
+ monero_unsigned_request_check(
+ core::ptr::null_mut(),
+ core::ptr::null_mut(),
+ core::ptr::null_mut(),
+ core::ptr::null_mut(),
+ ),
+ ] {
+ assert!(!result.is_null());
+ (*result).free();
+ drop(Box::from_raw(result));
+ }
+ let result = monero_parse_output(
+ core::ptr::null_mut(),
+ core::ptr::null_mut(),
+ core::ptr::null_mut(),
+ );
+ (*result).free();
+ drop(Box::from_raw(result));
+ for result in [
+ monero_generate_keyimage(core::ptr::null_mut(), core::ptr::null_mut(), 0, 0),
+ monero_generate_signature(core::ptr::null_mut(), core::ptr::null_mut(), 0, 0),
+ ] {
+ assert!(!result.is_null());
+ (*result).free();
+ drop(Box::from_raw(result));
+ }
+ let result = monero_generate_decrypt_key(core::ptr::null_mut());
+ assert!(!result.is_null());
+ monero_free_decrypt_key_response(result.cast());
+ }
+ }
+}
### rust/rust_c/src/monero/structs.rs
@@ -22,12 +22,15 @@ pub struct DisplayMoneroUnsignedTxOutput {
address: PtrString,
amount: PtrString,
is_change: bool,
+ is_integrated: bool,
+ payment_id: PtrString,
}
impl Free for DisplayMoneroUnsignedTxOutput {
unsafe fn free(&self) {
free_str_ptr!(self.address);
free_str_ptr!(self.amount);
+ free_str_ptr!(self.payment_id);
}
}
@@ -61,9 +64,11 @@ impl From<DisplayTransactionInfo> for DisplayMoneroUnsignedTx {
.outputs
.iter()
.map(|output| DisplayMoneroUnsignedTxOutput {
- address: convert_c_char(output.0.to_string()),
- amount: convert_c_char(output.1.to_string()),
- is_change: output.2,
+ address: convert_c_char(output.address.clone()),
+ amount: convert_c_char(output.amount.clone()),
+ is_change: output.is_change,
+ is_integrated: output.is_integrated,
+ payment_id: convert_c_char(output.payment_id.clone()),
})
.collect::<Vec<DisplayMoneroUnsignedTxOutput>>(),
)
### rust/rust_c/src/sandbox_parser.rs
@@ -20,6 +20,35 @@ pub unsafe extern "C" fn mpu_sandbox_validate_cbor(input: *const u8, input_len:
sandbox_parser::validate_cbor(input) as u32
}
+#[no_mangle]
+#[cfg_attr(target_os = "none", link_section = ".sandbox_parser_entry")]
+pub unsafe extern "C" fn mpu_sandbox_cbor_stream_push(
+ storage: *mut u8,
+ capacity: usize,
+ input: *const u8,
+ input_len: usize,
+ last: bool,
+) -> u32 {
+ use sandbox_parser::cbor_stream::State;
+ const MAX_STREAM_INPUT_LEN: usize = 232 - 4;
+ if storage.is_null()
+ || input.is_null()
+ || input_len > MAX_STREAM_INPUT_LEN
+ || capacity < core::mem::size_of::<State>()
+ || (storage as usize) % core::mem::align_of::<State>() != 0
+ {
+ return sandbox_parser::ValidationStatus::InvalidInput as u32;
+ }
+ let state = unsafe { &mut *storage.cast::<State>() };
+ let input = unsafe { core::slice::from_raw_parts(input, input_len) };
+ state.push(input);
+ if last {
+ state.finish()
+ } else {
+ 0
+ }
+}
+
#[no_mangle]
#[cfg_attr(target_os = "none", link_section = ".sandbox_parser_entry")]
pub unsafe extern "C" fn mpu_sandbox_validate_eip712_json(input: *mut u8, input_len: usize) -> u32 {
### rust/rust_c/src/solana/README.md
@@ -24,6 +24,29 @@
| seed | uint8 \* | seed of current wallet |
| seed_len | uint32 | length of seed |
+## Validation and ownership
+
+`solana_check` requires a non-null, four-byte device fingerprint matching the
+request source fingerprint. `solana_parse_tx` and `solana_parse_tx_with_pubkey`
+reuse `validated_payload` and accept only Transaction requests; the latter also
+checks the supplied signer public key.
+
+Final signing validates the payload and path, derives the BIP32 master fingerprint
+from the actual signing seed and rejects missing or mismatched source fingerprints.
+Transactions additionally require the derived public key to be a required signer.
+The signature covers the original request bytes. Arbitrary-message classification
+still has the truncated/unknown-version limitations described in the specification.
+
+Both successful and failed parse results must be released with the matching
+`free_TransactionParseResult_DisplaySolanaTx` or
+`free_TransactionParseResult_DisplaySolanaMessage` function. C page entry points
+release failed results before returning.
+
+Raw instruction Overview retains message-level V1 configuration in `general`.
+The UI renders warning, configuration, then instructions; metadata uses ordinal 0
+and does not change instruction numbering. Squads creation and Squads with System
+transfers use this layout, while ordinary proposals may retain their dedicated UI.
+
## Structs
### <a id="display_solana_tx">DisplaySolanaTx</a>
@@ -32,7 +55,24 @@
|:---------|:----------------------------------------------------------|:--------------------------------------------------------------|
| overview | [DisplaySolanaTxOverview](#display_solana_tx_overview) \* | the specific values on overview page |
| detail | char \* | the [json string](#detail_json_string_example) on detail page |
-| network | char \* | network text, "Solana Mainnet" |
+| advanced | VecFFI<DisplaySolanaAdvancedItem> \* | structured Advanced review items |
+| network | char \* | "Solana / Cluster not encoded"; the message does not identify the cluster |
+
+`DisplaySolanaTx` follows the `#[repr(C)]` field order in `structs.rs`:
+`network`, `overview`, `detail`, `advanced`. Generated bindings are authoritative
+for the C layout; the field table above is descriptive.
+
+`advanced` is a pointer to `VecFFI<DisplaySolanaAdvancedItem>`. Each item contains
+owned `title` and `value` strings with internal `{{solana_advanced_*}}` translation
+tokens, expanded by the C UI. They must not be displayed verbatim. Release the
+result through the existing transaction parse result cleanup; do not free these
+fields separately.
+
+`detail` now contains lossless wire-message JSON, not the old semantic instruction
+array. The historical examples below describe business resolver output only;
+they are not the current `detail` contract. See
+[Solana transaction review specification](../../../../specs/solana-transaction-review.md) for the current
+review behavior and format boundaries.
### <a id="display_solana_tx_overview">DisplaySolanaTxOverview</a>
@@ -45,7 +85,7 @@
| transfer_to | char \* | available for `"Transfer"` display type |
| votes_on | [DisplaySolanaTxOverviewVotesOn](#display_solana_tx_overview_votes_on) \* | available for `"Vote"` display type, a list of slots |
| vote_account | char \* | available for `"Vote"` display type |
-| general | [DisplaySolanaTxOverviewGeneral](#display_solana_tx_overview_general) \* | available for `"General"` display type, a list of general overview for programs |
+| general | [DisplaySolanaTxOverviewGeneral](#display_solana_tx_overview_general) \* | general program cards and additional metadata; includes V1 TransactionConfig in raw review |
### <a id="display_solana_tx_overview_votes_on">DisplaySolanaTxOverviewVotesOn</a>
### rust/rust_c/src/solana/mod.rs
@@ -4,7 +4,6 @@ use crate::common::types::{PtrBytes, PtrString, PtrT, PtrUR};
use crate::common::ur::{UREncodeResult, FRAGMENT_MAX_LENGTH_DEFAULT};
use crate::common::utils::{convert_c_char, recover_c_char};
use crate::{extract_array, extract_ptr_with_type};
-use alloc::format;
use alloc::string::ToString;
use app_solana::errors::SolanaError;
use app_solana::parse_message;
@@ -16,10 +15,493 @@ use ur_registry::traits::RegistryItem;
pub mod structs;
+fn validated_payload(
+ request: &SolSignRequest,
+) -> Result<app_solana::SolanaPayloadType, SolanaError> {
+ let data = request.get_sign_data();
+ match app_solana::classify_payload(&data) {
+ app_solana::SolanaPayloadType::Message => Ok(app_solana::SolanaPayloadType::Message),
+ app_solana::SolanaPayloadType::Transaction => {
+ app_solana::parse(&data)?;
+ Ok(app_solana::SolanaPayloadType::Transaction)
+ }
+ app_solana::SolanaPayloadType::MalformedTransaction => Err(SolanaError::InvalidData(
+ "invalid or unsupported transaction data".to_string(),
+ )),
+ }
+}
+
+#[cfg(test)]
+mod fixture_tests {
+ use super::*;
+ use ur_registry::solana::sol_sign_request::SignType;
+
+ unsafe fn parse_tx_results(request: &mut SolSignRequest) -> usize {
+ use crate::common::free::Free;
+ let ptr = request as *mut _ as PtrUR;
+ let signer = app_solana::message::Message::read_exact(&mut request.get_sign_data())
+ .ok()
+ .and_then(|message| {
+ message
+ .accounts
+ .first()
+ .map(|account| hex::encode(&account.value))
+ })
+ .unwrap_or_else(|| "00".repeat(32));
+ let pubkey = cstr_core::CString::new(signer).unwrap();
+ let mut produced = 0;
+ for result in [
+ solana_parse_tx(ptr),
+ solana_parse_tx_with_pubkey(ptr, pubkey.as_ptr() as PtrString),
+ ] {
+ if !(*(result as *const *mut DisplaySolanaTx)).is_null() {
+ produced += 1;
+ }
+ let result = alloc::boxed::Box::from_raw(result);
+ result.free();
+ }
+ produced
+ }
+
+ unsafe fn checked_signature(
+ request: &mut SolSignRequest,
+ seed: &[u8],
+ ) -> Option<alloc::vec::Vec<u8>> {
+ use crate::common::free::Free;
+ let result = alloc::boxed::Box::from_raw(solana_sign_checked_tx(
+ request as *mut _ as PtrUR,
+ seed.as_ptr() as PtrBytes,
+ seed.len() as u32,
+ ));
+ let signature = if result.data.is_null() {
+ None
+ } else {
+ let (_, cbor) = ur::decode(&recover_c_char(result.data).to_lowercase()).unwrap();
+ Some(SolSignature::try_from(cbor).unwrap().get_signature())
+ };
+ result.free();
+ signature
+ }
+
+ #[test]
+ fn custom_paths_pass_check_review_and_signing_but_wrong_signer_is_rejected() {
+ let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
+ let mut mfp = [0x73, 0xc5, 0xda, 0x0a];
+ for path in [
+ "m/44'/501'/50'",
+ "m/44'/501'/1000'/1'",
+ "m/44'/501'/0'/0'/7'",
+ "m/44'/60'/0'",
+ "m/0'",
+ ] {
+ let signer = app_solana::get_public_key(&seed, &path.to_string()).unwrap();
+ let mut raw = alloc::vec![1, 0, 1, 3];
+ raw.extend(signer);
+ raw.extend([9; 32]);
+ raw.extend([0; 32]);
+ raw.extend([7; 32]);
+ raw.extend([1, 2, 2, 0, 1, 12]);
+ raw.extend(2u32.to_le_bytes());
+ raw.extend(1u64.to_le_bytes());
+ let mut request = SolSignRequest::new(
+ None,
+ raw,
+ ur_registry::crypto_key_path::CryptoKeyPath::from_path(path.to_string(), Some(mfp))
+ .unwrap(),
+ None,
+ None,
+ SignType::Transaction,
+ );
+ unsafe {
+ use crate::common::free::Free;
+ let ptr = &mut request as *mut _ as PtrUR;
+ let check = alloc::boxed::Box::from_raw(solana_check(ptr, mfp.as_mut_ptr(), 4));
+ assert_eq!(
+ *(&*check as *const TransactionCheckResult as *const u32),
+ 0,
+ "{path}"
+ );
+ check.free();
+ for (public_key, expected) in [(signer, true), ([9; 32], false), ([8; 32], false)] {
+ let key = cstr_core::CString::new(hex::encode(public_key)).unwrap();
+ let checked = solana_check_tx_signer(ptr, key.as_ptr() as PtrString);
+ assert_eq!(*(checked as *const u32) == 0, expected, "{path}");
+ crate::common::structs::free_TransactionCheckResult(checked);
+ }
+ assert_eq!(parse_tx_results(&mut request), 2, "{path}");
+ let expected = build_sign_result(ptr, &seed).unwrap().get_signature();
+ assert_eq!(
+ checked_signature(&mut request, &seed),
+ Some(expected),
+ "{path}"
+ );
+ let transaction = request.get_sign_data();
+ request.set_sign_type(SignType::Message);
+ request.set_sign_data(b"custom path message".to_vec());
+ assert!(build_sign_result(ptr, &seed).is_ok(), "message {path}");
+ request.set_sign_type(SignType::Transaction);
+ request.set_sign_data(transaction);
+ request.set_derivation_path(
+ ur_registry::crypto_key_path::CryptoKeyPath::from_path(
+ "m/44'/501'/99'/2'".to_string(),
+ Some(mfp),
+ )
+ .unwrap(),
+ );
+ assert!(build_sign_result(ptr, &seed).is_err());
+ assert!(checked_signature(&mut request, &seed).is_none());
+ }
+ }
+ }
+
+ #[test]
+ fn squads_no_argument_trailing_bytes_rejected_at_final_signing() {
+ let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
+ let path = "m/44'/501'/0'";
+ let signer = app_solana::get_public_key(&seed, &path.to_string()).unwrap();
+ let program =
+ bitcoin::base58::decode("SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf").unwrap();
+ for discriminator in ["0b225cf89a1b336a", "c208a15799a419ab"] {
+ for suffix in [&[][..], &[0][..], &[1, 2, 3][..]] {
+ let mut data = hex::decode(discriminator).unwrap();
+ data.extend(suffix);
+ let mut raw = alloc::vec![1, 0, 1, 2];
+ raw.extend(&signer);
+ raw.extend(&program);
+ raw.extend([7; 32]);
+ raw.extend([1, 1, 0, data.len() as u8]);
+ raw.extend(data);
+ assert!(app_solana::message::Message::read_exact(&mut raw.clone()).is_ok());
+ let mut request = SolSignRequest::new(
+ None,
+ raw.clone(),
+ ur_registry::crypto_key_path::CryptoKeyPath::from_path(
+ path.to_string(),
+ Some([0x73, 0xc5, 0xda, 0x0a]),
+ )
+ .unwrap(),
+ None,
+ None,
+ SignType::Transaction,
+ );
+ assert_eq!(app_solana::parse(&raw).is_ok(), suffix.is_empty());
+ unsafe {
+ let result = build_sign_result(&mut request as *mut _ as PtrUR, &seed);
+ if suffix.is_empty() {
+ assert!(result.is_ok());
+ } else {
+ assert!(matches!(result, Err(SolanaError::ProgramError(_))));
+ }
+ }
+ }
+ }
+ }
+
+ #[test]
+ fn v1_security_checks_apply_at_final_signing() {
+ let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
+ let dataset: serde_json::Value =
+ serde_json::from_str(include_str!("../../tests/fixtures/solana-security.json"))
+ .unwrap();
+ let mut count = 0;
+ for fixture in dataset["fixtures"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .filter(|f| f["id"].as_str().unwrap().starts_with("v1--"))
+ {
+ count += 1;
+ let mut decoder = ur::Decoder::default();
+ for frame in fixture["ur"].as_array().unwrap() {
+ decoder
+ .receive(&frame.as_str().unwrap().to_lowercase())
+ .unwrap();
+ }
+ let mut request =
+ SolSignRequest::try_from(decoder.message().unwrap().unwrap()).unwrap();
+ let expected = fixture["expected_result"] == "success";
+ unsafe {
+ assert_eq!(
+ build_sign_result(&mut request as *mut _ as PtrUR, &seed).is_ok(),
+ expected,
+ "{}",
+ fixture["id"]
+ );
+ }
+ let mut outcomes = alloc::vec::Vec::new();
+ for hint in [SignType::Transaction, SignType::Message] {
+ request.set_sign_type(hint);
+ let checked = validated_payload(&request).is_ok();
+ let parsed = unsafe { parse_tx_results(&mut request) };
+ let signed =
+ unsafe { build_sign_result(&mut request as *mut _ as PtrUR, &seed).is_ok() };
+ outcomes.push((checked, parsed, signed));
+ }
+ assert_eq!(
+ outcomes[0], outcomes[1],
+ "type hint changed the outcome of {}",
+ fixture["id"]
+ );
+ if fixture["id"] == "v1--transfer" {
+ request.set_sign_type(SignType::Transaction);
+ let mut data = request.get_sign_data();
+ assert_eq!(&data[158..162], &[2, 2, 12, 0]);
+ data[160] = 13;
+ data.push(0);
+ assert!(app_solana::message::Message::read_exact(&mut data.clone()).is_ok());
+ request.set_sign_data(data);
+ assert!(validated_payload(&request).is_err());
+ unsafe {
+ assert!(build_sign_result(&mut request as *mut _ as PtrUR, &seed).is_err());
+ }
+ }
+ }
+ assert_eq!(count, 6);
+ }
+
+ #[test]
+ fn canonical_display_regressions_preserve_order_alt_and_message_length() {
+ use crate::common::free::Free;
+ use app_solana::parser::{overview::SolanaOverview, structs::OverviewAction};
+ let dataset: serde_json::Value =
+ serde_json::from_str(include_str!("../../tests/fixtures/solana-security.json"))
+ .unwrap();
+ for id in ["04", "05", "11", "14", "22"] {
+ let fixture = dataset["fixtures"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .find(|f| f["id"] == alloc::format!("transaction-security--{id}"))
+ .unwrap();
+ let mut decoder = ur::Decoder::default();
+ for frame in fixture["ur"].as_array().unwrap() {
+ decoder
+ .receive(&frame.as_str().unwrap().to_lowercase())
+ .unwrap();
+ }
+ let request = SolSignRequest::try_from(decoder.message().unwrap().unwrap()).unwrap();
+ let data = request.get_sign_data();
+ if id == "14" {
+ assert_eq!(data.len(), 961);
+ let message =
+ app_solana::parse_message(data, &alloc::string::String::new()).unwrap();
+ assert_eq!(message.message_length, 961);
+ assert_eq!(message.raw_message.len(), 1922);
+ continue;
+ }
+ let parsed = app_solana::parse(&data).unwrap();
+ let detail: serde_json::Value = serde_json::from_str(&parsed.detail).unwrap();
+ assert!(parsed.detail.starts_with("{\n") || parsed.detail.starts_with("[\n"));
+ assert_ne!(parsed.detail, serde_json::to_string(&detail).unwrap());
+ if id == "22" {
+ let instructions = detail["instructions"].as_array().unwrap();
+ assert!(instructions.iter().any(|instruction| {
+ let bytes =
+ bitcoin::base58::decode(instruction["data"].as_str().unwrap()).unwrap();
+ bytes
+ .windows(b"SQUADS-DETAILS-END".len())
+ .any(|w| w == b"SQUADS-DETAILS-END")
+ }));
+ continue;
+ }
+ if id == "11" {
+ assert_eq!(
+ detail["address_table_lookups"][0]["account_key"],
+ "7tj9biW3KRJ7EEWmVUGigHiouCTXhV2dzcyvwma7Cyu7"
+ );
+ assert!(detail["address_table_lookups"][0]["writable_indexes"]
+ .as_array()
+ .unwrap()
+ .contains(&serde_json::json!(7)));
+ let SolanaOverview::Transfer(transfer) = &parsed.overview else {
+ panic!("ALT transfer should retain its recognized layout")
+ };
+ assert_eq!(transfer.value, "0.001 SOL");
+ assert!(transfer.to_in_lookup_table);
+ assert_eq!(
+ transfer.to,
+ "Table: 7tj9biW3KRJ7EEWmVUGigHiouCTXhV2dzcyvwma7Cyu7\nIndex: 7"
+ );
+ } else {
+ let expected = if id == "04" {
+ alloc::vec![
+ (1, OverviewAction::Unknown(0)),
+ (2, OverviewAction::Primary)
+ ]
+ } else {
+ alloc::vec![
+ (1, OverviewAction::Primary),
+ (2, OverviewAction::Unknown(0))
+ ]
+ };
+ assert_eq!(parsed.overview_order, expected);
+ let SolanaOverview::Transfer(transfer) = &parsed.overview else {
+ panic!("retain transfer amounts")
+ };
+ assert!(!transfer.value.is_empty());
+ }
+ let display = structs::DisplaySolanaTx::from(parsed);
+ unsafe {
+ let overview = &*display.overview;
+ if id == "11" {
+ assert!(overview.unknown_instructions.is_null());
+ assert!(overview.transfer_to_in_lookup_table);
+ } else {
+ let actions = &*overview.overview_order;
+ assert_eq!(actions.size, 2);
+ assert_eq!((*actions.data).kind, if id == "04" { 2 } else { 0 });
+ assert_eq!((*overview.additional_unknown_programs).size, 1);
+ }
+ display.free();
+ }
+ }
+ }
+
+ #[test]
+ fn canonical_fixtures_check_and_sign() {
+ let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
+ let mut fingerprint = [0x73, 0xc5, 0xda, 0x0a];
+ let dataset: serde_json::Value =
+ serde_json::from_str(include_str!("../../tests/fixtures/solana-security.json"))
+ .unwrap();
+ for fixture in dataset["fixtures"].as_array().unwrap() {
+ if !["01", "02", "07", "08", "13", "14", "23", "24"]
+ .iter()
+ .any(|id| {
+ fixture["id"]
+ .as_str()
+ .unwrap()
+ .ends_with(&alloc::format!("--{id}"))
+ })
+ {
+ continue;
+ }
+ let expected = fixture["expected_result"] == "success";
+ let mut decoder = ur::Decoder::default();
+ for frame in fixture["ur"].as_array().unwrap() {
+ decoder
+ .receive(&frame.as_str().unwrap().to_lowercase())
+ .unwrap();
+ }
+ let mut request =
+ SolSignRequest::try_from(decoder.message().unwrap().unwrap()).unwrap();
+ unsafe {
+ let ptr = &mut request as *mut _ as PtrUR;
+ let checked = solana_check(ptr, fingerprint.as_mut_ptr(), 4);
+ let accepted = *(checked as *const u32) == 0;
+ crate::common::structs::free_TransactionCheckResult(checked);
+ assert_eq!(accepted, expected, "check {}", fixture["id"]);
+ assert_eq!(
+ build_sign_result(ptr, &seed).is_ok(),
+ expected,
+ "sign {}",
+ fixture["id"]
+ );
+ if expected {
+ let mut wrong_fingerprint = fingerprint;
+ wrong_fingerprint[0] ^= 1;
+ let checked = solana_check(ptr, wrong_fingerprint.as_mut_ptr(), 4);
+ let error_code = *(checked as *const u32);
+ crate::common::structs::free_TransactionCheckResult(checked);
+ assert_eq!(
+ error_code,
+ crate::common::errors::ErrorCodes::MasterFingerprintMismatch as u32,
+ "fingerprint mismatch {}",
+ fixture["id"]
+ );
+ let original_path = request.get_derivation_path();
+ for source in [Some(wrong_fingerprint), None] {
+ request.set_derivation_path(
+ ur_registry::crypto_key_path::CryptoKeyPath::new(
+ original_path.get_components(),
+ source,
+ original_path.get_depth(),
+ ),
+ );
+ assert!(matches!(build_sign_result(ptr, &seed),
+ Err(SolanaError::InvalidData(message)) if message == "master fingerprint mismatch"));
+ }
+ request.set_derivation_path(original_path);
+ assert!(build_sign_result(ptr, &seed).is_ok());
+ let checked = solana_check(ptr, core::ptr::null_mut(), 4);
+ assert_eq!(
+ *(checked as *const u32),
+ crate::common::errors::ErrorCodes::InvalidMasterFingerprint as u32
+ );
+ crate::common::structs::free_TransactionCheckResult(checked);
+ let classified = validated_payload(&request).ok();
+ let signed = build_sign_result(ptr, &seed).is_ok();
+ request.set_sign_type(if request.get_sign_type() == SignType::Transaction {
+ SignType::Message
+ } else {
+ SignType::Transaction
+ });
+ assert_eq!(
+ validated_payload(&request).ok(),
+ classified,
+ "type hint changed the classification {}",
+ fixture["id"]
+ );
+ assert_eq!(
+ build_sign_result(ptr, &seed).is_ok(),
+ signed,
+ "type hint changed the signing outcome {}",
+ fixture["id"]
+ );
+ }
+ }
+ }
+ }
+ #[test]
+ fn message_payload_with_transaction_hint_follows_the_payload() {
+ const SIWS_PAYLOAD_HEX: &str = "ff736f6c616e61206f6666636861696e000127026d616769636564656e2e696f2077616e747320796f7520746f207369676e20696e207769746820796f757220536f6c616e61206163636f756e743a0a4841676b31344a704d514c6774367256677637634251464a5746746f3544717869343732755433444b70716b0a0a57656c636f6d6520746f204d61676963204564656e2e205369676e696e6720697320746865206f6e6c79207761792077652063616e207472756c79206b6e6f77207468617420796f752061726520746865206f776e6572206f66207468652077616c6c657420796f752061726520636f6e6e656374696e672e205369676e696e67206973206120736166652c206761732d6c657373207472616e73616374696f6e207468617420646f6573206e6f7420696e20616e79207761792067697665204d61676963204564656e207065726d697373696f6e20746f20706572666f726d20616e79207472616e73616374696f6e73207769746820796f75722077616c6c65742e0a0a5552493a2068747470733a2f2f6d616769636564656e2e696f2f6d61726b6574706c6163652f73636f6f6279647269700a56657273696f6e3a20310a4e6f6e63653a2037326131633866623062393134376165383631363130303632393330383563620a4973737565642041743a20323032362d30382d30335430373a30373a33382e3234335a0a526571756573742049443a2063313331346235622d656365382d346234662d613837392d333839346464613336346534";
+ let seed = hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap();
+ let dataset: serde_json::Value =
+ serde_json::from_str(include_str!("../../tests/fixtures/solana-security.json"))
+ .unwrap();
+ let fixture = dataset["fixtures"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .find(|fixture| fixture["id"] == "transaction-security--01")
+ .expect("transaction fixture");
+ let mut decoder = ur::Decoder::default();
+ for frame in fixture["ur"].as_array().unwrap() {
+ decoder
+ .receive(&frame.as_str().unwrap().to_lowercase())
+ .unwrap();
+ }
+ let mut request = SolSignRequest::try_from(decoder.message().unwrap().unwrap()).unwrap();
+ let payload = hex::decode(SIWS_PAYLOAD_HEX).unwrap();
+ request.set_sign_type(SignType::Transaction);
+ request.set_sign_data(payload.clone());
+ assert_eq!(
+ validated_payload(&request).ok(),
+ Some(app_solana::SolanaPayloadType::Message)
+ );
+ let parsed = parse_message(payload, &alloc::string::String::new()).unwrap();
+ assert!(parsed
+ .utf8_message
+ .contains("magiceden.io wants you to sign in"));
+ unsafe {
+ use crate::common::free::Free;
+ let ptr = &mut request as *mut _ as PtrUR;
+ assert!(build_sign_result(ptr, &seed).is_ok());
+ let pubkey = cstr_core::CString::new("").unwrap();
+ let rendered = solana_parse_message(ptr, pubkey.as_ptr() as PtrString);
+ assert!(!(*(rendered as *const *mut DisplaySolanaMessage)).is_null());
+ let rendered = alloc::boxed::Box::from_raw(rendered);
+ rendered.free();
+ let expected = build_sign_result(ptr, &seed).unwrap().get_signature();
+ assert_eq!(checked_signature(&mut request, &seed), Some(expected));
+ }
+ }
+}
+
unsafe fn build_sign_result(ptr: PtrUR, seed: &[u8]) -> Result<SolSignature, SolanaError> {
let sign_request = extract_ptr_with_type!(ptr, SolSignRequest);
let sign_data = sign_request.get_sign_data();
- let is_complete_transaction = match app_solana::classify_payload(&sign_data) {
+ let is_complete_transaction = match validated_payload(sign_request)? {
app_solana::SolanaPayloadType::Transaction => true,
app_solana::SolanaPayloadType::Message => false,
app_solana::SolanaPayloadType::MalformedTransaction => {
@@ -28,16 +510,29 @@ unsafe fn build_sign_result(ptr: PtrUR, seed: &[u8]) -> Result<SolSignature, Sol
));
}
};
- let mut path =
- sign_request
- .get_derivation_path()
- .get_path()
- .ok_or(SolanaError::InvalidData(
- "invalid derivation path".to_string(),
- ))?;
- if !path.starts_with("m/") {
- path = format!("m/{path}");
+ sign_payload(sign_request, sign_data, is_complete_transaction, seed)
+}
+
+fn sign_payload(
+ sign_request: &SolSignRequest,
+ sign_data: alloc::vec::Vec<u8>,
+ is_complete_transaction: bool,
+ seed: &[u8],
+) -> Result<SolSignature, SolanaError> {
+ let fingerprint = keystore::algorithms::secp256k1::get_master_fingerprint_by_seed(seed)?;
+ if sign_request.get_derivation_path().get_source_fingerprint() != Some(*fingerprint.as_bytes())
+ {
+ return Err(SolanaError::InvalidData(
+ "master fingerprint mismatch".to_string(),
+ ));
}
+ let path = sign_request
+ .get_derivation_path()
+ .get_path()
+ .ok_or(SolanaError::InvalidData(
+ "invalid derivation path".to_string(),
+ ))?;
+ let path = app_solana::validate_derivation_path(&path)?;
if is_complete_transaction {
let signer = app_solana::get_public_key(seed, &path)?;
app_solana::validate_tx_signer(&mut sign_data.clone(), &signer)?;
@@ -65,27 +560,24 @@ pub unsafe extern "C" fn solana_check(
master_fingerprint: PtrBytes,
length: u32,
) -> PtrT<TransactionCheckResult> {
- if length != 4 {
+ if length != 4 || master_fingerprint.is_null() {
return TransactionCheckResult::from(RustCError::InvalidMasterFingerprint).c_ptr();
}
let sol_sign_request = extract_ptr_with_type!(ptr, SolSignRequest);
- // A transaction with bytes appended after the serialized message must be
- // rejected during the scan/check phase. Otherwise it passes the generic
- // fingerprint check and the UI opens the transaction detail page before
- // discovering the malformed payload during parsing/signing.
- if matches!(
- app_solana::classify_payload(&sol_sign_request.get_sign_data()),
- app_solana::SolanaPayloadType::MalformedTransaction
- ) {
- return TransactionCheckResult::from(SolanaError::InvalidData(
- "invalid or unsupported transaction data".to_string(),
- ))
- .c_ptr();
+ if let Err(error) = validated_payload(sol_sign_request) {
+ return TransactionCheckResult::from(error).c_ptr();
+ }
+ let derivation_path: ur_registry::crypto_key_path::CryptoKeyPath =
+ sol_sign_request.get_derivation_path();
+ let path = match derivation_path.get_path() {
+ Some(path) => path,
+ None => return TransactionCheckResult::from(RustCError::InvalidHDPath).c_ptr(),
+ };
+ if app_solana::validate_derivation_path(&path).is_err() {
+ return TransactionCheckResult::from(RustCError::InvalidHDPath).c_ptr();
}
let mfp = extract_array!(master_fingerprint, u8, 4);
if let Ok(mfp) = (mfp.try_into() as Result<[u8; 4], _>) {
- let derivation_path: ur_registry::crypto_key_path::CryptoKeyPath =
- sol_sign_request.get_derivation_path();
if let Some(ur_mfp) = derivation_path.get_source_fingerprint() {
return if mfp == ur_mfp {
TransactionCheckResult::new().c_ptr()
@@ -98,20 +590,51 @@ pub unsafe extern "C" fn solana_check(
TransactionCheckResult::from(RustCError::InvalidMasterFingerprint).c_ptr()
}
+#[no_mangle]
+pub unsafe extern "C" fn solana_check_tx_signer(
+ ptr: PtrUR,
+ pubkey: PtrString,
+) -> PtrT<TransactionCheckResult> {
+ let request = extract_ptr_with_type!(ptr, SolSignRequest);
+ if pubkey.is_null() {
+ return TransactionCheckResult::from(SolanaError::InvalidData(
+ "missing Solana signer public key".to_string(),
+ ))
+ .c_ptr();
+ }
+ let signer: [u8; 32] = match hex::decode(recover_c_char(pubkey))
+ .ok()
+ .and_then(|value| value.try_into().ok())
+ {
+ Some(value) => value,
+ None => {
+ return TransactionCheckResult::from(SolanaError::InvalidData(
+ "invalid Solana signer public key".to_string(),
+ ))
+ .c_ptr()
+ }
+ };
+ match app_solana::validate_tx_signer(&mut request.get_sign_data(), &signer) {
+ Ok(()) => TransactionCheckResult::new().c_ptr(),
+ Err(error) => TransactionCheckResult::from(error).c_ptr(),
+ }
+}
+
#[no_mangle]
pub unsafe extern "C" fn solana_parse_tx(
ptr: PtrUR,
) -> PtrT<TransactionParseResult<DisplaySolanaTx>> {
let solan_sign_reqeust = extract_ptr_with_type!(ptr, SolSignRequest);
let tx_hex = solan_sign_reqeust.get_sign_data();
- if matches!(
- app_solana::classify_payload(&tx_hex),
- app_solana::SolanaPayloadType::MalformedTransaction
- ) {
- return TransactionParseResult::from(SolanaError::InvalidData(
- "invalid or unsupported transaction data".to_string(),
- ))
- .c_ptr();
+ match validated_payload(solan_sign_reqeust) {
+ Ok(app_solana::SolanaPayloadType::Transaction) => {}
+ Ok(_) => {
+ return TransactionParseResult::from(SolanaError::InvalidData(
+ "expected a transaction request".to_string(),
+ ))
+ .c_ptr()
+ }
+ Err(error) => return TransactionParseResult::from(error).c_ptr(),
}
match app_solana::parse(&tx_hex.to_vec()) {
Ok(v) => TransactionParseResult::success(DisplaySolanaTx::from(v).c_ptr()).c_ptr(),
@@ -126,14 +649,15 @@ pub unsafe extern "C" fn solana_parse_tx_with_pubkey(
) -> PtrT<TransactionParseResult<DisplaySolanaTx>> {
let solan_sign_reqeust = extract_ptr_with_type!(ptr, SolSignRequest);
let tx_hex = solan_sign_reqeust.get_sign_data();
- if matches!(
- app_solana::classify_payload(&tx_hex),
- app_solana::SolanaPayloadType::MalformedTransaction
- ) {
- return TransactionParseResult::from(SolanaError::InvalidData(
- "invalid or unsupported transaction data".to_string(),
- ))
- .c_ptr();
+ match validated_payload(solan_sign_reqeust) {
+ Ok(app_solana::SolanaPayloadType::Transaction) => {}
+ Ok(_) => {
+ return TransactionParseResult::from(SolanaError::InvalidData(
+ "expected a transaction request".to_string(),
+ ))
+ .c_ptr()
+ }
+ Err(error) => return TransactionParseResult::from(error).c_ptr(),
}
let pubkey = recover_c_char(pubkey);
let signer: [u8; 32] = match hex::decode(pubkey)
@@ -162,24 +686,48 @@ pub unsafe extern "C" fn solana_sign_tx(
seed_len: u32,
) -> PtrT<UREncodeResult> {
let seed = extract_array!(seed, u8, seed_len as usize);
- build_sign_result(ptr, seed)
- .map(|v| v.try_into())
- .map_or_else(
- |e| UREncodeResult::from(e).c_ptr(),
- |v| {
- v.map_or_else(
- |e| UREncodeResult::from(e).c_ptr(),
- |data| {
- UREncodeResult::encode(
- data,
- SolSignature::get_registry_type().get_type(),
- FRAGMENT_MAX_LENGTH_DEFAULT,
- )
- .c_ptr()
- },
- )
- },
- )
+ encode_signature(build_sign_result(ptr, seed))
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn solana_sign_checked_tx(
+ ptr: PtrUR,
+ seed: PtrBytes,
+ seed_len: u32,
+) -> PtrT<UREncodeResult> {
+ let request = extract_ptr_with_type!(ptr, SolSignRequest);
+ let data = request.get_sign_data();
+ let is_transaction = match app_solana::classify_payload(&data) {
+ app_solana::SolanaPayloadType::Transaction => true,
+ app_solana::SolanaPayloadType::Message => false,
+ app_solana::SolanaPayloadType::MalformedTransaction => {
+ return UREncodeResult::from(SolanaError::InvalidData(
+ "invalid or unsupported transaction data".to_string(),
+ ))
+ .c_ptr();
+ }
+ };
+ let seed = extract_array!(seed, u8, seed_len as usize);
+ encode_signature(sign_payload(request, data, is_transaction, seed))
+}
+
+fn encode_signature(result: Result<SolSignature, SolanaError>) -> PtrT<UREncodeResult> {
+ result.map(|v| v.try_into()).map_or_else(
+ |e| UREncodeResult::from(e).c_ptr(),
+ |v| {
+ v.map_or_else(
+ |e| UREncodeResult::from(e).c_ptr(),
+ |data| {
+ UREncodeResult::encode(
+ data,
+ SolSignature::get_registry_type().get_type(),
+ FRAGMENT_MAX_LENGTH_DEFAULT,
+ )
+ .c_ptr()
+ },
+ )
+ },
+ )
}
#[no_mangle]
@@ -189,15 +737,16 @@ pub unsafe extern "C" fn solana_parse_message(
) -> PtrT<TransactionParseResult<DisplaySolanaMessage>> {
let sol_sign_request = extract_ptr_with_type!(ptr, SolSignRequest);
let pubkey = recover_c_char(pubkey);
- match app_solana::classify_payload(&sol_sign_request.get_sign_data()) {
- app_solana::SolanaPayloadType::Message => {}
- app_solana::SolanaPayloadType::Transaction => {
+ match validated_payload(sol_sign_request) {
+ Err(error) => return TransactionParseResult::from(error).c_ptr(),
+ Ok(app_solana::SolanaPayloadType::Message) => {}
+ Ok(app_solana::SolanaPayloadType::Transaction) => {
return TransactionParseResult::from(RustCError::UnsupportedTransaction(
"Transaction".to_string(),
))
.c_ptr();
}
- app_solana::SolanaPayloadType::MalformedTransaction => {
+ Ok(app_solana::SolanaPayloadType::MalformedTransaction) => {
return TransactionParseResult::from(SolanaError::InvalidData(
"invalid or unsupported transaction data".to_string(),
))
### rust/rust_c/src/solana/structs.rs
@@ -4,7 +4,7 @@ use alloc::vec::Vec;
use core::ptr::null_mut;
use app_solana::parser::overview::{ProgramOverviewGeneral, SolanaOverview};
-use app_solana::parser::structs::{ParsedSolanaTx, SolanaTxDisplayType};
+use app_solana::parser::structs::{OverviewAction, ParsedSolanaTx, SolanaTxDisplayType};
use app_solana::structs::SolanaMessage;
use itertools::Itertools;
@@ -15,11 +15,32 @@ use crate::common::types::{PtrString, PtrT};
use crate::common::utils::convert_c_char;
use crate::{check_and_free_ptr, free_str_ptr, impl_c_ptr, impl_c_ptrs, make_free_method};
+#[repr(C)]
+pub struct DisplaySolanaAdvancedItem {
+ pub title: PtrString,
+ pub value: PtrString,
+}
+
+impl Free for DisplaySolanaAdvancedItem {
+ unsafe fn free(&self) {
+ free_str_ptr!(self.title);
+ free_str_ptr!(self.value);
+ }
+}
+
#[repr(C)]
pub struct DisplaySolanaTx {
pub network: PtrString,
pub overview: PtrT<DisplaySolanaTxOverview>,
pub detail: PtrString,
+ pub advanced: PtrT<VecFFI<DisplaySolanaAdvancedItem>>,
+}
+
+#[repr(C)]
+pub struct DisplaySolanaOverviewAction {
+ pub instruction_index: usize,
+ pub kind: u32,
+ pub index: usize,
}
#[repr(C)]
@@ -217,6 +238,7 @@ impl Free for DisplaySolanaTxOverviewJupiterV6Swap {
#[repr(C)]
pub struct DisplaySolanaTxOverview {
+ pub overview_order: PtrT<VecFFI<DisplaySolanaOverviewAction>>,
// `Transfer`, `Vote`, `General`, `Unknown`
pub display_type: PtrString,
// 'Transfer', 'Vote'
@@ -319,6 +341,7 @@ impl_c_ptrs!(DisplaySolanaTx, DisplaySolanaTxOverview);
impl Default for DisplaySolanaTxOverview {
fn default() -> Self {
Self {
+ overview_order: null_mut(),
display_type: null_mut(),
transfer_value: null_mut(),
main_action: null_mut(),
@@ -344,11 +367,16 @@ impl Free for DisplaySolanaTx {
check_and_free_ptr!(self.overview);
free_str_ptr!(self.network);
free_str_ptr!(self.detail);
+ check_and_free_ptr!(self.advanced);
}
}
impl Free for DisplaySolanaTxOverview {
unsafe fn free(&self) {
+ if !self.overview_order.is_null() {
+ let order = Box::from_raw(self.overview_order);
+ drop(Vec::from_raw_parts(order.data, order.size, order.cap));
+ }
free_str_ptr!(self.display_type);
free_str_ptr!(self.main_action);
free_str_ptr!(self.transfer_value);
@@ -402,6 +430,29 @@ impl Free for DisplaySolanaTxOverview {
impl From<ParsedSolanaTx> for DisplaySolanaTx {
fn from(value: ParsedSolanaTx) -> Self {
let mut overview = DisplaySolanaTxOverview::from(&value);
+ if value.overview_order.len() > 1
+ && !matches!(value.overview, SolanaOverview::Instructions(_))
+ {
+ overview.overview_order = VecFFI::from(
+ value
+ .overview_order
+ .iter()
+ .map(|(instruction_index, action)| {
+ let (kind, index) = match action {
+ OverviewAction::Primary => (0, 0),
+ OverviewAction::General(index) => (1, *index),
+ OverviewAction::Unknown(index) => (2, *index),
+ };
+ DisplaySolanaOverviewAction {
+ instruction_index: *instruction_index,
+ kind,
+ index,
+ }
+ })
+ .collect_vec(),
+ )
+ .c_ptr();
+ }
if !value.additional_overviews.is_empty() {
overview.general = VecFFI::from(
value
@@ -426,6 +477,17 @@ impl From<ParsedSolanaTx> for DisplaySolanaTx {
network: convert_c_char(value.network.to_string()),
overview: overview.c_ptr(),
detail: convert_c_char(value.detail),
+ advanced: VecFFI::from(
+ value
+ .advanced
+ .into_iter()
+ .map(|item| DisplaySolanaAdvancedItem {
+ title: convert_c_char(item.title),
+ value: convert_c_char(item.value),
+ })
+ .collect::<Vec<_>>(),
+ )
+ .c_ptr(),
}
}
}
@@ -675,11 +737,13 @@ pub struct DisplaySolanaMessage {
raw_message: PtrString,
utf8_message: PtrString,
from: PtrString,
+ message_length: usize,
}
impl From<SolanaMessage> for DisplaySolanaMessage {
fn from(message: SolanaMessage) -> Self {
Self {
+ message_length: message.message_length,
raw_message: convert_c_char(message.raw_message),
utf8_message: if message.utf8_message.is_empty() {
null_mut()
### rust/rust_c/src/tron/mod.rs
@@ -6,7 +6,7 @@ use crate::common::structs::{SimpleResponse, TransactionCheckResult, Transaction
use crate::common::types::{PtrBytes, PtrString, PtrT, PtrUR};
use crate::common::ur::{QRCodeType, UREncodeResult};
use crate::common::utils::{convert_c_char, recover_c_char};
-use crate::extract_array;
+use crate::{extract_array, extract_array_mut};
use alloc::boxed::Box;
use alloc::slice;
use alloc::string::{String, ToString};
@@ -16,13 +16,18 @@ use structs::{DisplayTron, TransactionType};
use crate::extract_ptr_with_type;
use alloc::format;
-use keystore::algorithms::secp256k1::derive_public_key;
use structs::DisplayTRONPersonalMessage;
use ur_registry::traits::{RegistryItem, To};
use ur_registry::tron::tron_sign_request::TronSignRequest;
use ur_registry::tron::tron_signature::TronSignature;
+use zeroize::Zeroize;
-const TRON_DEFAULT_PATH: &str = "m/44'/195'/0'/0/0";
+fn request_path(req: &TronSignRequest) -> Option<String> {
+ req.get_derivation_path()
+ .get_path()
+ .map(|path| format!("m/{path}"))
+ .filter(|path| app_tron::validate_derivation_path(path).is_ok())
+}
#[no_mangle]
pub unsafe extern "C" fn tron_check_sign_request(
@@ -52,7 +57,10 @@ pub unsafe extern "C" fn tron_check_sign_request(
let x_pub_recovered = recover_c_char(x_pub);
let xpub_str = x_pub_recovered.as_str();
let sign_data = req.get_sign_data();
- let path = match req.get_derivation_path().get_path() {
+ if let Err(e) = app_tron::validate_sign_data_len(sign_data.len()) {
+ return TransactionCheckResult::from(e).c_ptr();
+ }
+ let path = match request_path(req) {
Some(p) => p,
None => return TransactionCheckResult::from(RustCError::InvalidHDPath).c_ptr(),
};
@@ -65,7 +73,10 @@ pub unsafe extern "C" fn tron_check_sign_request(
Err(e) => TransactionCheckResult::from(e).c_ptr(),
}
}
- TransactionType::PersonalMessage => TransactionCheckResult::new().c_ptr(),
+ TransactionType::PersonalMessage => match try_get_trx_public_key(xpub_str, req) {
+ Ok(_) => TransactionCheckResult::new().c_ptr(),
+ Err(e) => TransactionCheckResult::from(e).c_ptr(),
+ },
}
}
@@ -75,10 +86,10 @@ pub unsafe extern "C" fn tron_parse_sign_request(
) -> *mut TransactionParseResult<DisplayTron> {
let req = extract_ptr_with_type!(ptr, TronSignRequest);
let json_bytes = req.get_sign_data();
- let path = req
- .get_derivation_path()
- .get_path()
- .unwrap_or_else(|| String::from(TRON_DEFAULT_PATH));
+ let path = match request_path(req) {
+ Some(path) => path,
+ None => return TransactionParseResult::from(RustCError::InvalidHDPath).c_ptr(),
+ };
app_tron::parse_tx_request(&json_bytes, &path).map_or_else(
|e| TransactionParseResult::from(e).c_ptr(),
@@ -97,16 +108,37 @@ pub unsafe extern "C" fn tron_sign_request(
seed_len: u32,
fragment_len: usize,
) -> *mut UREncodeResult {
- let req = extract_ptr_with_type!(ptr, TronSignRequest);
- let seed_slice = extract_array!(seed, u8, seed_len as usize);
+ if seed.is_null() || !matches!(seed_len, 16 | 32 | 64) {
+ return UREncodeResult::from(KeystoneError::SignTxFailed(
+ "invalid seed pointer or length; expected 16, 32, or 64 bytes".into(),
+ ))
+ .c_ptr();
+ }
+ let seed_slice = extract_array_mut!(seed, u8, seed_len as usize);
let sign_res = (|| -> Result<Vec<u8>, KeystoneError> {
+ if ptr.is_null() {
+ return Err(KeystoneError::SignTxFailed("null TRON request".into()));
+ }
+ let req = extract_ptr_with_type!(ptr, TronSignRequest);
let sign_data = req.get_sign_data();
+ app_tron::validate_sign_data_len(sign_data.len())
+ .map_err(|e| KeystoneError::SignTxFailed(e.to_string()))?;
let request_id = req.get_request_id();
- let path = req
+ let path = request_path(req).ok_or(KeystoneError::SignTxFailed(
+ "invalid or missing TRON derivation path".to_string(),
+ ))?;
+ let expected = req
.get_derivation_path()
- .get_path()
- .unwrap_or_else(|| String::from(TRON_DEFAULT_PATH));
+ .get_source_fingerprint()
+ .ok_or_else(|| KeystoneError::SignTxFailed("missing TRON source fingerprint".into()))?;
+ let actual = keystore::algorithms::secp256k1::get_master_fingerprint_by_seed(seed_slice)
+ .map_err(|e| KeystoneError::SignTxFailed(e.to_string()))?;
+ if actual != expected.into() {
+ return Err(KeystoneError::SignTxFailed(
+ "TRON fingerprint does not match signing seed".into(),
+ ));
+ }
let signed_tx_hex = match TransactionType::from(req.get_data_type()) {
TransactionType::Transaction => {
@@ -127,6 +159,8 @@ pub unsafe extern "C" fn tron_sign_request(
.map_err(|e| KeystoneError::SignTxFailed(e.to_string()))
})();
+ seed_slice.zeroize();
+
match sign_res {
Ok(data) => UREncodeResult::encode(
data,
@@ -218,34 +252,12 @@ pub unsafe extern "C" fn tron_get_address(
}
}
-fn parse_trx_sub_path(path: String) -> Option<String> {
- let root_paths = ["m/44'/195'/", "44'/195'/", "m/44'/194'/", "44'/194'/"];
-
- root_paths.iter().find_map(|root| {
- path.strip_prefix(root).and_then(|remaining| {
- remaining
- .find('/')
- .map(|index| remaining[index + 1..].to_string())
- })
- })
-}
-
fn try_get_trx_public_key(
- xpub: String,
+ xpub: &str,
trx_sign_request: &TronSignRequest,
) -> Result<bitcoin::secp256k1::PublicKey, RustCError> {
- match trx_sign_request.get_derivation_path().get_path() {
- None => Err(RustCError::InvalidHDPath),
- Some(path) => {
- if let Some(sub_path) = parse_trx_sub_path(path.clone()) {
- derive_public_key(&xpub, &format!("m/{sub_path}")).map_err(|_e| {
- RustCError::UnexpectedError("unable to derive TRX pubkey".to_string())
- })
- } else {
- Err(RustCError::InvalidHDPath)
- }
- }
- }
+ let path = request_path(trx_sign_request).ok_or(RustCError::InvalidHDPath)?;
+ app_tron::get_public_key(&path, xpub).map_err(|e| RustCError::UnexpectedError(e.to_string()))
}
#[no_mangle]
@@ -256,12 +268,15 @@ pub unsafe extern "C" fn tron_parse_personal_message(
let crypto_trx = extract_ptr_with_type!(ptr, TronSignRequest);
let xpub = recover_c_char(xpub);
- let pubkey = try_get_trx_public_key(xpub, crypto_trx).ok();
+ let pubkey = match try_get_trx_public_key(&xpub, crypto_trx) {
+ Ok(pubkey) => pubkey,
+ Err(e) => return TransactionParseResult::from(e).c_ptr(),
+ };
let transaction_type = TransactionType::from(crypto_trx.get_data_type());
match transaction_type {
TransactionType::PersonalMessage => {
- match app_tron::parse_personal_message(&crypto_trx.get_sign_data(), pubkey) {
+ match app_tron::parse_personal_message(&crypto_trx.get_sign_data(), Some(pubkey)) {
Ok(tx) => {
TransactionParseResult::success(DisplayTRONPersonalMessage::from(tx).c_ptr())
.c_ptr()
@@ -275,3 +290,256 @@ pub unsafe extern "C" fn tron_parse_personal_message(
.c_ptr(),
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::common::free::free_ur_encode_result;
+ use crate::common::ur::FRAGMENT_UNLIMITED_LENGTH;
+ use ur_registry::crypto_key_path::CryptoKeyPath;
+ use ur_registry::tron::tron_sign_request::DataType;
+
+ fn request(path: &str, data_type: DataType) -> TronSignRequest {
+ TronSignRequest::new(
+ None,
+ b"Hello TRON".to_vec(),
+ data_type,
+ CryptoKeyPath::from_path(path.to_string(), Some([0x73, 0xc5, 0xda, 0x0a])).unwrap(),
+ None,
+ None,
+ )
+ }
+
+ fn test_seed() -> Vec<u8> {
+ hex::decode("5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4").unwrap()
+ }
+
+ fn signable_request(data_type: DataType, fingerprint: Option<[u8; 4]>) -> TronSignRequest {
+ let mut req = request("m/44'/195'/0'/0/0", data_type.clone());
+ req.set_derivation_path(
+ CryptoKeyPath::from_path("m/44'/195'/0'/0/0".into(), fingerprint).unwrap(),
+ );
+ if data_type == DataType::Transaction {
+ req.set_sign_data(hex::decode(concat!(
+ "0a0200012208020202020202020240d00f5a65080112610a2d",
+ "747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e",
+ "5472616e73666572436f6e747261637412300a1541c8599111f29c1e1e061265b4af93ea1f274ad78a",
+ "121541b6e708a39781c96bd399c7657780ff9fe9f052a8180170e807",
+ )).unwrap());
+ }
+ req
+ }
+
+ fn sign_via_ffi(req: &mut TronSignRequest, seed: &mut [u8]) -> Option<Vec<u8>> {
+ assert!(seed.iter().any(|byte| *byte != 0));
+ let encoded = unsafe {
+ let result = tron_sign_request(
+ req as *mut TronSignRequest as PtrUR,
+ seed.as_mut_ptr(),
+ seed.len() as u32,
+ FRAGMENT_UNLIMITED_LENGTH,
+ );
+ assert!(!result.is_null());
+ let encoded = if (*result).data.is_null() {
+ None
+ } else {
+ Some(recover_c_char((*result).data))
+ };
+ free_ur_encode_result(result);
+ encoded
+ };
+ assert!(
+ seed.iter().all(|byte| *byte == 0),
+ "FFI retained seed bytes"
+ );
+ encoded.map(|encoded| {
+ let (_, cbor) = ur::decode(&encoded.to_lowercase()).unwrap();
+ minicbor::decode::<TronSignature>(&cbor)
+ .unwrap()
+ .get_signature()
+ })
+ }
+
+ #[test]
+ fn final_signing_rejects_null_seed_and_invalid_lengths_without_memory_access() {
+ let mut req = signable_request(DataType::PersonalMessage, Some([0x73, 0xc5, 0xda, 0x0a]));
+ for len in [0, 1, 15, 17, 31, 33, 63, 65, u32::MAX] {
+ let mut storage = [0x42; 66];
+ unsafe {
+ let result = tron_sign_request(
+ &mut req as *mut TronSignRequest as PtrUR,
+ storage.as_mut_ptr().add(1),
+ len,
+ FRAGMENT_UNLIMITED_LENGTH,
+ );
+ assert!((*result).data.is_null());
+ free_ur_encode_result(result);
+ }
+ assert_eq!(
+ storage, [0x42; 66],
+ "invalid length {len} wrote caller memory"
+ );
+ }
+ for len in [0, 16, 32, 64, u32::MAX] {
+ unsafe {
+ let result = tron_sign_request(
+ &mut req as *mut TronSignRequest as PtrUR,
+ core::ptr::null_mut(),
+ len,
+ FRAGMENT_UNLIMITED_LENGTH,
+ );
+ assert!((*result).data.is_null());
+ free_ur_encode_result(result);
+ }
+ }
+ }
+
+ #[test]
+ fn final_signing_accepts_supported_seed_lengths_and_preserves_canaries() {
+ for len in [16, 32, 64] {
+ let mut storage = [0x42; 66];
+ let seed = &mut storage[1..1 + len];
+ let fingerprint =
+ keystore::algorithms::secp256k1::get_master_fingerprint_by_seed(seed).unwrap();
+ let mut req =
+ signable_request(DataType::PersonalMessage, Some(*fingerprint.as_bytes()));
+ assert!(sign_via_ffi(&mut req, seed).is_some());
+ assert_eq!(storage[0], 0x42);
+ assert!(storage[1 + len..].iter().all(|byte| *byte == 0x42));
+ }
+ }
+
+ #[test]
+ fn final_signing_rejects_null_request_and_clears_valid_seed() {
+ let mut seed = test_seed();
+ unsafe {
+ let result = tron_sign_request(
+ core::ptr::null_mut(),
+ seed.as_mut_ptr(),
+ seed.len() as u32,
+ FRAGMENT_UNLIMITED_LENGTH,
+ );
+ assert!((*result).data.is_null());
+ free_ur_encode_result(result);
+ }
+ assert!(seed.iter().all(|byte| *byte == 0));
+ }
+
+ #[test]
+ fn final_signing_rejects_requests_over_16_kib_and_clears_seed() {
+ for data_type in [DataType::Transaction, DataType::PersonalMessage] {
+ let mut req = signable_request(data_type, Some([0x73, 0xc5, 0xda, 0x0a]));
+ req.set_sign_data(alloc::vec![b'a'; app_tron::MAX_SIGN_DATA_LEN + 1]);
+ assert!(sign_via_ffi(&mut req, &mut test_seed()).is_none());
+ }
+ let mut req = signable_request(DataType::PersonalMessage, Some([0x73, 0xc5, 0xda, 0x0a]));
+ req.set_sign_data(alloc::vec![b'a'; app_tron::MAX_SIGN_DATA_LEN]);
+ assert!(sign_via_ffi(&mut req, &mut test_seed()).is_some());
+ }
+
+ #[test]
+ fn final_signing_rejects_missing_or_wrong_fingerprint_and_clears_seed() {
+ for data_type in [DataType::Transaction, DataType::PersonalMessage] {
+ for fingerprint in [None, Some([0xde, 0xad, 0xbe, 0xef])] {
+ let mut req = signable_request(data_type.clone(), fingerprint);
+ assert!(
+ sign_via_ffi(&mut req, &mut test_seed()).is_none(),
+ "accepted {data_type:?} with fingerprint {fingerprint:?}"
+ );
+ }
+ }
+ }
+
+ #[test]
+ fn final_signing_succeeds_with_matching_fingerprint_and_clears_seed() {
+ for data_type in [DataType::Transaction, DataType::PersonalMessage] {
+ let mut seed = test_seed();
+ let fingerprint =
+ keystore::algorithms::secp256k1::get_master_fingerprint_by_seed(&seed).unwrap();
+ let mut req = signable_request(data_type.clone(), Some(*fingerprint.as_bytes()));
+ let path = request_path(&req).unwrap();
+ let expected = match data_type {
+ DataType::Transaction => {
+ app_tron::sign_tx_request(&req.get_sign_data(), &path, &seed)
+ }
+ DataType::PersonalMessage => {
+ app_tron::sign_personal_message(&req.get_sign_data(), &path, &seed)
+ }
+ }
+ .unwrap();
+ assert_eq!(
+ sign_via_ffi(&mut req, &mut seed).unwrap(),
+ hex::decode(expected).unwrap()
+ );
+ }
+ }
+
+ #[test]
+ fn final_signing_clears_seed_on_invalid_paths_and_seed_errors() {
+ for data_type in [DataType::Transaction, DataType::PersonalMessage] {
+ let mut req = signable_request(data_type.clone(), Some([0x73, 0xc5, 0xda, 0x0a]));
+ let mut invalid_seed = [0xff; 16];
+ assert!(sign_via_ffi(&mut req, &mut invalid_seed).is_none());
+ for path in [
+ "m/44'/194'/0'/0/0",
+ "m/44'/195'/0'/0",
+ "m/44'/195'/0'/0/0/0",
+ ] {
+ req.set_derivation_path(
+ CryptoKeyPath::from_path(path.into(), Some([0x73, 0xc5, 0xda, 0x0a])).unwrap(),
+ );
+ assert!(sign_via_ffi(&mut req, &mut test_seed()).is_none());
+ }
+ }
+ }
+
+ #[test]
+ fn final_signing_clears_seed_on_transaction_parse_and_owner_errors() {
+ let mut req = signable_request(DataType::Transaction, Some([0x73, 0xc5, 0xda, 0x0a]));
+ req.set_derivation_path(
+ CryptoKeyPath::from_path("m/44'/195'/0'/0/1".into(), Some([0x73, 0xc5, 0xda, 0x0a]))
+ .unwrap(),
+ );
+ assert!(sign_via_ffi(&mut req, &mut test_seed()).is_none());
+ req.set_sign_data(alloc::vec![0xff]);
+ assert!(sign_via_ffi(&mut req, &mut test_seed()).is_none());
+ }
+
+ #[test]
+ fn requests_reject_wrong_coin_account_and_path_shape() {
+ for path in [
+ "m/44'/194'/0'/0/0",
+ "m/44'/60'/0'/0/0",
+ "m/44'/195'/1'/0/0",
+ "m/44'/195'/0'/1/0",
+ "m/44'/195'/0'/0",
+ "m/44'/195'/0'/0/0/0",
+ "m/44'/195'/0'/0/0'",
+ ] {
+ for data_type in [DataType::Transaction, DataType::PersonalMessage] {
+ let req = request(path, data_type);
+ assert!(request_path(&req).is_none(), "accepted {path}");
+ assert!(matches!(
+ try_get_trx_public_key("unused", &req),
+ Err(RustCError::InvalidHDPath)
+ ));
+ }
+ }
+ assert!(request_path(&TronSignRequest::default()).is_none());
+ }
+
+ #[test]
+ fn personal_message_requires_derivable_public_key() {
+ let xpub = "xpub6D1AabNHCupeiLM65ZR9UStMhJ1vCpyV4XbZdyhMZBiJXALQtmn9p42VTQckoHVn8WNqS7dqnJokZHAHcHGoaQgmv8D45oNUKx6DZMNZBCd";
+ for index in [0, 1, 2147483647] {
+ let path = format!("m/44'/195'/0'/0/{index}");
+ let req = request(&path, DataType::PersonalMessage);
+ assert_eq!(request_path(&req), Some(path.clone()));
+ assert_eq!(
+ try_get_trx_public_key(xpub, &req).unwrap(),
+ app_tron::get_public_key(&path, xpub).unwrap()
+ );
+ assert!(try_get_trx_public_key("invalid_xpub", &req).is_err());
+ }
+ }
+}
### rust/rust_c/src/tron/structs.rs
@@ -37,7 +37,22 @@ pub struct DisplayTronDetail {
token: PtrString,
contract_address: PtrString,
pub memo: PtrString,
+ pub memo_hex: PtrString,
+ pub memo_hash: PtrString,
+ pub fee_limit: PtrString,
+ pub timestamp: PtrString,
pub expiration: PtrString,
+ pub ref_block_num: PtrString,
+ pub ref_block_bytes: PtrString,
+ pub ref_block_hash: PtrString,
+ pub permission_id: PtrString,
+ pub raw_data_hash: PtrString,
+ pub call_value: PtrString,
+ pub call_token_value: PtrString,
+ pub token_id: PtrString,
+ pub call_data: PtrString,
+ pub contract_warning: PtrString,
+
pub raw_value: PtrString,
}
@@ -66,7 +81,22 @@ impl From<DetailTx> for DisplayTronDetail {
token: convert_c_char(value.token),
contract_address: convert_c_char(value.contract_address),
memo: convert_c_char(value.memo),
+ memo_hex: convert_c_char(value.memo_hex),
+ memo_hash: convert_c_char(value.memo_hash),
+ fee_limit: convert_c_char(value.fee_limit),
+ timestamp: convert_c_char(value.timestamp),
expiration: convert_c_char(value.expiration),
+ ref_block_num: convert_c_char(value.ref_block_num),
+ ref_block_bytes: convert_c_char(value.ref_block_bytes),
+ ref_block_hash: convert_c_char(value.ref_block_hash),
+ permission_id: convert_c_char(value.permission_id),
+ raw_data_hash: convert_c_char(value.raw_data_hash),
+ call_value: convert_c_char(value.call_value),
+ call_token_value: convert_c_char(value.call_token_value),
+ token_id: convert_c_char(value.token_id),
+ call_data: convert_c_char(value.call_data),
+ contract_warning: convert_c_char(value.contract_warning),
+
raw_value: convert_c_char(value.raw_value),
}
}
@@ -100,7 +130,22 @@ impl Free for DisplayTronDetail {
free_str_ptr!(self.token);
free_str_ptr!(self.contract_address);
free_str_ptr!(self.memo);
+ free_str_ptr!(self.memo_hex);
+ free_str_ptr!(self.memo_hash);
+ free_str_ptr!(self.fee_limit);
+ free_str_ptr!(self.timestamp);
free_str_ptr!(self.expiration);
+ free_str_ptr!(self.ref_block_num);
+ free_str_ptr!(self.ref_block_bytes);
+ free_str_ptr!(self.ref_block_hash);
+ free_str_ptr!(self.permission_id);
+ free_str_ptr!(self.raw_data_hash);
+ free_str_ptr!(self.call_value);
+ free_str_ptr!(self.call_token_value);
+ free_str_ptr!(self.token_id);
+ free_str_ptr!(self.call_data);
+ free_str_ptr!(self.contract_warning);
+
free_str_ptr!(self.raw_value);
}
}
### rust/rust_c/src/wallet/multi_coins_wallet/keeper.rs
@@ -5,14 +5,14 @@ use crate::common::{
};
use crate::extract_array;
use alloc::string::ToString;
-use app_wallets::tonkeeper::{generate_sync_ur, PathInfo};
+use app_wallets::keeper::{generate_sync_ur, PathInfo};
use {
hex,
ur_registry::{crypto_hd_key::CryptoHDKey, error::URError, traits::RegistryItem},
};
#[no_mangle]
-pub unsafe extern "C" fn get_tonkeeper_wallet_ur(
+pub unsafe extern "C" fn get_keeper_wallet_ur(
public_key: PtrString,
wallet_name: PtrString,
### rust/rust_c/src/wallet/multi_coins_wallet/mod.rs
@@ -1,11 +1,11 @@
pub mod arconnect;
pub mod backpack;
pub mod bitget;
+pub mod keeper;
pub mod keplr;
pub mod keystone_connect;
pub mod okx;
pub mod structs;
-pub mod tonkeeper;
mod utils;
pub mod xrp_toolkit;
### rust/rust_c/src/zcash/mod.rs
@@ -1538,3 +1538,53 @@ mod tests {
unsafe { free_zcash_checked_pczt(checked_ptr) };
}
}
+
+#[cfg(feature = "cypherpunk")]
+#[repr(C)]
+pub enum ZcashAddressVerification {
+ ZcashAddressOwned,
+ ZcashAddressNotOwned,
+ ZcashAddressInvalid,
+ ZcashAddressUnsupported,
+ ZcashAddressKeyUnavailable,
+}
+
+#[cfg(feature = "cypherpunk")]
+#[no_mangle]
+pub unsafe extern "C" fn zcash_address_qr_text(data: PtrUR) -> *const c_char {
+ if data.is_null() {
+ return core::ptr::null();
+ }
+ (&*(data as *const cstr_core::CString)).as_ptr()
+}
+
+#[cfg(feature = "cypherpunk")]
+#[no_mangle]
+pub unsafe extern "C" fn verify_zcash_address(
+ ufvk: PtrString,
+ address: PtrString,
+) -> ZcashAddressVerification {
+ use app_zcash::address_verification::VerificationResult;
+ use ZcashAddressVerification::*;
+ if ufvk.is_null() {
+ return ZcashAddressKeyUnavailable;
+ }
+ if address.is_null() {
+ return ZcashAddressInvalid;
+ }
+ let (key_ok, key) = crate::common::utils::check_recover_c_char_lossy(ufvk);
+ let (address_ok, text) = crate::common::utils::check_recover_c_char_lossy(address);
+ if !key_ok {
+ return ZcashAddressKeyUnavailable;
+ }
+ if !address_ok {
+ return ZcashAddressInvalid;
+ }
+ match app_zcash::address_verification::verify(&MainNetwork, &key, &text) {
+ VerificationResult::Owned => ZcashAddressOwned,
+ VerificationResult::NotOwned => ZcashAddressNotOwned,
+ VerificationResult::InvalidAddress => ZcashAddressInvalid,
+ VerificationResult::UnsupportedReceiver => ZcashAddressUnsupported,
+ VerificationResult::KeyUnavailable => ZcashAddressKeyUnavailable,
+ }
+}
### rust/rust_c/tests/fixtures/solana-security.json
@@ -0,0 +1,170 @@
+{
+ "fixtures": [
+ {
+ "id": "transaction-security--01",
+ "expected_result": "success",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-1/LPADADCSSWCYCESPWSPKHDSWOXADTPDAGDVSPRIOMHENLATEPAASPMSFBDTKFRHEKKAOHDMTADAEADAXWLRPAMDEFPRKMSKNTDCAVDCKSOHSMHAMEOSAJLCLETGLADHPADGEIAKNHSGAMDFLCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTADAOAOAEADBNAOAEAEAEAESGNYFRAEAEAEAEAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAMADIYADTAGD"
+ ]
+ },
+ {
+ "id": "transaction-security--02",
+ "expected_result": "success",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-1/LPADADCSSPCYTPHLYNDPHDSPOXADTPDAGDCSDLZTYKTDCNSGBSLTKGURVSHLRHLAOYAOHDMKLAADAEADAXWLRPAMDEFPRKMSKNTDCAVDCKSOHSMHAMEOSAJLCLETGLADHPADGEIAKNHSGAMDFLCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTADAOAOAEADBNAOAEAEAEAESGNYFRAEAEAEAEAEAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAMADSOLNENHY"
+ ]
+ },
+ {
+ "id": "transaction-security--04",
+ "expected_result": "success",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-1/LPADADCSYLCYLEGAAALFHDYLOXADTPDAGDQZSALSWNQZHHLYVWSGIEVSKIISLOTOMHAOHDSTADAEAOAAWLRPAMDEFPRKMSKNTDCAVDCKSOHSMHAMEOSAJLCLETGLADHPADGEIAKNHSGAMDFLCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTAOAXADAEBTISINIEIEIHJTDPHSIAJYINJLJTAOAOAEADBNAOAEAEAEFZFWBSAEAEAEAEAEAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAMADSRIDTYSE"
+ ]
+ },
+ {
+ "id": "transaction-security--05",
+ "expected_result": "success",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-1/LPADADCSYLCYUYCLMYWKHDYLOXADTPDAGDDRNDYTHDBALDFSREIYCKPABELABKGMBSAOHDSTADAEAOAAWLRPAMDEFPRKMSKNTDCAVDCKSOHSMHAMEOSAJLCLETGLADHPADGEIAKNHSGAMDFLCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTAOAOAOAEADBNAOAEAEAEFZFWBSAEAEAEAEAEAXADAEBTISINIEIEIHJTDPHSIAJYINJLJTAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAMADFNFGLAMK"
+ ]
+ },
+ {
+ "id": "transaction-security--07",
+ "expected_result": "success",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-1/LPADADCSRDCYFRHYJOIMHDRDOXADTPDAGDFMDPIABNATTBOXHGIAPYFPDWKPSPOLHTAOHDLEADAEADAXWLRPAMDEFPRKMSKNTDCAVDCKSOHSMHAMEOSAJLCLETGLADHPADGEIAKNHSGAMDFLCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTADASADAEADADAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAMADKNOEPMMY"
+ ],
+ "note": "host labels a message payload as a transaction; the payload decides"
+ },
+ {
+ "id": "transaction-security--08",
+ "expected_result": "success",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-1/LPADADCSEMCYFYKOPMLTHDEMOXADTPDAGDWZLDJTTDHLVEKNSPDAIEDALGTDMUAYOSAOFDADAEAELSLALALAAEAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAMADKGVDJLTN"
+ ],
+ "note": "host labels a message payload as a transaction; the payload decides"
+ },
+ {
+ "id": "transaction-security--11",
+ "expected_result": "success",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-1/LPADADCSSBCYIOHHRHFNHDSBOXADTPDAGDCEJPDKCAMNJYTDWPNSJTWPTPMTFWEMYKAOHDNDLAADAEADAOWLRPAMDEFPRKMSKNTDCAVDCKSOHSMHAMEOSAJLCLETGLADHPADGEIAKNHSGAMDFLAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTADADAOAEAOBNAOAEAEAEFZFWBSAEAEAEAEAEADIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYIYADATAEAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAMADEMINTNTE"
+ ]
+ },
+ {
+ "id": "transaction-security--13",
+ "expected_result": "success",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-7/LPADATCFATASCYOEMKATWNHKADAOOXADTPDAGDWTNBKOWNFDHNDRPKREJLFGDMKBKOBBHDAOHKAMTPGRIHKKJKJYJLJTIHCXGUJLJZHSJTHSCXJNIHJKJKHSIOIHCXIYINKSJYKPJPIHDMCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEJZVLFLFZ",
+ "UR:SOL-SIGN-REQUEST/2-7/LPAOATCFATASCYOEMKATWNHKADAOFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPTAEEROHN",
+ "UR:SOL-SIGN-REQUEST/3-7/LPAXATCFATASCYOEMKATWNHKADAOFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEDSOLTKWZ",
+ "UR:SOL-SIGN-REQUEST/4-7/LPAAATCFATASCYOEMKATWNHKADAOFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFHMOLRET",
+ "UR:SOL-SIGN-REQUEST/5-7/LPAHATCFATASCYOEMKATWNHKADAOFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFERTAEWFPK",
+ "UR:SOL-SIGN-REQUEST/6-7/LPAMATCFATASCYOEMKATWNHKADAOFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPIDBSJLWT",
+ "UR:SOL-SIGN-REQUEST/7-7/LPATATCFATASCYOEMKATWNHKADAOFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGUFPFGFEDPGDGMFEFGGAHDCXGAGTGDGWGMGHFPGLGHDPGUGAFLGLFEFYDPGUGOFGFGGAHDDPGTGOGUGHDPFWFEDPHFGAGUGAFWGSFEAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAMAOAEAEAEAEAERKTPTAWY"
+ ]
+ },
+ {
+ "id": "transaction-security--14",
+ "expected_result": "success",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-4/LPADAACFAXWZCYUYMKAAMKHDZCOXADTPDAGDJYIYTLKBCYISPYYNBWPFMUGRDEZTECISAOHKAXSEZMZMZMAEKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTADAEAELFAYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYDYGHPMDE",
+ "UR:SOL-SIGN-REQUEST/2-4/LPAOAACFAXWZCYUYMKAAMKHDZCPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYGHSETPDS",
+ "UR:SOL-SIGN-REQUEST/3-4/LPAXAACFAXWZCYUYMKAAMKHDZCPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYRFRTBBRP",
+ "UR:SOL-SIGN-REQUEST/4-4/LPAAAACFAXWZCYUYMKAAMKHDZCPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYPYGUGAFLGLFEFYDPFWGAGLFPGMHKDPGUGOFGFGGAHDAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAMAOAEAEPMFZYLWE"
+ ]
+ },
+ {
+ "id": "transaction-security--23",
+ "expected_result": "rejected",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-1/LPADADCFADATCYWZLGGAWLHKADATOXADTPDAGDCKMUBBFRHSTEASYLGSVYHNPMLDLNCWSOAOHDTSADAEAOAHWLRPAMDEFPRKMSKNTDCAVDCKSOHSMHAMEOSAJLCLETGLADHPADGEIAKNHSGAMDFLEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHSWZSKNWFRNUYPMFTFSIHWFIMPYSOJYEHPARKVESATDYNVTVEKEOLAOAXFEDLHLHSEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYAMUTYNVYTSIHOYMUTASBVYFGTOWMKKPSCEQZLPWEHEHPEMMEFTLKYKLPKBZMAEPTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTADAAAAADAOAXAEBDBNFZFWBSAEAEAEAEAEAMPKAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAMADMKRFMYVY"
+ ]
+ },
+ {
+ "id": "transaction-security--24",
+ "expected_result": "rejected",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-1/LPADADCSZCCYIAJODPQZHDZCOXADTPDAGDAAENKTTLWPKIRLTDBKAOMYGALBTSKBIAAOHDSNADAEAOAHWLRPAMDEFPRKMSKNTDCAVDCKSOHSMHAMEOSAJLCLETGLADHPADGEIAKNHSGAMDFLEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHEHSWZSKNWFRNUYPMFTFSIHWFIMPYSOJYEHPARKVESATDYNVTVEKEOLAOAXFEDLHLHSEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYEYAMUTYNVYTSIHOYMUTASBVYFGTOWMKKPSCEQZLPWEHEHPEMMEFTLKYKLPKBZMAEPTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTADAAAXADAOAEAOADPKAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAMADJOFRNDCE"
+ ]
+ },
+ {
+ "id": "v1--transfer",
+ "expected_result": "success",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-1/LPADADCSZECYNEAYBSFTHDZEONADTPDAGDBEHKLSRSBGDSFXSBHDOSSSWDJTRHGMFGAOHDPFLYADAEADCTAEAEAEATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATADAXWLRPAMDEFPRKMSKNTDCAVDCKSOHSMHAMEOSAJLCLETGLADHPADGEIAKNHSGAMDFLMOSGUOSOMKLUCLSFASCWHEVDMDMTWSBWKGRKAOEHNLIAVYYNVWZSWMVOCHAMUEVYAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAELOBWAEAEAEAEAEAEFZBTAXAEAEAEADAEAEAEADAEAOAOBNAEAEADAOAEAEAEAESGNYFRAEAEAEAEAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAHKSCWGRIHKKJKJYJLJTIHCXGUJLJZHSJTHSCXHFEHCXIYINKSJYKPJPIHJKAMADQDNEIMAE"
+ ]
+ },
+ {
+ "id": "v1--defaults",
+ "expected_result": "success",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-1/LPADADCSWDCYEHCWBNZMHDWDONADTPDAGDDTLKPSHFNEZOWPCMASAHLORKRYNNLNZSAOHDNSLYADAEADAEAEAEAEATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATADAXWLRPAMDEFPRKMSKNTDCAVDCKSOHSMHAMEOSAJLCLETGLADHPADGEIAKNHSGAMDFLMOSGUOSOMKLUCLSFASCWHEVDMDMTWSBWKGRKAOEHNLIAVYYNVWZSWMVOCHAMUEVYAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAOAOBNAEAEADAOAEAEAEAESGNYFRAEAEAEAEAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAHKSCWGRIHKKJKJYJLJTIHCXGUJLJZHSJTHSCXHFEHCXIYINKSJYKPJPIHJKAMADOLVENDJL"
+ ]
+ },
+ {
+ "id": "v1--compute-budget-invalid",
+ "expected_result": "success",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-1/LPADADCFADCNCYCSHHHSRDHKADCNONADTPDAGDVEMWWEMNWETOMSHGLPRLWFBKLOGACFASAOHDTLLYADAEAOCTAEAEAEATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATAOAAWLRPAMDEFPRKMSKNTDCAVDCKSOHSMHAMEOSAJLCLETGLADHPADGEIAKNHSGAMDFLMOSGUOSOMKLUCLSFASCWHEVDMDMTWSBWKGRKAOEHNLIAVYYNVWZSWMVOCHAMUEVYAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAXAMFGJLVWCLCHEYZMWPPMRDJPSRNDVDRFLKVWRKSKYLBGJEDWFXNDFTFZAEAEAELOBWAEAEAEAEAEAEFZBTAXAEAEAEADAEAEAEADAEAXAEADAEAOAOBNAEZMAEADAOAEAEAEAESGNYFRAEAEAEAEAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAHKSCWGRIHKKJKJYJLJTIHCXGUJLJZHSJTHSCXHFEHCXIYINKSJYKPJPIHJKAMADLAKEOXHH"
+ ]
+ },
+ {
+ "id": "v1--size-3922",
+ "expected_result": "success",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-14/LPADBACFBEBSCYVYRHJYFEHKADDSONADTPDAGDSSLNWDLDNDMYAETTWFSKFWGWMECXBEGWAOHKBSRTLYADAEADAEAEAEAEATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATADAOWLRPAMDEFPRKMSKNTDCAVDCKSOHSMHAMEOSAJLCLETGLADHPADGEIAKNHSGAMDFLDILDBDKILFIYJYDPLTAEEEOTGYIYJEAXOTPEOSLGPMPMAOSTMSSWOTIDWSHEGTRNADAEGMBSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWJPJNWLYN",
+ "UR:SOL-SIGN-REQUEST/2-14/LPAOBACFBEBSCYVYRHJYFEHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWPLTPGLES",
+ "UR:SOL-SIGN-REQUEST/3-14/LPAXBACFBEBSCYVYRHJYFEHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWGSTNSBFG",
+ "UR:SOL-SIGN-REQUEST/4-14/LPAABACFBEBSCYVYRHJYFEHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWMYFYHPYA",
+ "UR:SOL-SIGN-REQUEST/5-14/LPAHBACFBEBSCYVYRHJYFEHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWJNFGUELT",
+ "UR:SOL-SIGN-REQUEST/6-14/LPAMBACFBEBSCYVYRHJYFEHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWMHDYHGFL",
+ "UR:SOL-SIGN-REQUEST/7-14/LPATBACFBEBSCYVYRHJYFEHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWJPEYTDET",
+ "UR:SOL-SIGN-REQUEST/8-14/LPAYBACFBEBSCYVYRHJYFEHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWSFKEJOKN",
+ "UR:SOL-SIGN-REQUEST/9-14/LPASBACFBEBSCYVYRHJYFEHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWDMKBYKAH",
+ "UR:SOL-SIGN-REQUEST/10-14/LPBKBACFBEBSCYVYRHJYFEHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWTEAYKESK",
+ "UR:SOL-SIGN-REQUEST/11-14/LPBDBACFBEBSCYVYRHJYFEHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWEHBKYTRD",
+ "UR:SOL-SIGN-REQUEST/12-14/LPBNBACFBEBSCYVYRHJYFEHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWWZMWINAA",
+ "UR:SOL-SIGN-REQUEST/13-14/LPBTBACFBEBSCYVYRHJYFEHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWBEMTWPKG",
+ "UR:SOL-SIGN-REQUEST/14-14/LPBABACFBEBSCYVYRHJYFEHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAHKSCWGRIHKKJKJYJLJTIHCXGUJLJZHSJTHSCXHFEHCXIYINKSJYKPJPIHJKAMADAEAEAEAEAEIMCELSMK"
+ ]
+ },
+ {
+ "id": "v1--size-3923",
+ "expected_result": "rejected",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-14/LPADBACFBEBECYWMZOCNSWHKADDSONADTPDAGDJPFSLAHLKNBYHKWZGRRDCSWTJESPIANSAOHKBSSELYADAEADAEAEAEAEATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATADAOWLRPAMDEFPRKMSKNTDCAVDCKSOHSMHAMEOSAJLCLETGLADHPADGEIAKNHSGAMDFLDILDBDKILFIYJYDPLTAEEEOTGYIYJEAXOTPEOSLGPMPMAOSTMSSWOTIDWSHEGTRNADAEGUBSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWTTSPZOPD",
+ "UR:SOL-SIGN-REQUEST/2-14/LPAOBACFBEBECYWMZOCNSWHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWRDEEVLMT",
+ "UR:SOL-SIGN-REQUEST/3-14/LPAXBACFBEBECYWMZOCNSWHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWHDENIYWL",
+ "UR:SOL-SIGN-REQUEST/4-14/LPAABACFBEBECYWMZOCNSWHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWNDPDYNHG",
+ "UR:SOL-SIGN-REQUEST/5-14/LPAHBACFBEBECYWMZOCNSWHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWKKPKJKDE",
+ "UR:SOL-SIGN-REQUEST/6-14/LPAMBACFBEBECYWMZOCNSWHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWLRUOZSVS",
+ "UR:SOL-SIGN-REQUEST/7-14/LPATBACFBEBECYWMZOCNSWHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWIYUELBMS",
+ "UR:SOL-SIGN-REQUEST/8-14/LPAYBACFBEBECYWMZOCNSWHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWTPMHUTTL",
+ "UR:SOL-SIGN-REQUEST/9-14/LPASBACFBEBECYWMZOCNSWHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFTMOHDPK",
+ "UR:SOL-SIGN-REQUEST/10-14/LPBKBACFBEBECYWMZOCNSWHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWSTVETTIM",
+ "UR:SOL-SIGN-REQUEST/11-14/LPBDBACFBEBECYWMZOCNSWHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWDAVAGHBZ",
+ "UR:SOL-SIGN-REQUEST/12-14/LPBNBACFBEBECYWMZOCNSWHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWVAKSSSPY",
+ "UR:SOL-SIGN-REQUEST/13-14/LPBTBACFBEBECYWMZOCNSWHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWAAKNFPTY",
+ "UR:SOL-SIGN-REQUEST/14-14/LPBABACFBEBECYWMZOCNSWHKADDSFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWFWAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAHKSCWGRIHKKJKJYJLJTIHCXGUJLJZHSJTHSCXHFEHCXIYINKSJYKPJPIHJKAMADAEAEAEAEBTGAESST"
+ ]
+ },
+ {
+ "id": "v1--signer-mismatch",
+ "expected_result": "rejected",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-1/LPADADCSZECYNTWFFTISHDZEONADTPDAGDVADIJSRDAEAOWZGMNBINCPSFASESIMPTAOHDPFLYADAEADCTAEAEAEATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATADAXFHPYPANLBEMUFSLUISTPRLWZRKHNKNWDVDNDDNGYGRBSYKVLQDNNGAUEKGEYAOZOMOSGUOSOMKLUCLSFASCWHEVDMDMTWSBWKGRKAOEHNLIAVYYNVWZSWMVOCHAMUEVYAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAELOBWAEAEAEAEAEAEFZBTAXAEAEAEADAEAEAEADAEAOAOBNAEAEADAOAEAEAEAESGNYFRAEAEAEAEAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAHKSCWGRIHKKJKJYJLJTIHCXGUJLJZHSJTHSCXHFEHCXIYINKSJYKPJPIHJKAMADDTMHWLKS"
+ ]
+ },
+ {
+ "id": "transaction-security--22",
+ "expected_result": "success",
+ "ur": [
+ "UR:SOL-SIGN-REQUEST/1-4/LPADAACFAAIMCYJEAYTSZMHKADCWOXADTPDAGDHTUTESCMPLESIHTDFLCFBKKNDPEMRSWEAOHKAAESADAEADAOWLRPAMDEFPRKMSKNTDCAVDCKSOHSMHAMEOSAJLCLETGLADHPADGEIAKNHSGAMDFLAMLYSSTOFLVOCNISROPAGOHYSPLTPEASDMZTKBZORPJZOTYKDLRSISTYPSNSRLPDKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTAAADADAETDAMDYZSGLPDTIVOTNTEAEAEHSAOAEAEADAEADAXWLRPAMDEFPRKMSKNTDCAVDCKSOHSMHAMEOSAJLCLETGLADHPADGEIAKNHSGAMDFLCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEAEKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTKTCEAOAOAEADBNVADPDTSF",
+ "UR:SOL-SIGN-REQUEST/2-4/LPAOAACFAAIMCYJEAYTSZMHKADCWAOAEAEAEVSAXAEAEAEAEAEAEAOAOAEADBNAOAEAEAETIATAEAEAEAEAEAEAOAOAEADBNAOAEAEAEROBDAEAEAEAEAEAEAOAOAEADBNAOAEAEAENBBSAEAEAEAEAEAEAOAOAEADBNAOAEAEAELOBWAEAEAEAEAEAEAOAOAEADBNAOAEAEAEJOCHAEAEAEAEAEAEAOAOAEADBNAOAEAEAEHDCWAEAEAEAEAEAEAOAOAEADBNAOAEAEAEFZCTAEAEAEAEAEAEAOAOAEADBNAOAEAEAEDECNAEAEAEAEAEAEAOAOAEADBNAOAEAEAEBEDIAEAEAEAEAEAEAOAOAEADBNAOAEAEAEYADRAEAEAEAEAEAEAOAOAEADBNAOAEAEAEVTDMAEAEAEAEAEAEAOAOAEADBNAOAEAEAESPEYAEAEAEAEAEAEAOAOAEADBNAOAEAEAEPFENAEAEAEAEAEAEAOAOAEADBNAOAEAEAEMKFTAEAEAEAEAEAEAOAOAEADBNAOAEAEAELAFMAEAEAEAEAEAEAOAOAEADBNAOAEAEAEISFWAEAEAEAEAEKEWYWYRK",
+ "UR:SOL-SIGN-REQUEST/3-4/LPAXAACFAAIMCYJEAYTSZMHKADCWAEAOAOAEADBNAOAEAEAEGDFGAEAEAEAEAEAEAOAOAEADBNAOAEAEAEETGEAEAEAEAEAEAEAOAOAEADBNAOAEAEAECXGLAEAEAEAEAEAEAOAOAEADBNAOAEAEAEAYGMAEAEAEAEAEAEAOAOAEADBNAOAEAEAEWTGOAEAEAEAEAEAEAOAOAEADBNAOAEAEAETPHKAEAEAEAEAEAEAOAOAEADBNAOAEAEAERTHLAEAEAEAEAEAEAOAOAEADBNAOAEAEAEPDHSAEAEAEAEAEAEAOAOAEADBNAOAEAEAEMHIHAEAEAEAEAEAEAOAOAEADBNAOAEAEAEKSINAEAEAEAEAEAEAOAOAEADBNAOAEAEAEHNJNAEAEAEAEAEAEADUEAEAEAEGRIHKKJKJYJLJTIHCXGUJSKPHSIEJKCXIEIHJYHSINJZJKCXJKIAJPJLJZJZINJTIOCXJKJYJPIHJKJKCXIYINKSJYKPJPIHDMCXGMIHKOINIHKTCXJYISIHCXIAJLJNJOJZIHJYIHCXKOHSKPJZJYCXJYJPHSJTJKHSIAJYINJLJTCXJNIHBKDLJLCP",
+ "UR:SOL-SIGN-REQUEST/4-4/LPAAAACFAAIMCYJEAYTSZMHKADCWJKJKHSIOIHCXHSJTIECXJEIHIHJOCXJKIAJPJLJZJZINJTIOCXJPIHJKJOJLJTJKINKOIHDMCXGMIHKOINIHKTCXJYISIHCXIAJLJNJOJZIHJYIHCXKOHSKPJZJYCXJYJPHSJTJKHSIAJYINJLJTCXJNIHJKJKHSIOIHCXHSJTIECXJEIHIHJOCXJKIAJPJLJZJZINJTIOCXJPIHJKJOJLJTJKINKOIHDMCXGUGYGOFPFYGUDPFYFEGHFPGAGSGUDPFEGLFYADADAEBYUOFNGAVTCKJZGWNEDRAEAEAEAEAEAEAEAEADADAEAYBDCPHHYANYCWEOIMADADAEHDMHDAOXLORFTPDRYAADGRAEAEAEFPJOJOJPJLKOIHCXJLJTJZKKCXHSIYJYIHJPCXJPIHKOINIHKTINJTIOCXJYISIHCXIAJLJNJOJZIHJYIHCXGUJSKPHSIEJKCXKOHSKPJZJYCXJYJPHSJTJKHSIAJYINJLJTCXIEIHJYHSINJZJKDMAXTAADDYOEADLNCSDWYKCFADYKYKAEYKAOCYJKSKTNBKAMADAEAELETLDKTA"
+ ]
+ }
+ ]
+}
### rust/rust_c/tests/fixtures/solana-squads-overflow.hex
@@ -0,0 +1 @@
+01000205e9b6062841bb977ad21de71ec961900633c26f21384e015b014a637a614995471111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222200000000000000000000000000000000000000000000000000000000000000000681c4ce47e22368b8b1555ec887af092efc7efbb66ca3f52fbf68d4ac9cb7a833333333333333333333333333333333333333333333333333333333333333330104050102000003e4029bec57e4894b512764000000020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020300020100012700000050523131383a20616374696f6e20313030206c6f77657273207468726573686f6c6420746f2031
### rust/sandbox_parser/src/cbor_stream.rs
@@ -0,0 +1,342 @@
+use crate::{ValidationStatus as V, MAX_ITEMS, MAX_NESTING_DEPTH};
+
+const DEFINITE: u32 = 1;
+const ARRAY: u32 = 2;
+const MAP_KEY: u32 = 3;
+const MAP_VALUE: u32 = 4;
+const BYTES: u32 = 5;
+const TEXT: u32 = 6;
+
+#[repr(C)]
+struct Frame {
+ remaining: u32,
+ kind: u32,
+}
+
+#[repr(C, align(8))]
+pub struct State {
+ argument: u64,
+ remaining_bytes: u64,
+ frames: [Frame; MAX_NESTING_DEPTH as usize + 1],
+ height: u32,
+ depth: u32,
+ items: u32,
+ error: u32,
+ head: u32,
+ argument_bytes: u32,
+ chunk_body: u32,
+ done: u32,
+}
+
+pub const STORAGE_BYTES: usize = 512;
+const _: () = assert!(core::mem::size_of::<State>() <= STORAGE_BYTES);
+
+impl State {
+ fn top(&self) -> u32 {
+ self.height
+ .checked_sub(1)
+ .and_then(|i| self.frames.get(i as usize))
+ .map_or(0, |f| f.kind)
+ }
+
+ fn open(&mut self, kind: u32, remaining: u32) -> Result<(), V> {
+ if kind < BYTES && self.depth >= MAX_NESTING_DEPTH {
+ return Err(V::CborNestingLimit);
+ }
+ let frame = self
+ .frames
+ .get_mut(self.height as usize)
+ .ok_or(V::CborNestingLimit)?;
+ frame.kind = kind;
+ frame.remaining = remaining;
+ self.height += 1;
+ if kind < BYTES {
+ self.depth += 1;
+ }
+ if kind == DEFINITE && remaining == 0 {
+ self.close();
+ self.complete()?;
+ } else if kind == DEFINITE && self.items >= MAX_ITEMS {
+ return Err(V::CborItemLimit);
+ }
+ Ok(())
+ }
+
+ fn close(&mut self) {
+ if self.top() < BYTES {
+ self.depth = self.depth.saturating_sub(1);
+ }
+ self.height = self.height.saturating_sub(1);
+ }
+
+ fn complete(&mut self) -> Result<(), V> {
+ loop {
+ if self.height == 0 {
+ self.done = 1;
+ return Ok(());
+ }
+ let frame = self
+ .frames
+ .get_mut((self.height - 1) as usize)
+ .ok_or(V::CborInvalid)?;
+ match frame.kind {
+ DEFINITE => {
+ frame.remaining = frame.remaining.checked_sub(1).ok_or(V::CborInvalid)?;
+ if frame.remaining != 0 {
+ return if self.items >= MAX_ITEMS {
+ Err(V::CborItemLimit)
+ } else {
+ Ok(())
+ };
+ }
+ self.close();
+ }
+ MAP_KEY => {
+ frame.kind = MAP_VALUE;
+ return Ok(());
+ }
+ MAP_VALUE => {
+ frame.kind = MAP_KEY;
+ return Ok(());
+ }
+ ARRAY => return Ok(()),
+ _ => return Err(V::CborInvalid),
+ }
+ }
+ }
+
+ fn dispatch(&mut self) -> Result<(), V> {
+ let major = self.head >> 5;
+ let indefinite = self.head & 31 == 31;
+ if self.top() >= BYTES {
+ if indefinite {
+ return Err(V::CborInvalid);
+ }
+ self.remaining_bytes = self.argument;
+ self.chunk_body = 1;
+ return Ok(());
+ }
+ match major {
+ 0 | 1 | 7 => {
+ if indefinite {
+ return Err(V::CborInvalid);
+ }
+ self.complete()
+ }
+ 2 | 3 => {
+ if indefinite {
+ self.open(if major == 2 { BYTES } else { TEXT }, 0)
+ } else {
+ self.remaining_bytes = self.argument;
+ self.chunk_body = 0;
+ if self.remaining_bytes == 0 {
+ self.complete()?;
+ }
+ Ok(())
+ }
+ }
+ 4 | 5 => {
+ if indefinite {
+ self.open(if major == 4 { ARRAY } else { MAP_KEY }, 0)
+ } else {
+ let count = if major == 5 {
+ self.argument.saturating_mul(2)
+ } else {
+ self.argument
+ };
+ self.open(DEFINITE, count.min(u32::MAX as u64) as u32)
+ }
+ }
+ 6 => {
+ if indefinite {
+ return Err(V::CborInvalid);
+ }
+ self.open(DEFINITE, 1)
+ }
+ _ => Err(V::CborInvalid),
+ }
+ }
+
+ fn byte(&mut self, byte: u8) -> Result<(), V> {
+ if self.done != 0 {
+ return Err(V::CborTrailingData);
+ }
+ if self.remaining_bytes != 0 {
+ self.remaining_bytes -= 1;
+ if self.remaining_bytes == 0 && self.chunk_body == 0 {
+ self.complete()?;
+ }
+ return Ok(());
+ }
+ if self.argument_bytes != 0 {
+ self.argument = (self.argument << 8) | u64::from(byte);
+ self.argument_bytes -= 1;
+ return if self.argument_bytes == 0 {
+ self.dispatch()
+ } else {
+ Ok(())
+ };
+ }
+ let top = self.top();
+ if byte == 0xff {
+ if !matches!(top, ARRAY | MAP_KEY | BYTES | TEXT) {
+ return Err(V::CborInvalid);
+ }
+ self.close();
+ return self.complete();
+ }
+ if top >= BYTES {
+ let expected = if top == BYTES { 2 } else { 3 };
+ if byte >> 5 != expected {
+ return Err(V::CborInvalid);
+ }
+ } else {
+ if self.items >= MAX_ITEMS {
+ return Err(V::CborItemLimit);
+ }
+ self.items += 1;
+ }
+ self.head = u32::from(byte);
+ self.argument = 0;
+ match byte & 31 {
+ n @ 0..=23 => {
+ self.argument = u64::from(n);
+ self.dispatch()
+ }
+ n @ 24..=27 => {
+ self.argument_bytes = 1 << (n - 24);
+ Ok(())
+ }
+ 31 => self.dispatch(),
+ _ => Err(V::CborInvalid),
+ }
+ }
+
+ pub fn push(&mut self, bytes: &[u8]) {
+ for &byte in bytes {
+ if self.error != 0 {
+ break;
+ }
+ if let Err(error) = self.byte(byte) {
+ self.error = error as u32;
+ }
+ }
+ }
+
+ pub fn finish(&self) -> u32 {
+ if self.error != 0 {
+ return self.error;
+ }
+ if self.items == 0 {
+ return V::InvalidInput as u32;
+ }
+ if self.done == 0 {
+ return V::CborUnexpectedEof as u32;
+ }
+ V::Ok as u32
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use std::vec;
+
+ fn state() -> State {
+ unsafe { core::mem::zeroed() }
+ }
+
+ fn check_chunks(input: &[u8], expected: V) {
+ assert_eq!(crate::validate_cbor(input), expected);
+ for size in [1, 2, 7, 228] {
+ let mut parser = state();
+ for chunk in input.chunks(size) {
+ parser.push(chunk);
+ }
+ assert_eq!(parser.finish(), expected as u32, "chunk size {size}");
+ }
+ }
+
+ #[test]
+ fn length_arguments_survive_chunk_boundaries() {
+ for input in [
+ &b"\x58\x01x"[..],
+ &b"\x59\x00\x01x"[..],
+ &b"\x5a\x00\x00\x00\x01x"[..],
+ &b"\x5b\x00\x00\x00\x00\x00\x00\x00\x01x"[..],
+ ] {
+ check_chunks(input, V::Ok);
+ for split in 1..input.len() {
+ let mut parser = state();
+ parser.push(&input[..split]);
+ assert_eq!(parser.finish(), V::CborUnexpectedEof as u32);
+ parser.push(&input[split..]);
+ assert_eq!(parser.finish(), V::Ok as u32);
+ }
+ }
+ }
+
+ #[test]
+ fn large_body_truncation_and_trailing_data() {
+ let mut input = vec![0xa1, 0x01, 0x59, 0x7f, 0xfb];
+ input.resize(32 * 1024, 0xab);
+ check_chunks(&input, V::Ok);
+ input.pop();
+ check_chunks(&input, V::CborUnexpectedEof);
+ input.extend_from_slice(&[0xab, 0x00]);
+ check_chunks(&input, V::CborTrailingData);
+
+ let mut parser = state();
+ parser.push(&input[..input.len() - 1]);
+ assert_eq!(parser.finish(), V::Ok as u32);
+ parser.push(&[0x00]);
+ assert_eq!(parser.finish(), V::CborTrailingData as u32);
+ }
+
+ #[test]
+ fn indefinite_containers_require_complete_values_and_matching_strings() {
+ let valid = b"\xbf\x01\x9f\x5f\x41x\x40\xff\x7f\x61y\x60\xff\xff\xff";
+ check_chunks(valid, V::Ok);
+ check_chunks(&[], V::InvalidInput);
+ for end in 1..valid.len() {
+ check_chunks(&valid[..end], V::CborUnexpectedEof);
+ }
+ for invalid in [
+ &b"\xbf\x01\xff"[..],
+ &b"\xa1\x01\xff"[..],
+ &b"\x5f\x61x\xff"[..],
+ &b"\x7f\x41x\xff"[..],
+ &b"\x5f\x5f\xff\xff"[..],
+ &b"\x81\xff"[..],
+ ] {
+ check_chunks(invalid, V::CborInvalid);
+ }
+ }
+
+ #[test]
+ fn parser_error_is_preserved_across_later_chunks() {
+ let mut parser = state();
+ parser.push(b"\xbf\x01");
+ parser.push(b"\xff");
+ assert_eq!(parser.finish(), V::CborInvalid as u32);
+ parser.push(b"\x00\xff");
+ assert_eq!(parser.finish(), V::CborInvalid as u32);
+ }
+
+ #[test]
+ fn complexity_limits_apply_across_chunks() {
+ for (depth, expected) in [
+ (MAX_NESTING_DEPTH, V::Ok),
+ (MAX_NESTING_DEPTH + 1, V::CborNestingLimit),
+ ] {
+ let mut input = vec![0x81; depth as usize];
+ input.push(0x00);
+ check_chunks(&input, expected);
+ }
+ for (count, expected) in [(MAX_ITEMS - 1, V::Ok), (MAX_ITEMS, V::CborItemLimit)] {
+ let mut input = vec![0x99, (count >> 8) as u8, count as u8];
+ input.resize(input.len() + count as usize, 0x00);
+ check_chunks(&input, expected);
+ }
+ }
+}
### rust/sandbox_parser/src/lib.rs
@@ -1,5 +1,7 @@
#![no_std]
+pub mod cbor_stream;
+
pub const MAX_NESTING_DEPTH: u32 = 32;
pub const MAX_ITEMS: u32 = 1024;
pub const MAX_JSON_NESTING_DEPTH: u32 = 32;
### src/config/legacy_web_update_pad.c
@@ -9,13 +9,13 @@
#ifdef BTC_ONLY
#ifndef LEGACY_USB_PAD_LEN
-#define LEGACY_USB_PAD_LEN 2U
+#define LEGACY_USB_PAD_LEN 1U
#endif
#endif
#ifdef CYPHERPUNK_VERSION
#ifndef LEGACY_USB_PAD_LEN
-#define LEGACY_USB_PAD_LEN 2U
+#define LEGACY_USB_PAD_LEN 3U
#endif
#endif
### src/config/version.c
@@ -93,7 +93,7 @@ bool NeedUpdateBoot(void)
if (GetBootSoftwareVersion(&major, &minor, &build) == false) {
return true;
}
- if (major == 0 && minor == 4 && build == 0) {
+ if (major == 0 && minor == 4 && build == 1) {
return false;
}
return true;
### src/config/version.h
@@ -7,7 +7,7 @@
#define SOFTWARE_VERSION_MAJOR 13
#define SOFTWARE_VERSION_MAJOR_OFFSET 10
#define SOFTWARE_VERSION_MINOR 1
-#define SOFTWARE_VERSION_BUILD 2
+#define SOFTWARE_VERSION_BUILD 4
#define SOFTWARE_VERSION_BETA 0
#define SOFTWARE_VERSION (SOFTWARE_VERSION_MAJOR * 10000 + SOFTWARE_VERSION_MINOR * 100 + SOFTWARE_VERSION_BUILD)
#ifdef WEB3_VERSION
### src/crypto/account_public_info.c
@@ -11,6 +11,7 @@
#include "account_public_info.h"
#include "account_manager.h"
#include "se_manager.h"
+#include "se_interface.h"
#include "user_utils.h"
#include "librust_c.h"
#include "assert.h"
@@ -862,6 +863,36 @@ int32_t AccountPublicInfoReadFromFlash(uint8_t accountIndex, uint32_t addr)
return ret;
}
+static int32_t VerifySeedMasterFingerprint(const uint8_t *seed, int seedLen)
+{
+ if (GetMnemonicType() == MNEMONIC_TYPE_TON) {
+ return SUCCESS_CODE;
+ }
+ uint8_t expected[4] = {0};
+ uint8_t actual[4] = {0};
+ GetMasterFingerPrint(expected);
+ SimpleResponse_u8 *response = get_master_fingerprint((PtrBytes)seed, (uint32_t)seedLen);
+ bool responseOk = response != NULL && response->error_code == 0 && response->data != NULL;
+ if (responseOk) {
+ memcpy_s(actual, sizeof(actual), response->data, sizeof(actual));
+ }
+ if (response != NULL) {
+ free_simple_response_u8(response);
+ }
+ if (!responseOk || timingsafe_bcmp(actual, expected, sizeof(expected)) != 0) {
+ printf("seed master fingerprint mismatch\r\n");
+#ifdef COMPILE_SIMULATOR
+ printf("simulator: recorded mfp=%02x%02x%02x%02x, seed mfp=%02x%02x%02x%02x, continuing\r\n",
+ expected[0], expected[1], expected[2], expected[3],
+ actual[0], actual[1], actual[2], actual[3]);
+ return SUCCESS_CODE;
+#else
+ return ERR_KEYSTORE_EXTEND_PUBLIC_KEY_NOT_MATCH;
+#endif
+ }
+ return SUCCESS_CODE;
+}
+
int32_t AccountPublicSavePublicInfo(uint8_t accountIndex, const char *password, uint32_t addr)
{
uint8_t entropyLen = 0;
@@ -887,6 +918,8 @@ int32_t AccountPublicSavePublicInfo(uint8_t accountIndex, const char *password,
FreePublicKeyRam();
ret = GetAccountSeed(accountIndex, seed, password);
CHECK_ERRCODE_BREAK("get seed", ret);
+ ret = VerifySeedMasterFingerprint(seed, seedLen);
+ CHECK_ERRCODE_BREAK("verify seed fingerprint", ret);
ret = GetAccountEntropy(accountIndex, entropy, &entropyLen, password);
CHECK_ERRCODE_BREAK("get entropy", ret);
if (isBip39) {
@@ -1033,6 +1066,10 @@ int32_t AccountPublicInfoSwitch(uint8_t accountIndex, const char *password, bool
if (regeneratePubKey) {
ret = AccountPublicSavePublicInfo(accountIndex, password, addr);
+ if (ret != SUCCESS_CODE) {
+ FreePublicKeyRam();
+ return ret;
+ }
}
#ifdef BTC_ONLY
@@ -1318,6 +1355,8 @@ int32_t TempAccountPublicInfo(uint8_t accountIndex, const char *password, bool s
FreePublicKeyRam();
ret = GetAccountSeed(accountIndex, seed, password);
CHECK_ERRCODE_BREAK("get temp account seed", ret);
+ ret = VerifySeedMasterFingerprint(seed, seedLen);
+ CHECK_ERRCODE_BREAK("verify temp account seed fingerprint", ret);
ret = GetAccountEntropy(accountIndex, entropy, &entropyLen, password);
CHECK_ERRCODE_BREAK("get temp account entropy", ret);
@@ -1447,7 +1486,7 @@ int32_t TempAccountPublicInfo(uint8_t accountIndex, const char *password, bool s
return ret;
}
-static int32_t DeleteAccountPublicInfoFlash(uint8_t accountIndex)
+int32_t DeleteAccountPublicInfoFlash(uint8_t accountIndex)
{
if (accountIndex >= 3) {
return ERR_GENERAL_FAIL;
@@ -1567,6 +1606,69 @@ uint8_t SpecifiedXPubExist(const char *value)
return accountIndex;
}
+int32_t FindAccountByXpub(const char *value, uint8_t *accountIndex)
+{
+ if (value == NULL || accountIndex == NULL) {
+ return ERR_GENERAL_FAIL;
+ }
+ *accountIndex = INVALID_ACCOUNT_INDEX;
+ for (uint8_t index = 0; index < 3; index++) {
+ uint8_t iv[32] = {0};
+ int32_t ret = SE_HmacEncryptRead(iv, index * PAGE_NUM_PER_ACCOUNT + PAGE_INDEX_IV);
+ bool exists = CheckEntropy(iv, sizeof(iv));
+ CLEAR_ARRAY(iv);
+ if (ret != SUCCESS_CODE) {
+ return ret;
+ }
+ if (!exists) {
+ continue;
+ }
+
+ uint32_t size = 0;
+ uint32_t addr = SPI_FLASH_ADDR_USER1_DATA + index * SPI_FLASH_ADDR_EACH_SIZE;
+ if (Gd25FlashReadBuffer(addr, (uint8_t *)&size, sizeof(size)) != sizeof(size) ||
+ size == 0 || size > SPI_FLASH_SIZE_USER1_DATA - 4) {
+ return ERR_GENERAL_FAIL;
+ }
+ char *json = SRAM_MALLOC(size + 1);
+ if (json == NULL) {
+ return ERR_GENERAL_FAIL;
+ }
+ cJSON *root = NULL;
+ bool matched = false;
+ ret = ERR_GENERAL_FAIL;
+ if (Gd25FlashReadBuffer(addr + 4, (uint8_t *)json, size) == size) {
+ uint8_t hash[32];
+ sha256((struct sha256 *)hash, json, size);
+ bool valid = VerifyWalletDataHash(index, hash);
+ CLEAR_ARRAY(hash);
+ if (!valid) {
+ SRAM_FREE(json);
+ return ERR_KEYSTORE_EXTEND_PUBLIC_KEY_NOT_MATCH;
+ }
+ json[size] = '\0';
+ root = cJSON_Parse(json);
+ cJSON *key = cJSON_GetObjectItem(root, "key");
+ cJSON *chain = cJSON_GetObjectItem(key, g_chainTable[0].name);
+ cJSON *xpub = cJSON_GetObjectItem(chain, "value");
+ if (cJSON_IsString(xpub) && xpub->valuestring != NULL && xpub->valuestring[0] != '\0') {
+ matched = strcmp(value, xpub->valuestring) == 0;
+ ret = SUCCESS_CODE;
+ }
+ }
+ cJSON_Delete(root);
+ SRAM_FREE(json);
+ if (ret != SUCCESS_CODE) {
+ return ret;
+ }
+ if (matched) {
+ *accountIndex = index;
+ return SUCCESS_CODE;
+ }
+ }
+ return SUCCESS_CODE;
+}
+
/// @brief
/// @param argc Test arg count.
/// @param argv Test arg values.
### src/crypto/account_public_info.h
@@ -290,9 +290,11 @@ int32_t RegenerateZcashUFVKV3(uint8_t accountIndex, const uint8_t *seed, int see
int32_t AccountPublicInfoSwitch(uint8_t accountIndex, const char *password, bool newKey);
int32_t TempAccountPublicInfo(uint8_t accountIndex, const char *password, bool set);
int32_t DeleteAccountPublicInfo(uint8_t accountIndex);
+int32_t DeleteAccountPublicInfoFlash(uint8_t accountIndex);
char *GetCurrentAccountPublicKey(ChainType chain);
char *GetCurrentAccountPath(ChainType chain);
uint8_t SpecifiedXPubExist(const char *xPub);
+int32_t FindAccountByXpub(const char *xPub, uint8_t *accountIndex);
void AccountPublicInfoTest(int argc, char *argv[]);
bool GetFirstReceive(const char* chainName);
void SetFirstReceive(const char* chainName, bool isFirst);
### src/crypto/secret_cache.c
@@ -8,6 +8,9 @@
#include "stdio.h"
#include "account_manager.h"
#include "se_manager.h"
+#ifdef CYPHERPUNK_VERSION
+extern void monero_clear_transaction_state(void);
+#endif
static char *g_passwordCache = NULL;
static char *g_newPasswordCache = NULL;
@@ -240,6 +243,9 @@ uint32_t SecretCacheGetDiceRollsLen(void)
void ClearSecretCache(void)
{
+#ifdef CYPHERPUNK_VERSION
+ monero_clear_transaction_state();
+#endif
uint32_t len;
g_identifier = 0;
g_iteration = 0;
@@ -310,3 +316,67 @@ void ClearSecretCache(void)
// SE-side transient session secrets share the passcode cache's lifetime (gen-2). No-op on gen-1.
SE_ClearSessionSecrets();
}
+
+void WipeSecretCacheOnFatalError(void)
+{
+
+ uint32_t len;
+ g_identifier = 0;
+ g_iteration = 0;
+ g_extendable = false;
+
+ if (g_passwordCache != NULL) {
+ len = strnlen_s(g_passwordCache, PASSWORD_MAX_LEN);
+ memset_s(g_passwordCache, len, 0, len);
+ g_passwordCache = NULL;
+ }
+
+ if (g_passphraseCache != NULL) {
+ len = strnlen_s(g_passphraseCache, PASSPHRASE_MAX_LEN);
+ memset_s(g_passphraseCache, len, 0, len);
+ g_passphraseCache = NULL;
+ }
+
+ if (g_newPasswordCache != NULL) {
+ len = strnlen_s(g_newPasswordCache, PASSWORD_MAX_LEN);
+ memset_s(g_newPasswordCache, len, 0, len);
+ g_newPasswordCache = NULL;
+ }
+
+ if (g_entropyCache != NULL) {
+ memset_s(g_entropyCache, g_entropyLen, 0, g_entropyLen);
+ g_entropyLen = 0;
+ g_entropyCache = NULL;
+ }
+
+ if (g_emsCache != NULL) {
+ memset_s(g_emsCache, g_emsLen, 0, g_emsLen);
+ g_emsLen = 0;
+ g_emsCache = NULL;
+ }
+
+ if (g_mnemonicCache != NULL) {
+ len = strnlen_s(g_mnemonicCache, MNEMONIC_MAX_LEN);
+ memset_s(g_mnemonicCache, len, 0, len);
+ g_mnemonicCache = NULL;
+ }
+
+ if (g_walletName != NULL) {
+ size_t len = strnlen_s(g_walletName, WALLET_NAME_MAX_LEN + 1);
+ memset_s(g_walletName, WALLET_NAME_MAX_LEN + 1, 0, len);
+ g_walletName = NULL;
+ }
+
+ for (int i = 0; i < SLIP39_MAX_MEMBER; i++) {
+ if (g_slip39MnemonicCache[i] != NULL) {
+ len = strnlen_s(g_slip39MnemonicCache[i], MNEMONIC_MAX_LEN);
+ memset_s(g_slip39MnemonicCache[i], len, 0, len);
+ g_slip39MnemonicCache[i] = NULL;
+ }
+ }
+
+ memset_s(g_checksumCache, 32, 0, 32);
+ memset_s(g_diceRollHashCache, 32, 0, 32);
+ g_diceRollsLen = 0;
+
+}
### src/crypto/secret_cache.h
@@ -54,5 +54,6 @@ void SecretCacheSetExtendable(bool flag);
bool SecretCacheGetExtendable(void);
void ClearSecretCache(void);
+void WipeSecretCacheOnFatalError(void);
#endif
### src/crypto/slip39/slip39.c
@@ -928,6 +928,9 @@ int Slip39OneSliceCheck(char *wordsList, uint8_t wordCnt, uint16_t id, uint8_t e
int Slip39CheckFirstWordList(char *wordsList, uint8_t wordCnt, uint8_t *threshold)
{
+ if (wordCnt != 20 && wordCnt != 33) {
+ return SLIP39_INVALID_SECRET_LENGTH;
+ }
uint16_t wordIndexBuf[wordCnt];
Slip39Shared_t shards;
char words[wordCnt][10];
@@ -937,13 +940,16 @@ int Slip39CheckFirstWordList(char *wordsList, uint8_t wordCnt, uint8_t *threshol
wordIndexBuf[i] = slip39_word_for_string(words[i]);
}
- int ret = DecodeMnemonics(wordIndexBuf, wordCnt, &shards);
- if (ret < 0) {
- Slip39Error(ret);
- return ret;
+ int shareLen = DecodeMnemonics(wordIndexBuf, wordCnt, &shards);
+ if (shareLen < 0) {
+ Slip39Error(shareLen);
+ return shareLen;
+ }
+ if (shareLen != (wordCnt == 20 ? 16 : 32)) {
+ return SLIP39_INVALID_SECRET_LENGTH;
}
*threshold = shards.memberThreshold;
- return ret;
+ return SLIP39_OK;
}
void Slip39Error(int errNum)
### src/device_setting.h
@@ -10,8 +10,20 @@
#define MIN_BRIGHT 4
#define MAX_BRIGHT 50
+typedef enum {
+ SETUP_PHASE_WELCOME = 0,
+ SETUP_PHASE_LANGUAGE,
+ SETUP_PHASE_WEB_AUTH,
+ SETUP_PHASE_FIRMWARE_UPDATE,
+ SETUP_PHASE_CREATE_WALLET,
+ SETUP_PHASE_DONE,
+ SETUP_PHASE_WALLET_WRITE_PENDING,
+} SETUP_PHASE_ENUM;
+
void DeviceSettingsInit(void);
+int32_t DeviceSettingsRecoverSetupStep(void);
void SaveDeviceSettings(void);
+int32_t SaveSetupCheckpoint(uint32_t setupStep);
uint32_t GetSetupStep(void);
void SetSetupStep(uint32_t setupStep);
@@ -49,7 +61,7 @@ bool IsNftScreenValid(void);
void SetNftBinValid(bool en);
bool IsUpdateSuccess(void);
-void WipeDevice(void);
+int32_t WipeDevice(void);
void DeviceSettingsTest(int argc, char *argv[]);
bool GetEnableBlindSigning(void);
### src/device_settings.c
@@ -16,6 +16,7 @@
#include "screen_manager.h"
#include "power_manager.h"
#include "account_manager.h"
+#include "account_public_info.h"
#include "se_manager.h"
#include "version.h"
#include "legacy_web_update_pad.h"
@@ -75,7 +76,7 @@ typedef struct {
} DeviceSettings_t;
static int32_t SaveDeviceSettingsAsyncFunc(const void *inData, uint32_t inDataLen);
-static void SaveDeviceSettingsSync(void);
+static int32_t SaveDeviceSettingsSync(void);
static bool GetDeviceSettingsFromJsonString(const char *string);
static char *GetJsonStringFromDeviceSettings(void);
static void AesEncryptBuffer(uint8_t *cipher, uint32_t sz, uint8_t *plain);
@@ -255,6 +256,17 @@ void SaveDeviceSettings(void)
AsyncExecute(SaveDeviceSettingsAsyncFunc, NULL, 0);
}
+int32_t SaveSetupCheckpoint(uint32_t setupStep)
+{
+ uint32_t previous = g_deviceSettings.setupStep;
+ g_deviceSettings.setupStep = setupStep;
+ int32_t ret = SaveDeviceSettingsSync();
+ if (ret != SUCCESS_CODE) {
+ g_deviceSettings.setupStep = previous;
+ }
+ return ret;
+}
+
uint32_t GetSetupStep(void)
{
return g_deviceSettings.setupStep;
@@ -265,6 +277,31 @@ void SetSetupStep(uint32_t setupStep)
g_deviceSettings.setupStep = setupStep;
}
+int32_t DeviceSettingsRecoverSetupStep(void)
+{
+ if (GetSetupStep() != SETUP_PHASE_DONE) {
+ return SUCCESS_CODE;
+ }
+ uint8_t accountNum = 0xFF;
+ int32_t ret = GetExistAccountNum(&accountNum);
+ if (ret != SUCCESS_CODE || accountNum != 0) {
+ return ret;
+ }
+ for (uint8_t index = 0; index < 3; index++) {
+ ret = DeleteAccountPublicInfoFlash(index);
+ if (ret != SUCCESS_CODE) {
+ return ret;
+ }
+ }
+ FpClearManageInfo();
+ SetSetupStep(SETUP_PHASE_WELCOME);
+ ret = SaveDeviceSettingsSync();
+ if (ret != SUCCESS_CODE) {
+ SetSetupStep(SETUP_PHASE_DONE);
+ }
+ return ret;
+}
+
uint32_t GetBright(void)
{
return g_deviceSettings.bright;
@@ -455,7 +492,7 @@ void SetLanguage(uint32_t language)
}
/// @brief Wipe device.
-void WipeDevice(void)
+int32_t WipeDevice(void)
{
// reset all account address index in receive page
{
@@ -470,33 +507,35 @@ void WipeDevice(void)
}
uint32_t wipeFlag = DEVICE_WIPE_FLAG_MAGIC_NUM;
- Gd25FlashWriteBuffer(SPI_FLASH_ADDR_PROTECT_PARAM, (uint8_t *)&wipeFlag, sizeof(wipeFlag));
+ if (Gd25FlashWriteBuffer(SPI_FLASH_ADDR_PROTECT_PARAM, (uint8_t *)&wipeFlag, sizeof(wipeFlag)) != sizeof(wipeFlag)) {
+ return ERR_GENERAL_FAIL;
+ }
SetShowPowerOffPage(false);
FpWipeManageInfo();
- ErasePublicInfo();
- // gen-2: also wipe the SE-side secrets (gen-1 no-op). Best-effort — the blobs are already wiped + flash
- // erased below.
- SE_WipeAll();
- DestroyAccount(0);
- DestroyAccount(1);
- DestroyAccount(2);
- // Clear the external per-account status pages (36/37/38). DestroyAccount above already clears each, but do
- // it explicitly so the in-app wipe sweeps them like the bootloader's full-range wipe does.
- SE_SetAccountStatus(0, ACCOUNT_STATUS_UNKNOWN);
- SE_SetAccountStatus(1, ACCOUNT_STATUS_UNKNOWN);
- SE_SetAccountStatus(2, ACCOUNT_STATUS_UNKNOWN);
+ int32_t ret = ErasePublicInfo();
+ CHECK_ERRCODE_RETURN_INT(ret);
+ ret = SE_WipeAll();
+ CHECK_ERRCODE_RETURN_INT(ret);
+ for (uint8_t index = 0; index < 3; index++) {
+ ret = DestroyAccount(index);
+ CHECK_ERRCODE_RETURN_INT(ret);
+ }
for (uint32_t addr = 0; addr < GD25QXX_FLASH_SIZE; addr += 1024 * 64) {
- Gd25FlashBlockErase(addr);
+ ret = Gd25FlashBlockErase(addr);
+ CHECK_ERRCODE_RETURN_INT(ret);
printf("flash erase address: %#x\n", (unsigned int)addr);
}
+ return SUCCESS_CODE;
}
/// @brief Device settings test.
/// @param argc Test arg count.
/// @param argv Test arg values.
void DeviceSettingsTest(int argc, char *argv[])
{
- if (strcmp(argv[0], "wipe") == 0) {
+ if (argc <= 0 || argv == NULL) {
+ printf("device settings test arg err\n");
+ } else if (strcmp(argv[0], "wipe") == 0) {
printf("start wipe\n");
WipeDevice();
printf("wipe over\n");
@@ -531,23 +570,61 @@ void DeviceSettingsTest(int argc, char *argv[])
static int32_t SaveDeviceSettingsAsyncFunc(const void *inData, uint32_t inDataLen)
{
- SaveDeviceSettingsSync();
- return 0;
+ return SaveDeviceSettingsSync();
}
-static void SaveDeviceSettingsSync(void)
+static int32_t VerifyDeviceSettingsWrite(const char *jsonString, uint32_t size)
+{
+ uint32_t savedSize = 0;
+ uint8_t verifyBuffer[64];
+ int32_t readSize = Gd25FlashReadBuffer(SPI_FLASH_ADDR_NORMAL_PARAM,
+ (uint8_t *)&savedSize, sizeof(savedSize));
+ if (readSize != sizeof(savedSize) || savedSize != size) {
+ return ERR_GD25_BAD_PARAM;
+ }
+
+ uint32_t offset = 0;
+ const uint32_t totalSize = size + 1;
+ while (offset < totalSize) {
+ uint32_t chunkSize = totalSize - offset;
+ if (chunkSize > sizeof(verifyBuffer)) {
+ chunkSize = sizeof(verifyBuffer);
+ }
+ readSize = Gd25FlashReadBuffer(SPI_FLASH_ADDR_NORMAL_PARAM + sizeof(savedSize) + offset,
+ verifyBuffer, chunkSize);
+ if (readSize != chunkSize || memcmp(verifyBuffer, jsonString + offset, chunkSize) != 0) {
+ return ERR_GD25_BAD_PARAM;
+ }
+ offset += chunkSize;
+ }
+ return SUCCESS_CODE;
+}
+static int32_t SaveDeviceSettingsSync(void)
{
char *jsonString;
uint32_t size;
jsonString = GetJsonStringFromDeviceSettings();
+ if (jsonString == NULL) {
+ return ERR_GENERAL_FAIL;
+ }
printf("jsonString=%s\n", jsonString);
- Gd25FlashSectorErase(SPI_FLASH_ADDR_NORMAL_PARAM); // Only one sector for device settings.
size = strnlen_s(jsonString, SPI_FLASH_SIZE_NORMAL_PARAM - 4 - 1);
ASSERT(size < SPI_FLASH_SIZE_NORMAL_PARAM - 4);
- Gd25FlashWriteBuffer(SPI_FLASH_ADDR_NORMAL_PARAM, (uint8_t *)&size, 4);
- Gd25FlashWriteBuffer(SPI_FLASH_ADDR_NORMAL_PARAM + 4, (uint8_t *)jsonString, size + 1);
+ int32_t ret = Gd25FlashSectorErase(SPI_FLASH_ADDR_NORMAL_PARAM);
+ if (ret == SUCCESS_CODE &&
+ Gd25FlashWriteBuffer(SPI_FLASH_ADDR_NORMAL_PARAM, (uint8_t *)&size, sizeof(size)) != sizeof(size)) {
+ ret = ERR_GD25_BAD_PARAM;
+ }
+ if (ret == SUCCESS_CODE &&
+ Gd25FlashWriteBuffer(SPI_FLASH_ADDR_NORMAL_PARAM + 4, (uint8_t *)jsonString, size + 1) != size + 1) {
+ ret = ERR_GD25_BAD_PARAM;
+ }
+ if (ret == SUCCESS_CODE) {
+ ret = VerifyDeviceSettingsWrite(jsonString, size);
+ }
EXT_FREE(jsonString);
+ return ret;
}
static bool GetDeviceSettingsFromJsonString(const char *string)
@@ -592,28 +669,36 @@ static bool GetDeviceSettingsFromJsonString(const char *string)
static char *GetJsonStringFromDeviceSettings(void)
{
- cJSON *rootJson;
- char *retStr;
-
- rootJson = cJSON_CreateObject();
- cJSON_AddItemToObject(rootJson, KEY_VERSION, cJSON_CreateString(g_deviceSettingsVersion));
- cJSON_AddItemToObject(rootJson, KEY_SETUP_STEP, cJSON_CreateNumber(g_deviceSettings.setupStep));
- cJSON_AddItemToObject(rootJson, KEY_BRIGHT, cJSON_CreateNumber(g_deviceSettings.bright));
- cJSON_AddItemToObject(rootJson, KEY_AUTO_LOCK_SCREEN, cJSON_CreateNumber(g_deviceSettings.autoLockScreen));
- cJSON_AddItemToObject(rootJson, KEY_AUTO_POWER_OFF, cJSON_CreateNumber(g_deviceSettings.autoPowerOff));
- cJSON_AddItemToObject(rootJson, KEY_VIBRATION, cJSON_CreateNumber(g_deviceSettings.vibration));
- cJSON_AddItemToObject(rootJson, KEY_RANDOM_PIN_PAD, cJSON_CreateNumber(g_deviceSettings.randomPinPad));
- cJSON_AddItemToObject(rootJson, KEY_PERMIT_SIGN, cJSON_CreateNumber(g_deviceSettings.permitSign));
- cJSON_AddItemToObject(rootJson, KEY_DARK_MODE, cJSON_CreateNumber(g_deviceSettings.darkMode));
- cJSON_AddItemToObject(rootJson, KEY_USB_SWITCH, cJSON_CreateNumber(g_deviceSettings.usbSwitch));
- cJSON_AddItemToObject(rootJson, KEY_LAST_VERSION, cJSON_CreateNumber(g_deviceSettings.lastVersion));
- cJSON_AddItemToObject(rootJson, KEY_LANGUAGE, cJSON_CreateNumber(g_deviceSettings.language));
- cJSON_AddItemToObject(rootJson, KEY_NFT_SCREEN, cJSON_CreateBool(g_deviceSettings.nftEnable));
- cJSON_AddItemToObject(rootJson, KEY_NFT_VALID, cJSON_CreateBool(g_deviceSettings.nftValid));
- cJSON_AddItemToObject(rootJson, KEY_ENABLE_BLIND_SIGNING, cJSON_CreateBool(g_deviceSettings.enableBlindSigning));
- retStr = cJSON_PrintBuffered(rootJson, SPI_FLASH_SIZE_NORMAL_PARAM - 4, false);
- RemoveFormatChar(retStr);
+ char *retStr = NULL;
+ cJSON *rootJson = cJSON_CreateObject();
+ if (rootJson == NULL) {
+ return NULL;
+ }
+
+ if (cJSON_AddStringToObject(rootJson, KEY_VERSION, g_deviceSettingsVersion) == NULL ||
+ cJSON_AddNumberToObject(rootJson, KEY_SETUP_STEP, g_deviceSettings.setupStep) == NULL ||
+ cJSON_AddNumberToObject(rootJson, KEY_BRIGHT, g_deviceSettings.bright) == NULL ||
+ cJSON_AddNumberToObject(rootJson, KEY_AUTO_LOCK_SCREEN, g_deviceSettings.autoLockScreen) == NULL ||
+ cJSON_AddNumberToObject(rootJson, KEY_AUTO_POWER_OFF, g_deviceSettings.autoPowerOff) == NULL ||
+ cJSON_AddNumberToObject(rootJson, KEY_VIBRATION, g_deviceSettings.vibration) == NULL ||
+ cJSON_AddNumberToObject(rootJson, KEY_RANDOM_PIN_PAD, g_deviceSettings.randomPinPad) == NULL ||
+ cJSON_AddNumberToObject(rootJson, KEY_PERMIT_SIGN, g_deviceSettings.permitSign) == NULL ||
+ cJSON_AddNumberToObject(rootJson, KEY_DARK_MODE, g_deviceSettings.darkMode) == NULL ||
+ cJSON_AddNumberToObject(rootJson, KEY_USB_SWITCH, g_deviceSettings.usbSwitch) == NULL ||
+ cJSON_AddNumberToObject(rootJson, KEY_LAST_VERSION, g_deviceSettings.lastVersion) == NULL ||
+ cJSON_AddNumberToObject(rootJson, KEY_LANGUAGE, g_deviceSettings.language) == NULL ||
+ cJSON_AddBoolToObject(rootJson, KEY_NFT_SCREEN, g_deviceSettings.nftEnable) == NULL ||
+ cJSON_AddBoolToObject(rootJson, KEY_NFT_VALID, g_deviceSettings.nftValid) == NULL ||
+ cJSON_AddBoolToObject(rootJson, KEY_ENABLE_BLIND_SIGNING, g_deviceSettings.enableBlindSigning) == NULL) {
+ cJSON_Delete(rootJson);
+ return NULL;
+ }
+
+ retStr = cJSON_PrintBuffered(rootJson, SPI_FLASH_SIZE_NORMAL_PARAM - sizeof(uint32_t), false);
cJSON_Delete(rootJson);
+ if (retStr != NULL) {
+ RemoveFormatChar(retStr);
+ }
return retStr;
}
### src/driver/drv_mpu.c
@@ -1,4 +1,5 @@
#include "drv_mpu.h"
+#include "FreeRTOS.h"
extern uint32_t _sbss;
extern uint32_t _ebss;
@@ -122,4 +123,12 @@ void ConfigureMPUForBSS(void)
void MpuInit(void)
{
ConfigureMPUForSramNoExec();
+ MpuSetProtection(MHSCPU_PSRAM_BASE,
+ MHSCPU_PSRAM_END - MHSCPU_PSRAM_BASE + 1UL,
+ portPSRAM_REGION,
+ MPU_INSTRUCTION_ACCESS_DISABLE,
+ MPU_REGION_PRIV_RW,
+ MPU_ACCESS_NOT_SHAREABLE,
+ MPU_ACCESS_CACHEABLE,
+ MPU_ACCESS_NOT_BUFFERABLE);
}
### src/driver/drv_power.c
@@ -1,6 +1,7 @@
#include "drv_power.h"
#include "mhscpu.h"
#include "stdio.h"
+#include "diagnostic_location.h"
#define POWER_CTRL_VCC33_PORT GPIOE
#define POWER_CTRL_VCC33_PIN GPIO_Pin_13
@@ -57,11 +58,11 @@ void PowerTest(int argc, char *argv[])
if (strcmp(argv[0], "vcc33") == 0) {
if (strcmp(argv[1], "open") == 0) {
OpenPower(POWER_TYPE_VCC33);
- line = __LINE__;
+ line = DIAGNOSTIC_LINE;
}
if (strcmp(argv[1], "close") == 0) {
ClosePower(POWER_TYPE_VCC33);
- line = __LINE__;
+ line = DIAGNOSTIC_LINE;
}
}
printf("power test,execute line=%d\r\n", (int)line);
### src/driver/drv_qspi_flash.c
@@ -5,6 +5,7 @@
#include "assert.h"
#include "mh_rand.h"
#include "mhscpu_qspi.h"
+#include "mhscpu_cache.h"
static uint32_t CheckFlashType(void);
@@ -178,4 +179,4 @@ static uint32_t CheckFlashType(void)
}
return chip_type;
}
-#endif
\ No newline at end of file
+#endif
### src/driver/power_on_self_check.c
@@ -22,7 +22,7 @@
LV_FONT_DECLARE(openSans_20);
LV_FONT_DECLARE(openSans_24);
-void PowerOnSelfCheck(void)
+int32_t PowerOnSelfCheck(void)
{
int ret = SUCCESS_CODE;
uint32_t flashId = 0;
@@ -55,16 +55,23 @@ void PowerOnSelfCheck(void)
DrawStringOnLcd(190, 408, "Loading...", 0xFFFF, &openSans_24);
uint32_t c = 0x666666;
DrawStringOnLcd(170, 456, "About 1 minute", (uint16_t)(((c & 0xF80000) >> 16) | ((c & 0xFC00) >> 13) | ((c & 0x1C00) << 3) | ((c & 0xF8) << 5)), &openSans_20);
- FpWipeManageInfo();
- SE_WipeAll();
- DestroyAccount(0);
- DestroyAccount(1);
- DestroyAccount(2);
+ FpClearManageInfo();
+ ret = SE_WipeAll();
+ CHECK_ERRCODE_RETURN_INT(ret);
+ for (uint8_t index = 0; index < 3; index++) {
+ ret = DestroyAccount(index);
+ CHECK_ERRCODE_RETURN_INT(ret);
+ }
+ ret = ErasePublicInfo();
+ CHECK_ERRCODE_RETURN_INT(ret);
for (uint32_t addr = 0; addr < GD25QXX_FLASH_SIZE; addr += 1024 * 64) {
- Gd25FlashBlockErase(addr);
+ ret = Gd25FlashBlockErase(addr);
+ CHECK_ERRCODE_RETURN_INT(ret);
printf("flash erase address: %#x\n", (unsigned int)addr);
}
- ErasePublicInfo();
NVIC_SystemReset();
}
+ ret = DeviceSettingsRecoverSetupStep();
+ ASSERT(ret == SUCCESS_CODE);
+ return ret;
}
### src/driver/power_on_self_check.h
@@ -5,6 +5,6 @@
#include "stdbool.h"
#include "mhscpu.h"
-void PowerOnSelfCheck(void);
+int32_t PowerOnSelfCheck(void);
#endif
### src/error_codes/err_code.h
@@ -4,6 +4,7 @@
#include "stdint.h"
#include "stdbool.h"
#include "stdlib.h"
+#include "diagnostic_location.h"
typedef enum {
SUCCESS_CODE = 0,
@@ -103,11 +104,10 @@ typedef struct {
const char *GetErrorMessage(Error_Code errCode);
-#define CHECK_ERRCODE_BREAK(content, ret) {if (ret != SUCCESS_CODE) {printf("%s err,0x%X,line=%d\r\n", content, (unsigned int)ret, __LINE__); break; }}
-#define CHECK_ERRCODE_RETURN(ret) {if (ret != SUCCESS_CODE) {printf("%s err,%s,line=%d\r\n", __func__, GetErrorMessage(ret), __LINE__); return; }}
-#define CHECK_ERRCODE_RETURN_NULL(ret) {if (ret != SUCCESS_CODE) {printf("%s err,%s,line=%d\r\n", __func__, GetErrorMessage(ret), __LINE__); return NULL; }}
-#define CHECK_ERRCODE_RETURN_INT(ret) {if (ret != SUCCESS_CODE) {printf("%s err,%s,line=%d\r\n", __func__, GetErrorMessage(ret), __LINE__); return ret; }}
-#define PRINT_ERRCODE(ret) {if (ret != SUCCESS_CODE) {printf("%s err,%s,line=%d\r\n", __func__, GetErrorMessage(ret), __LINE__); }}
+#define CHECK_ERRCODE_BREAK(content, ret) {if (ret != SUCCESS_CODE) {printf("%s err,0x%X,line=%d\r\n", content, (unsigned int)ret, DIAGNOSTIC_LINE); break; }}
+#define CHECK_ERRCODE_RETURN(ret) {if (ret != SUCCESS_CODE) {printf("%s err,%s,line=%d\r\n", __func__, GetErrorMessage(ret), DIAGNOSTIC_LINE); return; }}
+#define CHECK_ERRCODE_RETURN_NULL(ret) {if (ret != SUCCESS_CODE) {printf("%s err,%s,line=%d\r\n", __func__, GetErrorMessage(ret), DIAGNOSTIC_LINE); return NULL; }}
+#define CHECK_ERRCODE_RETURN_INT(ret) {if (ret != SUCCESS_CODE) {printf("%s err,%s,line=%d\r\n", __func__, GetErrorMessage(ret), DIAGNOSTIC_LINE); return ret; }}
+#define PRINT_ERRCODE(ret) {if (ret != SUCCESS_CODE) {printf("%s err,%s,line=%d\r\n", __func__, GetErrorMessage(ret), DIAGNOSTIC_LINE); }}
#endif
-
### src/main.c
@@ -82,7 +82,10 @@ int main(void)
DS28S60_Init();
Atecc608bInit();
SeManagerInit(); // resolve SE generation once (after the 608B is up, before any SE-account use)
- AccountsDataCheck();
+ if (AccountsDataCheck() != SUCCESS_CODE) {
+ printf("Account recovery failed; normal startup is blocked.\r\n");
+ while (1);
+ }
MountUsbFatfs();
RtcInit();
MotorInit();
@@ -94,7 +97,10 @@ int main(void)
UserSqlite3Init();
ScreenManagerInit();
AccountManagerInit();
- PowerOnSelfCheck();
+ if (PowerOnSelfCheck() != SUCCESS_CODE) {
+ printf("Device cleanup failed; normal startup is blocked.\r\n");
+ while (1);
+ }
PrintSystemInfo();
osKernelInitialize();
### src/managers/account_manager.c
@@ -35,7 +35,7 @@ static AccountInfo_t g_currentAccountInfo = {0};
static PublicInfo_t g_publicInfo = {0};
#ifndef BTC_ONLY
-static ZcashUFVKCache_t g_zcashUFVKcache = {0};
+static ZcashUFVKCache_t g_zcashUFVKcache = {.accountIndex = ACCOUNT_INDEX_LOGOUT};
static void ClearZcashUFVK();
#endif
@@ -133,15 +133,25 @@ void SetMnemonicType(MnemonicType type)
SaveCurrentAccountInfo();
}
-int32_t CreateNewAccount(uint8_t accountIndex, const uint8_t *entropy, uint8_t entropyLen, const char *password)
+int32_t CreateNewAccount(uint8_t accountIndex, const uint8_t *entropy, uint8_t entropyLen, const char *password, bool *cleanupRequired)
{
ASSERT(accountIndex <= 2);
+ if (cleanupRequired != NULL) {
+ *cleanupRequired = false;
+ }
int32_t ret = DestroyAccount(accountIndex);
CHECK_ERRCODE_RETURN_INT(ret);
+ if (cleanupRequired != NULL) {
+ *cleanupRequired = true;
+ }
CLEAR_OBJECT(g_currentAccountInfo);
g_currentAccountIndex = accountIndex;
- SetWalletName(SecretCacheGetWalletName());
- SetWalletIconIndex(SecretCacheGetWalletIconIndex());
+ ret = SE_SetAccountStatus(accountIndex, ACCOUNT_STATUS_CREATING);
+ CHECK_ERRCODE_RETURN_INT(ret);
+ ret = SetWalletName(SecretCacheGetWalletName());
+ CHECK_ERRCODE_RETURN_INT(ret);
+ ret = SetWalletIconIndex(SecretCacheGetWalletIconIndex());
+ CHECK_ERRCODE_RETURN_INT(ret);
ret = SaveNewBip39Entropy(accountIndex, entropy, entropyLen, password);
CHECK_ERRCODE_RETURN_INT(ret);
@@ -161,16 +171,26 @@ int32_t CreateNewAccount(uint8_t accountIndex, const uint8_t *entropy, uint8_t e
return ret;
}
-int32_t CreateNewSlip39Account(uint8_t accountIndex, const uint8_t *ems, const uint8_t *entropy, uint8_t entropyLen, const char *password, uint16_t id, bool eb, uint8_t ie)
+int32_t CreateNewSlip39Account(uint8_t accountIndex, const uint8_t *ems, const uint8_t *entropy, uint8_t entropyLen, const char *password, uint16_t id, bool eb, uint8_t ie, bool *cleanupRequired)
{
ASSERT(accountIndex <= 2);
+ if (cleanupRequired != NULL) {
+ *cleanupRequired = false;
+ }
int32_t ret = DestroyAccount(accountIndex);
CHECK_ERRCODE_RETURN_INT(ret);
+ if (cleanupRequired != NULL) {
+ *cleanupRequired = true;
+ }
CLEAR_OBJECT(g_currentAccountInfo);
g_currentAccountIndex = accountIndex;
g_currentAccountInfo.isSlip39 = true;
- SetWalletName(SecretCacheGetWalletName());
- SetWalletIconIndex(SecretCacheGetWalletIconIndex());
+ ret = SE_SetAccountStatus(accountIndex, ACCOUNT_STATUS_CREATING);
+ CHECK_ERRCODE_RETURN_INT(ret);
+ ret = SetWalletName(SecretCacheGetWalletName());
+ CHECK_ERRCODE_RETURN_INT(ret);
+ ret = SetWalletIconIndex(SecretCacheGetWalletIconIndex());
+ CHECK_ERRCODE_RETURN_INT(ret);
ret = SaveNewSlip39Entropy(accountIndex, ems, entropy, entropyLen, password, id, ie);
CHECK_ERRCODE_RETURN_INT(ret);
@@ -199,6 +219,7 @@ int32_t VerifyCurrentAccountPassword(const char *password)
{
uint8_t accountIndex;
int32_t ret;
+ uint8_t previousErrorCount = g_publicInfo.currentPasswordErrorCount;
do {
accountIndex = GetCurrentAccountIndex();
@@ -219,22 +240,35 @@ int32_t VerifyCurrentAccountPassword(const char *password)
} else {
break;
}
- SE_HmacEncryptWrite((uint8_t *)&g_publicInfo, PAGE_PUBLIC_INFO);
+ int32_t writeRet = SE_HmacEncryptWrite((uint8_t *)&g_publicInfo, PAGE_PUBLIC_INFO);
+ if (writeRet != SUCCESS_CODE) {
+ g_publicInfo.currentPasswordErrorCount = previousErrorCount;
+ ret = writeRet;
+ }
} while (0);
return ret;
}
-uint8_t RecordCurrentPasswordError(uint8_t maxCount)
+int32_t RecordCurrentPasswordError(uint8_t maxCount, uint8_t *errorCount)
{
+ uint8_t previousErrorCount = g_publicInfo.currentPasswordErrorCount;
+
if (g_publicInfo.currentPasswordErrorCount < maxCount) {
g_publicInfo.currentPasswordErrorCount++;
} else {
g_publicInfo.currentPasswordErrorCount = maxCount;
}
printf("current password error count=%d\r\n", g_publicInfo.currentPasswordErrorCount);
- SE_HmacEncryptWrite((uint8_t *)&g_publicInfo, PAGE_PUBLIC_INFO);
- return g_publicInfo.currentPasswordErrorCount;
+ int32_t ret = SE_HmacEncryptWrite((uint8_t *)&g_publicInfo, PAGE_PUBLIC_INFO);
+ if (ret != SUCCESS_CODE) {
+ g_publicInfo.currentPasswordErrorCount = previousErrorCount;
+ return ret;
+ }
+ if (errorCount != NULL) {
+ *errorCount = g_publicInfo.currentPasswordErrorCount;
+ }
+ return SUCCESS_CODE;
}
/// @brief Verify ownership against any wallet and tick the LOGIN error counter WITHOUT logging in.
@@ -247,6 +281,7 @@ uint8_t RecordCurrentPasswordError(uint8_t maxCount)
/// @return err code.
int32_t VerifyOwnershipPasswordTryAll(uint8_t *accountIndex, const char *password, uint8_t maxCount)
{
+ uint8_t previousErrorCount = g_publicInfo.loginPasswordErrorCount;
int32_t ret = FindAccountByPassword(accountIndex, password);
if (ret == SUCCESS_CODE) {
g_publicInfo.loginPasswordErrorCount = 0;
@@ -261,17 +296,31 @@ int32_t VerifyOwnershipPasswordTryAll(uint8_t *accountIndex, const char *passwor
} else {
return ret; // transient SE error: don't touch the counter
}
- SE_HmacEncryptWrite((uint8_t *)&g_publicInfo, PAGE_PUBLIC_INFO);
+ int32_t writeRet = SE_HmacEncryptWrite((uint8_t *)&g_publicInfo, PAGE_PUBLIC_INFO);
+ if (writeRet != SUCCESS_CODE) {
+ g_publicInfo.loginPasswordErrorCount = previousErrorCount;
+ if (accountIndex != NULL) {
+ *accountIndex = ACCOUNT_INDEX_LOGOUT;
+ }
+ return writeRet;
+ }
return ret;
}
int32_t ClearCurrentPasswordErrorCount(void)
{
+ uint8_t previousLoginErrorCount = g_publicInfo.loginPasswordErrorCount;
+ uint8_t previousCurrentErrorCount = g_publicInfo.currentPasswordErrorCount;
+
printf("clear current password error count\r\n");
g_publicInfo.loginPasswordErrorCount = 0;
g_publicInfo.currentPasswordErrorCount = 0;
- SE_HmacEncryptWrite((uint8_t *)&g_publicInfo, PAGE_PUBLIC_INFO);
- return SUCCESS_CODE;
+ int32_t ret = SE_HmacEncryptWrite((uint8_t *)&g_publicInfo, PAGE_PUBLIC_INFO);
+ if (ret != SUCCESS_CODE) {
+ g_publicInfo.loginPasswordErrorCount = previousLoginErrorCount;
+ g_publicInfo.currentPasswordErrorCount = previousCurrentErrorCount;
+ }
+ return ret;
}
/// @brief Find account by password, if success set current account id. PasswordErrorCount++ if err.
@@ -282,6 +331,10 @@ int32_t VerifyPasswordAndLogin(uint8_t *accountIndex, const char *password)
{
int32_t ret;
uint8_t tempIndex;
+ uint8_t previousLoginErrorCount = g_publicInfo.loginPasswordErrorCount;
+ uint8_t previousCurrentErrorCount = g_publicInfo.currentPasswordErrorCount;
+ bool countersChanged = false;
+ bool countersPersisted = false;
#ifdef CYPHERPUNK_VERSION
uint8_t zcashCacheKey[AES_KEY_LEN];
CLEAR_ARRAY(zcashCacheKey);
@@ -298,8 +351,12 @@ int32_t VerifyPasswordAndLogin(uint8_t *accountIndex, const char *password)
*accountIndex = tempIndex;
}
ret = ReadCurrentAccountInfo();
+ if (ret != SUCCESS_CODE) {
+ goto login_cleanup;
+ }
g_publicInfo.loginPasswordErrorCount = 0;
g_publicInfo.currentPasswordErrorCount = 0;
+ countersChanged = true;
#ifndef BTC_ONLY
ClearZcashUFVK();
#endif
@@ -312,28 +369,49 @@ int32_t VerifyPasswordAndLogin(uint8_t *accountIndex, const char *password)
ret = AccountPublicInfoSwitch(g_currentAccountIndex, password, false);
}
if (ret != SUCCESS_CODE) {
-#ifdef CYPHERPUNK_VERSION
- CLEAR_ARRAY(zcashCacheKey);
-#endif
- return ret;
+ goto login_cleanup;
}
#ifdef CYPHERPUNK_VERSION
ret = SetupZcashCache(tempIndex, password, zcashCacheKey);
CLEAR_ARRAY(zcashCacheKey);
- CHECK_ERRCODE_RETURN_INT(ret);
+ if (ret != SUCCESS_CODE) {
+ goto login_cleanup;
+ }
#endif
#ifdef WEB3_VERSION
ret = SetupZcashSFP(tempIndex, password);
- CHECK_ERRCODE_RETURN_INT(ret);
+ if (ret != SUCCESS_CODE) {
+ goto login_cleanup;
+ }
#endif
- } else {
+ } else if (ret == ERR_KEYSTORE_PASSWORD_ERR) {
g_publicInfo.loginPasswordErrorCount++;
+ countersChanged = true;
+ } else {
+ goto login_cleanup;
}
+ {
+ int32_t writeRet = SE_HmacEncryptWrite((uint8_t *)&g_publicInfo, PAGE_PUBLIC_INFO);
+ if (writeRet != SUCCESS_CODE) {
+ ret = writeRet;
+ } else {
+ countersPersisted = true;
+ }
+ }
+login_cleanup:
#ifdef CYPHERPUNK_VERSION
CLEAR_ARRAY(zcashCacheKey);
#endif
- SE_HmacEncryptWrite((uint8_t *)&g_publicInfo, PAGE_PUBLIC_INFO);
-
+ if (ret != SUCCESS_CODE) {
+ if (countersChanged && !countersPersisted) {
+ g_publicInfo.loginPasswordErrorCount = previousLoginErrorCount;
+ g_publicInfo.currentPasswordErrorCount = previousCurrentErrorCount;
+ }
+ LogoutCurrentAccount();
+ if (accountIndex != NULL) {
+ *accountIndex = ACCOUNT_INDEX_LOGOUT;
+ }
+ }
return ret;
}
@@ -397,6 +475,7 @@ int32_t GetExistAccountNum(uint8_t *accountNum)
void LogoutCurrentAccount(void)
{
g_currentAccountIndex = ACCOUNT_INDEX_LOGOUT;
+
}
/// @brief Get the specific account info.
@@ -490,41 +569,75 @@ char *GetWalletName(void)
return g_currentAccountInfo.walletName;
}
+/// @return err code.
+int32_t SetWalletDesc(const char *walletName, uint8_t iconIndex)
+{
+ if (walletName == NULL || strnlen_s(walletName, WALLET_NAME_MAX_LEN + 1) > WALLET_NAME_MAX_LEN) {
+ return ERR_GENERAL_FAIL;
+ }
+ AccountInfo_t previous = g_currentAccountInfo;
+ memset_s(g_currentAccountInfo.walletName, sizeof(g_currentAccountInfo.walletName), 0,
+ sizeof(g_currentAccountInfo.walletName));
+ strcpy_s(g_currentAccountInfo.walletName, WALLET_NAME_MAX_LEN + 1, walletName);
+ g_currentAccountInfo.iconIndex = iconIndex;
+
+ int32_t ret = SaveCurrentAccountInfo();
+ if (ret != SUCCESS_CODE) {
+ g_currentAccountInfo = previous;
+ }
+ CLEAR_OBJECT(previous);
+ return ret;
+}
+
/// @brief Set passphrase quick access enable for the current account.
/// @param[in] enable Quick access enable.
-void SetPassphraseQuickAccess(bool enable)
+int32_t SetPassphraseQuickAccess(bool enable)
{
+ uint8_t previousQuickAccess = g_currentAccountInfo.passphraseQuickAccess;
+ uint8_t previousMark = g_currentAccountInfo.passphraseMark;
+
g_currentAccountInfo.passphraseQuickAccess = enable ? 1 : 0;
// should only show quick access after restart.
if (PassphraseExist(GetCurrentAccountIndex()) == true) {
- SetPassphraseMark(true);
+ g_currentAccountInfo.passphraseMark = true;
}
- SaveCurrentAccountInfo();
+ int32_t ret = SaveCurrentAccountInfo();
+ if (ret != SUCCESS_CODE) {
+ g_currentAccountInfo.passphraseQuickAccess = previousQuickAccess;
+ g_currentAccountInfo.passphraseMark = previousMark;
+ }
+ return ret;
}
/// @brief Set passphrase mark enable for the current account.
/// @param[in] enable Mark enable.
-void SetPassphraseMark(bool enable)
+int32_t SetPassphraseMark(bool enable)
{
+ uint8_t previousMark = g_currentAccountInfo.passphraseMark;
+
g_currentAccountInfo.passphraseMark = enable ? 1 : 0;
- SaveCurrentAccountInfo();
+ int32_t ret = SaveCurrentAccountInfo();
+ if (ret != SUCCESS_CODE) {
+ g_currentAccountInfo.passphraseMark = previousMark;
+ }
+ return ret;
}
/// @brief Set wallet icon index for the current account.
/// @param[in] iconIndex
-void SetWalletIconIndex(uint8_t iconIndex)
+int32_t SetWalletIconIndex(uint8_t iconIndex)
{
g_currentAccountInfo.iconIndex = iconIndex;
- SaveCurrentAccountInfo();
+ return SaveCurrentAccountInfo();
}
/// @brief Set wallet name for the current account.
/// @param[in] walletName
-void SetWalletName(const char *walletName)
+int32_t SetWalletName(const char *walletName)
{
memset_s(g_currentAccountInfo.walletName, sizeof(g_currentAccountInfo.walletName), 0, sizeof(g_currentAccountInfo.walletName));
strcpy_s(g_currentAccountInfo.walletName, WALLET_NAME_MAX_LEN + 1, walletName);
- SaveCurrentAccountInfo();
+ return SaveCurrentAccountInfo();
}
/// @brief Get password err count for login.
@@ -627,6 +740,9 @@ int32_t DestroyAccount(uint8_t accountIndex)
// Mark the account DELETING (external status page, survives the zero-loop below). If power dies mid-erase,
// the boot check sees DELETING and finishes the deletion. Cleared to UNKNOWN once the data is gone.
printf("destroy account %d\n", accountIndex);
+#ifndef BTC_ONLY
+ ClearZcashUFVK();
+#endif
ret = SE_SetAccountStatus(accountIndex, ACCOUNT_STATUS_DELETING);
if (ret != SUCCESS_CODE) {
printf("destroy account:set deleting status err,0x%X\n", (unsigned int)ret);
@@ -684,21 +800,24 @@ int32_t DestroyAccount(uint8_t accountIndex)
}
// wipe device may power lose, check the account status.
// check whether the account data is valid, if not, erase the account data.
-void AccountsDataCheck(void)
+int32_t AccountsDataCheck(void)
{
- int32_t ret;
+ int32_t ret = SUCCESS_CODE;
uint8_t data[32], accountIndex, validCount;
for (accountIndex = 0; accountIndex < 3; accountIndex++) {
// gen-2 lifecycle status (external page): an account caught mid-create / mid-change-PIN / mid-delete is
// inconsistent -> erase it. delete -> finishes the deletion; change-PIN -> user restores from seed;
// create -> drops the partial wallet. A valid CREATED account skips the coarse heuristic below.
AccountStatus_t status = ACCOUNT_STATUS_UNKNOWN;
- if (SE_GetAccountStatus(accountIndex, &status) == SUCCESS_CODE) {
+ ret = SE_GetAccountStatus(accountIndex, &status);
+ CHECK_ERRCODE_BREAK("read account status", ret);
+ if (ret == SUCCESS_CODE) {
if (status == ACCOUNT_STATUS_CREATING || status == ACCOUNT_STATUS_CHANGING_PIN ||
status == ACCOUNT_STATUS_DELETING) {
printf("incomplete op on account %d (status=%d) -> erase\n", accountIndex, status);
- DestroyAccount(accountIndex);
+ ret = DestroyAccount(accountIndex);
+ CHECK_ERRCODE_BREAK("finish interrupted account operation", ret);
continue;
}
if (status == ACCOUNT_STATUS_CREATED) {
@@ -722,19 +841,25 @@ void AccountsDataCheck(void)
// if start disconsistent with keypieces, consider the account data is illegal, erase the account data.
if (validCount == 1) {
printf("illegal data:%d\n", accountIndex);
- DestroyAccount(accountIndex);
+ ret = DestroyAccount(accountIndex);
+ CHECK_ERRCODE_BREAK("erase inconsistent account", ret);
}
}
CLEAR_ARRAY(data);
+ return ret;
}
#ifndef BTC_ONLY
bool IsZcashSupportedForCurrentMnemonic(void)
{
MnemonicType type = GetMnemonicType();
- if (type == MNEMONIC_TYPE_BIP39) return true;
+ if (type == MNEMONIC_TYPE_BIP39) {
+ return true;
+ }
#ifdef CYPHERPUNK_VERSION
- if (type == MNEMONIC_TYPE_SLIP39) return GetCurrentAccountEntropyLen() >= 32;
+ if (type == MNEMONIC_TYPE_SLIP39) {
+ return GetCurrentAccountEntropyLen() >= 32;
+ }
#endif
return false;
}
@@ -762,6 +887,7 @@ static void SetZcashSFP(uint8_t accountIndex, const uint8_t* seedFingerprint)
static void ClearZcashUFVK()
{
+ g_zcashUFVKcache.accountIndex = ACCOUNT_INDEX_LOGOUT;
memset_s(g_zcashUFVKcache.ufvkCache, sizeof(g_zcashUFVKcache.ufvkCache), '\0', sizeof(g_zcashUFVKcache.ufvkCache));
memset_s(g_zcashUFVKcache.seedFingerprint, sizeof(g_zcashUFVKcache.seedFingerprint),
0, sizeof(g_zcashUFVKcache.seedFingerprint));
@@ -770,27 +896,37 @@ static void ClearZcashUFVK()
int32_t GetZcashUFVK(uint8_t accountIndex, char* outUFVK)
{
ASSERT(accountIndex <= 2);
- if (g_zcashUFVKcache.accountIndex == accountIndex) {
+ if (outUFVK == NULL) {
+ return ERR_GENERAL_FAIL;
+ }
+ if (g_zcashUFVKcache.accountIndex == accountIndex && g_zcashUFVKcache.ufvkCache[0] != '\0') {
strcpy_s(outUFVK, ZCASH_UFVK_BUFFER_SIZE, g_zcashUFVKcache.ufvkCache);
return SUCCESS_CODE;
}
+ outUFVK[0] = '\0';
return ERR_ZCASH_INVALID_ACCOUNT_INDEX;
}
int32_t GetZcashSFP(uint8_t accountIndex, uint8_t* outSFP)
{
ASSERT(accountIndex <= 2);
- if (g_zcashUFVKcache.accountIndex == accountIndex) {
+ if (outSFP == NULL) {
+ return ERR_GENERAL_FAIL;
+ }
+ if (g_zcashUFVKcache.accountIndex == accountIndex &&
+ !CheckAllZero(g_zcashUFVKcache.seedFingerprint, ZCASH_SFP_LEN)) {
memcpy_s(outSFP, ZCASH_SFP_LEN, g_zcashUFVKcache.seedFingerprint, ZCASH_SFP_LEN);
return SUCCESS_CODE;
}
+ memset_s(outSFP, ZCASH_SFP_LEN, 0, ZCASH_SFP_LEN);
return ERR_ZCASH_INVALID_ACCOUNT_INDEX;
}
int32_t SetupZcashSFP(uint8_t accountIndex, const char* password)
{
ASSERT(accountIndex <= 2);
+ ClearZcashUFVK();
if (!IsZcashSupportedForCurrentMnemonic()) {
return SUCCESS_CODE;
}
@@ -826,12 +962,11 @@ int32_t SetupZcashCache(uint8_t accountIndex, const char* password,
{
ASSERT(accountIndex <= 2);
+ ClearZcashUFVK();
if (!IsZcashSupportedForCurrentMnemonic()) {
return SUCCESS_CODE;
}
- ClearZcashUFVK();
-
char *zcashEncrypted = GetCurrentAccountPublicKey(ZCASH_UFVK_ENCRYPTED_0);
if (zcashEncrypted == NULL) {
return ERR_GENERAL_FAIL;
### src/managers/account_manager.h
@@ -62,11 +62,10 @@ MnemonicType GetMnemonicType(void);
void SetPasscodeType(PasscodeType type);
void SetMnemonicType(MnemonicType type);
-int32_t CreateNewAccount(uint8_t accountIndex, const uint8_t *entropy, uint8_t entropyLen, const char *password);
-int32_t CreateNewSlip39Account(uint8_t accountIndex, const uint8_t *ems, const uint8_t *entropy, uint8_t entropyLen, const char *password, uint16_t id, bool eb, uint8_t ie);
-int32_t ClearCurrentPasswordErrorCount(void);
+int32_t CreateNewAccount(uint8_t accountIndex, const uint8_t *entropy, uint8_t entropyLen, const char *password, bool *cleanupRequired);
+int32_t CreateNewSlip39Account(uint8_t accountIndex, const uint8_t *ems, const uint8_t *entropy, uint8_t entropyLen, const char *password, uint16_t id, bool eb, uint8_t ie, bool *cleanupRequired);
int32_t VerifyCurrentAccountPassword(const char *password);
-uint8_t RecordCurrentPasswordError(uint8_t maxCount);
+int32_t RecordCurrentPasswordError(uint8_t maxCount, uint8_t *errorCount);
int32_t VerifyOwnershipPasswordTryAll(uint8_t *accountIndex, const char *password, uint8_t maxCount);
int32_t VerifyPasswordAndLogin(uint8_t *accountIndex, const char *password);
void LogoutCurrentAccount(void);
@@ -79,14 +78,15 @@ int32_t DestroyAccount(uint8_t accountIndex);
int32_t SaveCurrentAccountInfo(void);
void SetCurrentAccountMfp(uint8_t* mfp);
void SetCurrentAccountEntropyLen(uint8_t entropyLen);
-void SetPassphraseQuickAccess(bool exist);
+int32_t SetPassphraseQuickAccess(bool exist);
bool GetPassphraseQuickAccess(void);
bool GetPassphraseMark(void);
uint8_t GetWalletIconIndex(void);
char *GetWalletName(void);
-void SetPassphraseMark(bool enable);
-void SetWalletIconIndex(uint8_t iconIndex);
-void SetWalletName(const char *walletName);
+int32_t SetPassphraseMark(bool enable);
+int32_t SetWalletDesc(const char *walletName, uint8_t iconIndex);
+int32_t SetWalletIconIndex(uint8_t iconIndex);
+int32_t SetWalletName(const char *walletName);
uint8_t GetLoginPasswordErrorCount(void);
uint8_t GetCurrentPasswordErrorCount(void);
uint32_t GetLastLockDeviceTime(void);
@@ -105,7 +105,7 @@ uint16_t GetSlip39Id(void);
uint8_t GetSlip39Ie(void);
uint8_t GetSlip39Eb(void);
-void AccountsDataCheck(void);
+int32_t AccountsDataCheck(void);
#ifndef BTC_ONLY
bool IsZcashSupportedForCurrentMnemonic(void);
### src/managers/fingerprint_process.c
@@ -1214,10 +1214,15 @@ void __inline FingerprintIsrRecvProcess(uint8_t byte)
}
}
-void FpWipeManageInfo(void)
+void FpClearManageInfo(void)
{
memset_s(&g_fpManager, sizeof(g_fpManager), 0, sizeof(g_fpManager));
SetFingerManagerInfoToSE();
+}
+
+void FpWipeManageInfo(void)
+{
+ FpClearManageInfo();
FpDeleteSend(FINGERPRINT_CMD_DELETE_ALL, 1);
}
### src/managers/fingerprint_process.h
@@ -191,6 +191,7 @@ void SearchFpInitState(void);
void SetFpAesKey(void);
void SetFpLowPowerMode(void);
uint8_t *GuiGetFpVersion(char *version, uint32_t maxLen);
+void FpClearManageInfo(void);
void FpWipeManageInfo(void);
const char *GetFpErrorMessage(FingerError_Code errCode);
void FpResponseHandleStop(void);
### src/managers/keystore.c
@@ -28,6 +28,7 @@
#include "assert.h"
#include "secret_cache.h"
#include "background_task.h"
+#include "fingerprint_process.h"
#ifdef COMPILE_SIMULATOR
#include "simulator_model.h"
#include "simulator_storage.h"
@@ -292,11 +293,14 @@ int32_t GetAccountSlip39Ems(uint8_t accountIndex, uint8_t *slip39Ems, const char
/// @param[in] newPassword New password.
/// @param[in] password Old password.
/// @return err code.
-int32_t ChangePassword(uint8_t accountIndex, const char *newPassword, const char *password)
+int32_t ChangePassword(uint8_t accountIndex, const char *newPassword, const char *password, bool *modified)
{
int32_t ret;
AccountSecret_t accountSecret;
+ if (modified != NULL) {
+ *modified = false;
+ }
ASSERT(accountIndex <= 2);
if (accountIndex != GetCurrentAccountIndex() || GetIsTempAccount()) {
printf("change pin requires the current base account\r\n");
@@ -307,11 +311,15 @@ int32_t ChangePassword(uint8_t accountIndex, const char *newPassword, const char
CHECK_ERRCODE_BREAK("check repeat password", ret);
ret = LoadAccountSecret(accountIndex, &accountSecret, password); // decrypt seed under PIN_old (reads only)
CHECK_ERRCODE_BREAK("load account secret", ret);
+ UpdateFingerSignFlag(accountIndex, false);
// Change-PIN re-provisions the SAME index under PIN_new. Bracket the re-wrap with CHANGING_PIN so an
// interrupted change (power loss / failure) is erased and restored at boot. The backend hook
// handles generation-specific prep (gen-1 no-op).
ret = SE_SetAccountStatus(accountIndex, ACCOUNT_STATUS_CHANGING_PIN);
CHECK_ERRCODE_BREAK("set changing pin status", ret);
+ if (modified != NULL) {
+ *modified = true;
+ }
ret = SE_PrepareChangePin(accountIndex, password); // password = PIN_old
CHECK_ERRCODE_BREAK("prepare change pin", ret);
ret = SaveAccountSecret(accountIndex, &accountSecret, newPassword, false);
@@ -323,6 +331,8 @@ int32_t ChangePassword(uint8_t accountIndex, const char *newPassword, const char
CHECK_ERRCODE_BREAK("regenerate zcash z3 ufvk", ret);
}
#endif
+ ret = VerifyAccountPassword(accountIndex, newPassword);
+ CHECK_ERRCODE_BREAK("verify new password", ret);
ret = SE_SetAccountStatus(accountIndex, ACCOUNT_STATUS_CREATED);
CHECK_ERRCODE_BREAK("set created status", ret);
} while (0);
@@ -513,7 +523,7 @@ int32_t CheckPasswordExisted(const char *password, uint8_t excludeIndex)
/// @param[in] passphrase
/// @param[in] password Password string.
/// @return err code.
-int32_t SetPassphrase(uint8_t accountIndex, const char *passphrase, const char *password)
+int32_t SetSetupPassphrase(uint8_t accountIndex, const char *passphrase, const char *password)
{
uint8_t seed[SEED_LEN] = {0};
uint8_t newMfp[4] = {0};
@@ -540,6 +550,10 @@ int32_t SetPassphrase(uint8_t accountIndex, const char *passphrase, const char *
}
ret = simpleResponse->error_code;
CHECK_ERRCODE_BREAK("get_master_fingerprint", ret);
+ if (simpleResponse->data == NULL) {
+ ret = ERR_GENERAL_FAIL;
+ break;
+ }
memcpy_s(newMfp, sizeof(newMfp), simpleResponse->data, sizeof(newMfp));
free_simple_response_u8(simpleResponse);
simpleResponse = NULL;
@@ -562,14 +576,20 @@ int32_t SetPassphrase(uint8_t accountIndex, const char *passphrase, const char *
ret = SetupZcashCache(accountIndex, password, NULL);
CHECK_ERRCODE_BREAK("setup passphrase zcash cache", ret);
#endif
- SetPassphraseMark(passphrase[0] != '\0');
+ ret = SetPassphraseMark(passphrase[0] != '\0');
} while (0);
if (simpleResponse != NULL) {
free_simple_response_u8(simpleResponse);
}
CLEAR_ARRAY(seed);
CLEAR_ARRAY(newMfp);
+ return ret;
+}
+
+int32_t SetPassphrase(uint8_t accountIndex, const char *passphrase, const char *password)
+{
+ int32_t ret = SetSetupPassphrase(accountIndex, passphrase, password);
if (ret != SUCCESS_CODE) {
ClearAccountPassphrase(accountIndex);
ClearSecretCache();
@@ -667,7 +687,6 @@ static int32_t SaveAccountSecret(uint8_t accountIndex, const AccountSecret_t *ac
// Account-create bracket: mark CREATING before any SE write, so an
// interrupted create (power loss / auto-lock mid-provision) is caught at the next boot
// (AccountsDataCheck erases the partial account) instead of leaving a half-written, HMAC-failing
- // slot. Flipped to CREATED only after the full blob + account info commit below. (Change-PIN's
// CHANGING_PIN bracket lives in ChangePassword; it calls here with newAccount == false.)
ret = SE_SetAccountStatus(accountIndex, ACCOUNT_STATUS_CREATING);
CHECK_ERRCODE_BREAK("set creating status", ret);
@@ -749,8 +768,6 @@ static int32_t SaveAccountSecret(uint8_t accountIndex, const AccountSecret_t *ac
CHECK_ERRCODE_BREAK("get_master_fingerprint", ret);
ret = SaveCurrentAccountInfo(); // capture the param-page write result (was discarded)
CHECK_ERRCODE_BREAK("write param", ret);
- ret = SE_SetAccountStatus(accountIndex, ACCOUNT_STATUS_CREATED); // create fully committed
- CHECK_ERRCODE_BREAK("set created status", ret);
}
} while (0);
@@ -1028,7 +1045,10 @@ void KeyStoreTest(int argc, char *argv[])
entropyLen = tempI32;
GenerateEntropy(entropy, entropyLen, argv[3]);
PrintArray("entropy", entropy, entropyLen);
- ret = CreateNewAccount(index, entropy, entropyLen, argv[3]);
+ ret = CreateNewAccount(index, entropy, entropyLen, argv[3], NULL);
+ if (ret == SUCCESS_CODE) {
+ ret = SE_SetAccountStatus(index, ACCOUNT_STATUS_CREATED);
+ }
printf("CreateNewAccount=%d\r\n", ret);
} else if (strcmp(argv[0], "new_slip39_entropy") == 0) {
VALUE_CHECK(argc, 4);
@@ -1037,7 +1057,10 @@ void KeyStoreTest(int argc, char *argv[])
entropyLen = tempI32;
GenerateEntropy(entropy, entropyLen, argv[3]);
PrintArray("entropy", entropy, entropyLen);
- ret = CreateNewSlip39Account(index, ems, entropy, entropyLen, argv[3], 4543, false, 0);
+ ret = CreateNewSlip39Account(index, ems, entropy, entropyLen, argv[3], 4543, false, 0, NULL);
+ if (ret == SUCCESS_CODE) {
+ ret = SE_SetAccountStatus(index, ACCOUNT_STATUS_CREATED);
+ }
printf("CreateNewSlip39Account=%d\r\n", ret);
} else if (strcmp(argv[0], "save_slip39_entropy") == 0) {
VALUE_CHECK(argc, 5);
@@ -1050,7 +1073,10 @@ void KeyStoreTest(int argc, char *argv[])
}
PrintArray("entropy", entropy, entropyLen);
uint8_t ems[32] = {0};
- ret = CreateNewSlip39Account(index, ems, entropy, entropyLen, argv[4], 1234, false, 0);
+ ret = CreateNewSlip39Account(index, ems, entropy, entropyLen, argv[4], 1234, false, 0, NULL);
+ if (ret == SUCCESS_CODE) {
+ ret = SE_SetAccountStatus(index, ACCOUNT_STATUS_CREATED);
+ }
printf("CreateNewSlip39Account=%d\r\n", ret);
} else if (strcmp(argv[0], "get_entropy") == 0) {
VALUE_CHECK(argc, 3);
@@ -1070,7 +1096,10 @@ void KeyStoreTest(int argc, char *argv[])
printf("input length err\r\n");
}
PrintArray("entropy", entropy, 32);
- ret = CreateNewAccount(index, entropy, entropyLen, argv[4]);
+ ret = CreateNewAccount(index, entropy, entropyLen, argv[4], NULL);
+ if (ret == SUCCESS_CODE) {
+ ret = SE_SetAccountStatus(index, ACCOUNT_STATUS_CREATED);
+ }
printf("CreateNewAccount=%d\r\n", ret);
} else if (strcmp(argv[0], "get_seed") == 0) {
VALUE_CHECK(argc, 3);
@@ -1113,7 +1142,7 @@ void KeyStoreTest(int argc, char *argv[])
} else if (strcmp(argv[0], "change_password") == 0) {
VALUE_CHECK(argc, 4);
sscanf(argv[1], "%d", &index);
- ret = ChangePassword(index, argv[2], argv[3]);
+ ret = ChangePassword(index, argv[2], argv[3], NULL);
printf("ChangePassword=%d\r\n", ret);
} else if (strcmp(argv[0], "get_account") == 0) {
ret = GetBlankAccountIndex(&accountIndex);
### src/managers/keystore.h
@@ -52,7 +52,7 @@ int32_t SaveNewSlip39Entropy(uint8_t accountIndex, const uint8_t *ems, const uin
int32_t GetAccountEntropy(uint8_t accountIndex, uint8_t *entropy, uint8_t *entropyLen, const char *password);
int32_t GetAccountSeed(uint8_t accountIndex, uint8_t *seed, const char *password);
int32_t GetAccountSlip39Ems(uint8_t accountIndex, uint8_t *slip39Ems, const char *password);
-int32_t ChangePassword(uint8_t accountIndex, const char *newPassword, const char *password);
+int32_t ChangePassword(uint8_t accountIndex, const char *newPassword, const char *password, bool *modified);
int32_t FindAccountByPassword(uint8_t *matchedAccountIndex, const char *password);
int32_t VerifyAccountPassword(uint8_t accountIndex, const char *password);
int32_t FindAccountByPasswordAndDeriveSubkey(
@@ -71,6 +71,7 @@ char* GetPassphrase(uint8_t accountIndex);
int32_t CheckPasswordExisted(const char *password, uint8_t excludeIndex);
int32_t SetPassphrase(uint8_t accountIndex, const char *passphrase, const char *password);
+int32_t SetSetupPassphrase(uint8_t accountIndex, const char *passphrase, const char *password);
void ClearAccountPassphrase(uint8_t accountIndex);
void GetMasterFingerPrint(uint8_t *mfp);
### src/ram/user_memory.h
@@ -48,6 +48,9 @@ void PrintHeapInfo(void);
#ifndef strcmp_s
#define strcmp_s(s, slen, dest, result_p) (*(result_p) = strcmp((s), (dest)), EOK)
#endif
+#ifndef timingsafe_bcmp
+#define timingsafe_bcmp(p1, p2, n) memcmp(p1, p2, n)
+#endif
#ifndef EOK
#define EOK (0)
@@ -60,17 +63,18 @@ void PrintHeapInfo(void);
#include "safe_str_lib.h"
#include "safe_mem_lib.h"
#include "safe_lib_errno.h"
-#define SRAM_MALLOC(size) SramMallocTrack(size, __FILE__, __LINE__, __func__)
-#define SRAM_FREE(p) SramFreeTrack(p, __FILE__, __LINE__, __func__)
-#define SRAM_REALLOC(p, size) SramReallocTrack(p, size, __FILE__, __LINE__, __func__)
+#include "diagnostic_location.h"
+#define SRAM_MALLOC(size) SramMallocTrack(size, DIAGNOSTIC_FILE, DIAGNOSTIC_LINE, __func__)
+#define SRAM_FREE(p) SramFreeTrack(p, DIAGNOSTIC_FILE, DIAGNOSTIC_LINE, __func__)
+#define SRAM_REALLOC(p, size) SramReallocTrack(p, size, DIAGNOSTIC_FILE, DIAGNOSTIC_LINE, __func__)
#endif
#ifdef COMPILE_SIMULATOR
#define EXT_MALLOC(size) malloc(size)
#define EXT_FREE(p) free(p)
#else
-#define EXT_MALLOC(size) ExtMallocTrack(size, __FILE__, __LINE__, __func__)
-#define EXT_FREE(p) ExtFreeTrack(p, __FILE__, __LINE__, __func__)
+#define EXT_MALLOC(size) ExtMallocTrack(size, DIAGNOSTIC_FILE, DIAGNOSTIC_LINE, __func__)
+#define EXT_FREE(p) ExtFreeTrack(p, DIAGNOSTIC_FILE, DIAGNOSTIC_LINE, __func__)
#endif
#endif
### src/tasks/mpu_sandbox_internal.h
@@ -16,8 +16,15 @@
#define MPU_SANDBOX_UR_CHUNK_HEADER_SIZE 4U
#define MPU_SANDBOX_UR_CHUNK_DATA_SIZE \
(MPU_SANDBOX_INPUT_SIZE - MPU_SANDBOX_UR_CHUNK_HEADER_SIZE)
+#ifdef CYPHERPUNK_VERSION
+#define MPU_SANDBOX_CBOR_INPUT_MAX_SIZE (32U * 1024U)
+#elif defined(WEB3_VERSION)
+#define MPU_SANDBOX_CBOR_INPUT_MAX_SIZE (17U * 1024U)
+#else
#define MPU_SANDBOX_CBOR_INPUT_MAX_SIZE (14U * 1024U)
-#define MPU_SANDBOX_EIP712_JSON_INPUT_MAX_SIZE MPU_SANDBOX_CBOR_INPUT_MAX_SIZE
+#endif
+#define MPU_SANDBOX_EIP712_JSON_INPUT_MAX_SIZE (14U * 1024U)
+#define MPU_SANDBOX_CBOR_STATE_SIZE 512U
typedef struct {
volatile MpuSandboxRequest_t request;
@@ -42,12 +49,18 @@ typedef struct {
} MpuSandboxUrChunkResult_t;
typedef struct {
- uint8_t data[MPU_SANDBOX_CBOR_INPUT_MAX_SIZE];
+ uint8_t data[MPU_SANDBOX_EIP712_JSON_INPUT_MAX_SIZE];
uint16_t length;
uint16_t total_length;
bool active;
} MpuSandboxPayloadValidationState_t;
+typedef struct {
+ uint8_t parser[MPU_SANDBOX_CBOR_STATE_SIZE] __attribute__((aligned(8)));
+ uint16_t length;
+ uint16_t total_length;
+} MpuSandboxCborState_t;
+
typedef enum {
MPU_SANDBOX_PAYLOAD_NONE = 0,
MPU_SANDBOX_PAYLOAD_EAPDU,
@@ -58,10 +71,12 @@ typedef enum {
#ifndef BTC_ONLY
typedef union {
EapduFramingState_t eapdu;
+ MpuSandboxCborState_t cbor;
MpuSandboxPayloadValidationState_t validation;
} MpuSandboxPayloadState_t;
#else
typedef union {
+ MpuSandboxCborState_t cbor;
MpuSandboxPayloadValidationState_t validation;
} MpuSandboxPayloadState_t;
#endif
### src/tasks/mpu_sandbox_runtime.c
@@ -179,9 +179,56 @@ static void MpuSandboxProcessPayloadValidationChunk(MpuSandboxInput_t *input,
static void MpuSandboxProcessCborChunk(MpuSandboxInput_t *input, MpuSandboxRw_t *rw)
{
- MpuSandboxProcessPayloadValidationChunk(input, rw,
- MPU_SANDBOX_PAYLOAD_CBOR,
- MPU_SANDBOX_VALIDATION_CBOR);
+ MpuSandboxCborState_t *state = &rw->payload.cbor;
+ uint32_t inputLength = input->request.input_length;
+ if ((rw->payload_mode != MPU_SANDBOX_PAYLOAD_NONE) &&
+ (rw->payload_mode != MPU_SANDBOX_PAYLOAD_CBOR)) {
+ rw->output.response.status = MPU_SANDBOX_STATUS_INVALID_REQUEST;
+ return;
+ }
+ if ((inputLength <= MPU_SANDBOX_UR_CHUNK_HEADER_SIZE) ||
+ (inputLength > MPU_SANDBOX_INPUT_SIZE)) {
+ goto invalid;
+ }
+ uint16_t offset = (uint16_t)input->input[0] | ((uint16_t)input->input[1] << 8U);
+ uint16_t total = (uint16_t)input->input[2] | ((uint16_t)input->input[3] << 8U);
+ uint32_t length = inputLength - MPU_SANDBOX_UR_CHUNK_HEADER_SIZE;
+ if ((total == 0U) || (total > MPU_SANDBOX_CBOR_INPUT_MAX_SIZE) ||
+ ((uint32_t)offset + length > total)) {
+ goto invalid;
+ }
+ if (offset == 0U) {
+ if (rw->payload_mode != MPU_SANDBOX_PAYLOAD_NONE) {
+ goto invalid;
+ }
+ SandboxZero(&rw->payload, sizeof(rw->payload));
+ rw->payload_mode = MPU_SANDBOX_PAYLOAD_CBOR;
+ state->total_length = total;
+ } else if ((rw->payload_mode != MPU_SANDBOX_PAYLOAD_CBOR) ||
+ (state->length != offset) || (state->total_length != total)) {
+ goto invalid;
+ }
+ state->length = (uint16_t)(offset + length);
+ bool last = state->length == total;
+ MpuSandboxUrChunkResult_t result = {
+ .validation_status = mpu_sandbox_cbor_stream_push(state->parser,
+ sizeof(state->parser), input->input + MPU_SANDBOX_UR_CHUNK_HEADER_SIZE,
+ length, last),
+ .accepted_length = state->length,
+ };
+ if (last) {
+ SandboxZero(&rw->payload, sizeof(rw->payload));
+ rw->payload_mode = MPU_SANDBOX_PAYLOAD_NONE;
+ }
+ SandboxCopy(rw->output.output, &result, sizeof(result));
+ rw->output.response.output_length = sizeof(result);
+ __asm volatile("dmb" ::: "memory");
+ rw->output.response.status = MPU_SANDBOX_STATUS_OK;
+ return;
+invalid:
+ SandboxZero(&rw->payload, sizeof(rw->payload));
+ rw->payload_mode = MPU_SANDBOX_PAYLOAD_NONE;
+ rw->output.response.status = MPU_SANDBOX_STATUS_INVALID_REQUEST;
}
static void MpuSandboxProcessEip712JsonChunk(MpuSandboxInput_t *input, MpuSandboxRw_t *rw)
### src/tasks/mpu_sandbox_ur_validator.h
@@ -3,6 +3,7 @@
#include <stddef.h>
#include <stdint.h>
+#include <stdbool.h>
#define MPU_SANDBOX_RESOLVE_UR_COMMAND 0x0002U
@@ -31,6 +32,8 @@ typedef enum {
uint32_t mpu_sandbox_validate_ur(const uint8_t *input, size_t input_len);
uint32_t mpu_sandbox_validate_cbor(const uint8_t *input, size_t input_len);
+uint32_t mpu_sandbox_cbor_stream_push(uint8_t *storage, size_t capacity,
+ const uint8_t *input, size_t input_len, bool last);
uint32_t mpu_sandbox_validate_eip712_json(uint8_t *input, size_t input_len);
#endif
### src/tasks/qrdecode_task.c
@@ -164,6 +164,10 @@ void ProcessQr(uint32_t count)
}
} else if (retFromRust == 0U) {
retFromRust = urResult->error_code;
+ printf("QR first frame rejected: bytes=%lu, error code=%d\r\n",
+ (unsigned long)qrLength, (int)urResult->error_code);
+ printf("error message: %s\r\n",
+ urResult->error_message != NULL ? urResult->error_message : "(none)");
}
} else {
### src/ui/gui_analyze/gui_analyze.c
@@ -3,8 +3,13 @@
#include "cjson/cJSON.h"
#include "lvgl.h"
#include "gui_analyze.h"
+#include "assert.h"
+#include "gui_chain_components.h"
#include "gui_chain.h"
#include "gui_model.h"
+#ifdef FEATURE_TRON
+#include "gui_trx.h"
+#endif
#ifndef COMPILE_SIMULATOR
#include "safe_mem_lib.h"
@@ -29,7 +34,7 @@ typedef struct {
FreeChainDataFunc freeFunc;
} GuiAnalyze_t;
-#define GUI_ANALYZE_TABVIEW_CNT 2
+#define GUI_ANALYZE_TABVIEW_CNT 3
typedef struct {
lv_obj_t *obj[GUI_ANALYZE_TABVIEW_CNT];
uint8_t tabviewIndex;
@@ -45,22 +50,14 @@ typedef struct {
const static GuiAnalyze_t g_analyzeArray[] = {
{
REMAPVIEW_BTC,
-#ifndef COMPILE_SIMULATOR
"{\"name\":\"btc_page\",\"type\":\"tabview\",\"pos\":[36,0],\"size\":[408,774],\"bg_color\":0,\"border_width\":0,\"children\":[{\"type\":\"tabview_child\",\"index\":1,\"tab_name\":\"Overview\",\"text_color\":16777215,\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"custom_container\",\"bg_color\":0,\"bg_opa\":0,\"pos\":[0,12],\"custom_show_func\":\"GuiBtcTxOverview\"}]},{\"type\":\"tabview_child\",\"index\":2,\"tab_name\":\"Details\",\"text_color\":16777215,\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"custom_container\",\"bg_color\":0,\"bg_opa\":0,\"pos\":[0,12],\"custom_show_func\":\"GuiBtcTxDetail\"}]}]}",
-#else
- PC_SIMULATOR_PATH "/page_btc.json",
-#endif
GuiGetParsedQrData,
NULL,
FreePsbtUxtoMemory,
},
{
REMAPVIEW_BTC_MESSAGE,
-#ifndef COMPILE_SIMULATOR
"{\"type\":\"container\",\"pos\":[36,0],\"size\":[408,526],\"bg_opa\":0,\"children\":[{\"type\":\"custom_container\",\"bg_color\":0,\"bg_opa\":0,\"pos\":[0,12],\"custom_show_func\":\"GuiBtcMsg\"}]}",
-#else
- PC_SIMULATOR_PATH "/page_btc_msg.json",
-#endif
GuiGetParsedQrData,
NULL,
FreeBtcMsgMemory,
@@ -313,7 +310,7 @@ lv_event_cb_t GuiTemplateEventCbGet(char *type)
void GuiWidgetBaseInit(lv_obj_t *obj, cJSON *json)
{
GetContSizeFunc func = NULL;
- uint16_t xpos, ypos;
+ uint16_t xpos = 0, ypos = 0;
int xsize, ysize;
lv_align_t align;
// virtual void create_lvgl_widget(cJSON *json) {};
@@ -418,6 +415,39 @@ void GuiWidgetBaseInit(lv_obj_t *obj, cJSON *json)
lv_obj_set_scrollbar_mode(obj, LV_SCROLLBAR_MODE_OFF);
+ bool dynamic = cJSON_IsTrue(cJSON_GetObjectItem(json, "dynamic"));
+ if (dynamic) {
+ const char *type = cJSON_GetObjectItem(json, "type")->valuestring;
+ bool viewport = cJSON_IsTrue(cJSON_GetObjectItem(json, "viewport"));
+ if (!strcmp(type, "container") || !strcmp(type, "tabview_child")) {
+ lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN);
+ lv_obj_set_style_pad_row(obj, 12, LV_PART_MAIN);
+ lv_obj_set_style_pad_column(obj, 0, LV_PART_MAIN);
+ if (!strcmp(type, "tabview_child")) {
+ lv_obj_set_style_pad_all(obj, 0, LV_PART_MAIN);
+ lv_obj_set_style_pad_top(obj, 12, LV_PART_MAIN);
+ lv_obj_set_style_pad_bottom(obj, 16, LV_PART_MAIN);
+ } else {
+ cJSON *padding = cJSON_GetObjectItem(json, "content_padding");
+ lv_obj_set_style_pad_all(obj, padding ? padding->valueint : 16, LV_PART_MAIN);
+ }
+ }
+ if (strcmp(type, "tabview_child") && !viewport) {
+ lv_obj_set_width(obj, lv_pct(100));
+ if (strcmp(type, "paged_text")) lv_obj_set_height(obj, LV_SIZE_CONTENT);
+ }
+ if (!strcmp(type, "label")) {
+ lv_label_set_long_mode(obj, LV_LABEL_LONG_WRAP);
+ lv_obj_set_height(obj, LV_SIZE_CONTENT);
+ }
+ if (viewport || !strcmp(type, "tabview_child")) {
+ lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
+ lv_obj_set_scroll_dir(obj, LV_DIR_VER);
+ } else {
+ lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
+ }
+ }
+
cJSON *childrenArray = cJSON_GetObjectItem(json, "children");
if (childrenArray != NULL) {
for (cJSON *child = childrenArray->child; child != NULL; child = child->next) {
@@ -444,6 +474,18 @@ void GuiWidgetBaseInit(lv_obj_t *obj, cJSON *json)
!strcmp(ethTextFunc->valuestring, "GetMessageRaw"));
continue;
}
+#endif
+#ifdef FEATURE_TRON
+ cJSON *trxType = cJSON_GetObjectItem(child, "type");
+ cJSON *trxTextFunc = cJSON_GetObjectItem(child, "text_func");
+ if (trxType != NULL && trxTextFunc != NULL &&
+ !strcmp(trxType->valuestring, "label") &&
+ (!strcmp(trxTextFunc->valuestring, "GetTrxMessageUtf8") ||
+ !strcmp(trxTextFunc->valuestring, "GetTrxMessageRaw"))) {
+ GuiShowTrxMessagePaged(obj, g_totalData,
+ !strcmp(trxTextFunc->valuestring, "GetTrxMessageRaw"));
+ continue;
+ }
#endif
GuiWidgetFactoryCreate(obj, child);
}
@@ -463,6 +505,8 @@ static char *GetLabelText(lv_obj_t *parent, cJSON *json)
}
}
char *text = EXT_MALLOC(bufLen);
+ ASSERT(text != NULL);
+ memset(text, 0, bufLen);
item = cJSON_GetObjectItem(json, "text");
if (item != NULL) {
strcpy_s(text, bufLen, _(item->valuestring));
@@ -484,6 +528,46 @@ static char *GetLabelText(lv_obj_t *parent, cJSON *json)
return text;
}
+static void GuiPagedTextDelete(lv_event_t *event)
+{
+ EXT_FREE(lv_event_get_user_data(event));
+}
+
+static lv_obj_t *GuiWidgetPagedText(lv_obj_t *parent, cJSON *json)
+{
+ lv_obj_t *obj = lv_obj_create(parent);
+ lv_obj_set_size(obj, lv_pct(100), 360);
+ lv_obj_set_style_pad_all(obj, 0, LV_PART_MAIN);
+ lv_obj_set_style_border_width(obj, 0, LV_PART_MAIN);
+ lv_obj_set_style_bg_opa(obj, LV_OPA_TRANSP, LV_PART_MAIN);
+ char *ownedText = NULL;
+ const char *text = NULL;
+#ifdef FEATURE_TRON
+ cJSON *textFunc = cJSON_GetObjectItem(json, "text_func");
+ if (textFunc != NULL && textFunc->valuestring != NULL &&
+ (strcmp(textFunc->valuestring, "GetTrxCallData") == 0 ||
+ strcmp(textFunc->valuestring, "GetTrxMemo") == 0 ||
+ strcmp(textFunc->valuestring, "GetTrxMemoHex") == 0)) {
+ if (strcmp(textFunc->valuestring, "GetTrxMemo") == 0) {
+ text = GuiGetTrxMemoText(g_totalData);
+ } else if (strcmp(textFunc->valuestring, "GetTrxMemoHex") == 0) {
+ text = GuiGetTrxMemoHexText(g_totalData);
+ } else {
+ text = GuiGetTrxCallDataText(g_totalData);
+ }
+ } else
+#endif
+ {
+ ownedText = GetLabelText(parent, json);
+ text = ownedText;
+ }
+ GuiShowPagedMessageText(obj, text, true, NULL, NULL);
+ if (ownedText != NULL) {
+ lv_obj_add_event_cb(obj, GuiPagedTextDelete, LV_EVENT_DELETE, ownedText);
+ }
+ return obj;
+}
+
lv_obj_t *GuiWidgetTextArea(lv_obj_t *parent, cJSON *json)
{
lv_obj_clear_flag(parent, LV_OBJ_FLAG_SCROLLABLE);
@@ -536,7 +620,7 @@ static void DisplayJsonRecursive(lv_obj_t *parent, cJSON *item, int indent, uint
while (item != NULL) {
if (item->string != NULL) {
- snprintf(buf, sizeof(buf), "%s:", item->string);
+ snprintf_s(buf, sizeof(buf), "%s:", item->string);
GuiCreateValueLabel(parent, buf, indent, yOffset);
}
@@ -556,13 +640,13 @@ static void DisplayJsonRecursive(lv_obj_t *parent, cJSON *item, int indent, uint
}
GuiCreateValueLabel(parent, buf, indent + 1, yOffset);
} else if (cJSON_IsNumber(item)) {
- snprintf(buf, sizeof(buf), "%.0f", item->valuedouble);
+ snprintf_s(buf, sizeof(buf), "%.0f", item->valuedouble);
GuiCreateValueLabel(parent, buf, indent + 1, yOffset);
} else if (cJSON_IsBool(item)) {
- snprintf(buf, sizeof(buf), "%*s%s", (indent + 1) * 2, "", item->valueint ? "true" : "false");
+ snprintf_s(buf, sizeof(buf), "%*s%s", (indent + 1) * 2, "", item->valueint ? "true" : "false");
GuiCreateValueLabel(parent, buf, indent, yOffset);
} else if (cJSON_IsNull(item)) {
- snprintf(buf, sizeof(buf), "%*snull", (indent + 1) * 2, "");
+ snprintf_s(buf, sizeof(buf), "%*snull", (indent + 1) * 2, "");
GuiCreateValueLabel(parent, buf, indent, yOffset);
}
@@ -916,7 +1000,7 @@ lv_obj_t *GuiWidgetTabViewChild(lv_obj_t *parent, cJSON *json)
lv_obj_set_style_text_color(tab_btns, WHITE_COLOR, LV_PART_ITEMS | LV_STATE_CHECKED);
lv_obj_set_style_text_color(tab_btns, WHITE_COLOR, LV_PART_MAIN);
lv_obj_set_style_border_side(tab_btns, LV_BORDER_SIDE_BOTTOM, LV_PART_ITEMS | LV_STATE_CHECKED);
- lv_obj_set_width(tab_btns, 200);
+ lv_obj_set_width(tab_btns, g_analyzeTabview.tabviewIndex >= 2 ? 408 : 200);
item = cJSON_GetObjectItem(json, "font");
if (item != NULL) {
@@ -995,6 +1079,8 @@ static lv_obj_t *GuiWidgetFactoryCreate(lv_obj_t *parent, cJSON *json)
obj = GuiWidgetCustomContainer(parent, json);
} else if (0 == strcmp(type, "textarea")) {
obj = GuiWidgetTextArea(parent, json);
+ } else if (0 == strcmp(type, "paged_text")) {
+ obj = GuiWidgetPagedText(parent, json);
} else if (0 == strcmp(type, "json_label")) {
obj = GuiWidgetJsonLabel(parent, json);
} else if (0 == strcmp(type, "btn")) {
@@ -1012,6 +1098,30 @@ void SetParseTransactionResult(void* result)
g_totalData = ((TransactionParseResult_DisplayTx *)result)->data;
}
+static cJSON *ParseTransactionTemplate(const char *config)
+{
+#ifdef COMPILE_SIMULATOR
+ enum { TRANSACTION_TEMPLATE_MAX_LEN = 100 * 1024 };
+ if (config[0] != '{') {
+ lv_fs_file_t fd;
+ uint32_t size = 0;
+ char buf[TRANSACTION_TEMPLATE_MAX_LEN];
+ if (LV_FS_RES_OK != lv_fs_open(&fd, config, LV_FS_MODE_RD)) {
+ printf("lv_fs_open failed %s\n", config);
+ return NULL;
+ }
+ lv_fs_res_t result = lv_fs_read(&fd, buf, sizeof(buf), &size);
+ lv_fs_close(&fd);
+ if (result != LV_FS_RES_OK || size >= sizeof(buf)) {
+ return NULL;
+ }
+ buf[size] = '\0';
+ return cJSON_Parse(buf);
+ }
+#endif
+ return cJSON_Parse(config);
+}
+
static void* CreateTransactionDetailWidgets()
{
int index = -1;
@@ -1024,36 +1134,12 @@ static void* CreateTransactionDetailWidgets()
if (index == -1) {
return NULL;
}
-#ifdef COMPILE_SIMULATOR
- lv_fs_file_t fd;
- uint32_t size;
-#define JSON_MAX_LEN (1024 * 100)
- char buf[JSON_MAX_LEN];
- if (LV_FS_RES_OK != lv_fs_open(&fd, g_analyzeArray[index].config, LV_FS_MODE_RD)) {
- printf("lv_fs_open failed %s\n", g_analyzeArray[index].config);
- return NULL;
- }
-
- lv_fs_read(&fd, buf, JSON_MAX_LEN, &size);
- buf[size] = '\0';
-#endif
-
-#ifdef COMPILE_SIMULATOR
- cJSON *paramJson = cJSON_Parse(buf);
-#else
- cJSON *paramJson = cJSON_Parse(g_analyzeArray[index].config);
-#endif
+ cJSON *paramJson = ParseTransactionTemplate(g_analyzeArray[index].config);
if (paramJson == NULL) {
printf("cJSON_Parse failed\n");
-#ifdef COMPILE_SIMULATOR
- lv_fs_close(&fd);
-#endif
return NULL;
}
lv_obj_t *obj = GuiWidgetFactoryCreate(g_templateContainer, paramJson);
-#ifdef COMPILE_SIMULATOR
- lv_fs_close(&fd);
-#endif
cJSON_Delete(paramJson);
return obj;
}
@@ -1105,6 +1191,9 @@ void GuiAnalyzeViewInit(lv_obj_t *parent)
}
tabWidth += tabItemWidth;
}
+ if (tabWidth > 408) {
+ tabWidth = 408;
+ }
for (int i = 0; i < GUI_ANALYZE_TABVIEW_CNT; i++) {
if (g_analyzeTabview.obj[i] == NULL) {
@@ -1189,7 +1278,13 @@ void *GuiTemplateReload(lv_obj_t *parent, uint8_t index)
return NULL;
}
#ifdef COMPILE_SIMULATOR
- return g_templateContainer;
+ if (g_reMapIndex != REMAPVIEW_BTC && g_reMapIndex != REMAPVIEW_BTC_MESSAGE
+#ifdef WEB3_VERSION
+ && g_reMapIndex != REMAPVIEW_SOL && g_reMapIndex != REMAPVIEW_SOL_MESSAGE
+#endif
+ ) {
+ return g_templateContainer;
+ }
#endif
if (g_tableView == NULL || g_analyzeTabview.obj[0] == NULL) {
### src/ui/gui_analyze/gui_resolve_ur.c
@@ -22,6 +22,7 @@
#endif
#ifdef CYPHERPUNK_VERSION
#include "gui_zcash_batch_widgets.h"
+#include "gui_scan_widgets.h"
#endif
// The order of the enumeration must be guaranteed
@@ -97,6 +98,19 @@ void handleURResult(URParseResult *urResult, URParseMultiResult *urMultiResult,
break;
#endif
#ifdef CYPHERPUNK_VERSION
+ case ZcashAddressCheck: {
+ ZcashAddressScanResult_t message = {.viewType = urViewType};
+ const char *address = zcash_address_qr_text(urResult->data);
+ if (address == NULL || strcpy_s(message.address, sizeof(message.address), address) != EOK) {
+ free_ur_parse_result(urResult);
+ return;
+ }
+ free_ur_parse_result(urResult);
+ if (GuiApiEmitSignal(SIG_QRCODE_VIEW_SCAN_PASS, &message, sizeof(message)) == SUCCESS_CODE) {
+ StopQrDecode();
+ }
+ return;
+ }
case ZcashBatchTx:
GuiSetZcashBatchUrData(urResult, urMultiResult, is_multi);
break;
### src/ui/gui_analyze/multi/cypherpunk/gui_cypherpunk_analyze.h
@@ -2,6 +2,7 @@
#ifndef COMPILE_SIMULATOR
#ifndef _GUI_CYPHERPUNK_ANALYZE_WIDGETS_H
#define _GUI_CYPHERPUNK_ANALYZE_WIDGETS_H
+#include "gui_monero_template.h"
#define GUI_ANALYZE_OBJ_SURPLUS \
{ \
REMAPVIEW_ZCASH, \
@@ -12,14 +13,14 @@
}, \
{ \
REMAPVIEW_XMR_OUTPUT, \
- "{\"name\":\"monero_output_page\",\"type\":\"container\",\"pos\":[36,0],\"size\":[408,542],\"bg_color\":0,\"children\":[{\"type\":\"custom_container\",\"pos\":[0,0],\"bg_opa\":0,\"custom_show_func\":\"GuiShowXmrOutputsDetails\"}]}", \
+ GUI_XMR_OUTPUT_TEMPLATE, \
GuiGetMoneroOutputData, \
NULL, \
FreeMoneroMemory, \
}, \
{ \
REMAPVIEW_XMR_UNSIGNED, \
- "{\"name\":\"monero_transaction_page\",\"type\":\"tabview\",\"pos\":[36,0],\"size\":[408,602],\"bg_color\":0,\"border_width\":0,\"children\":[{\"type\":\"tabview_child\",\"index\":1,\"tab_name\":\"Overview\",\"text_color\":16777215,\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"custom_container\",\"bg_color\":0,\"bg_opa\":0,\"pos\":[0,12],\"custom_show_func\":\"GuiShowXmrTransactionOverview\"}]},{\"type\":\"tabview_child\",\"index\":2,\"tab_name\":\"Details\",\"text_color\":16777215,\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"custom_container\",\"bg_color\":0,\"bg_opa\":0,\"pos\":[0,12],\"custom_show_func\":\"GuiShowXmrTransactionDetails\"}]}]}", \
+ GUI_XMR_UNSIGNED_TEMPLATE, \
GuiGetMoneroUnsignedTxData, \
NULL, \
FreeMoneroMemory, \
### src/ui/gui_analyze/multi/cypherpunk/gui_monero_template.h
@@ -0,0 +1,8 @@
+#ifndef GUI_MONERO_TEMPLATE_H
+#define GUI_MONERO_TEMPLATE_H
+
+#define GUI_XMR_OUTPUT_TEMPLATE "{\"name\":\"monero_output_page\",\"type\":\"container\",\"pos\":[36,0],\"size\":[408,542],\"bg_color\":0,\"children\":[{\"type\":\"custom_container\",\"pos\":[0,0],\"bg_opa\":0,\"custom_show_func\":\"GuiShowXmrOutputsDetails\"}]}"
+
+#define GUI_XMR_UNSIGNED_TEMPLATE "{\"name\":\"monero_transaction_page\",\"type\":\"tabview\",\"pos\":[36,0],\"size\":[408,602],\"bg_color\":0,\"border_width\":0,\"children\":[{\"type\":\"tabview_child\",\"index\":1,\"tab_name\":\"Overview\",\"text_color\":16777215,\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"custom_container\",\"bg_color\":0,\"bg_opa\":0,\"pos\":[0,12],\"custom_show_func\":\"GuiShowXmrTransactionOverview\"}]},{\"type\":\"tabview_child\",\"index\":2,\"tab_name\":\"Details\",\"text_color\":16777215,\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"custom_container\",\"bg_color\":0,\"bg_opa\":0,\"pos\":[0,12],\"custom_show_func\":\"GuiShowXmrTransactionDetails\"}]}]}"
+
+#endif
### src/ui/gui_analyze/multi/web3/gui_general_analyze.c
@@ -69,8 +69,12 @@ GetContSizeFunc GetOtherChainPos(char *type, GuiRemapViewType remapIndex)
GetCustomContainerFunc GetOtherChainCustomFunc(char *funcName)
{
- if (!strcmp(funcName, "GuiShowSolTxOverview")) {
+ if (!strcmp(funcName, "GuiShowSolMessageReview")) {
+ return GuiShowSolMessageReview;
+ } else if (!strcmp(funcName, "GuiShowSolTxOverview")) {
return GuiShowSolTxOverview;
+ } else if (!strcmp(funcName, "GuiShowSolTxAdvanced")) {
+ return GuiShowSolTxAdvanced;
} else if (!strcmp(funcName, "GuiShowSolTxDetail")) {
return GuiShowSolTxDetail;
} else if (!strcmp(funcName, "GuiArTxOverview")) {
@@ -167,6 +171,14 @@ GetObjStateFunc GuiOtherChainStateFuncGet(char *type)
return GetTrxContractExist;
} else if (!strcmp(type, "GetTrxTokenExist")) {
return GetTrxTokenExist;
+ } else if (!strcmp(type, "GetTrxAttachedTokenExist")) {
+ return GetTrxAttachedTokenExist;
+ } else if (!strcmp(type, "GetTrxContractWarningExist")) {
+ return GetTrxContractWarningExist;
+ } else if (!strcmp(type, "GetTrxMemoExist")) {
+ return GetTrxMemoExist;
+ } else if (!strcmp(type, "GetTrxMemoBytesExist")) {
+ return GetTrxMemoBytesExist;
} else if (!strcmp(type, "GetTrxMessageFromExist")) {
return GetTrxMessageFromExist;
} else if (!strcmp(type, "GetTrxMessageFromNotExist")) {
@@ -266,6 +278,12 @@ GetLabelDataFunc GuiOtherChainTextFuncGet(char *type, GuiRemapViewType remapInde
GetLabelDataLenFunc GuiOtherChainTextLenFuncGet(char *type, GuiRemapViewType remapIndex)
{
switch (remapIndex) {
+ case REMAPVIEW_TRX:
+ case REMAPVIEW_TRX_SWAP:
+ if (!strcmp(type, "GetTrxCallDataLen")) return GetTrxCallDataLen;
+ if (!strcmp(type, "GetTrxMemoLen")) return GetTrxMemoLen;
+ if (!strcmp(type, "GetTrxMemoHexLen")) return GetTrxMemoHexLen;
+ return NULL;
case REMAPVIEW_SUI:
return GuiSuiTextLenFuncGet(type);
case REMAPVIEW_APT:
@@ -430,6 +448,34 @@ static GetLabelDataFunc GuiTrxTextFuncGet(char *type)
return GetTrxValueRaw;
} else if (!strcmp(type, "GetTrxMemo")) {
return GetTrxMemo;
+ } else if (!strcmp(type, "GetTrxCallValue")) {
+ return GetTrxCallValue;
+ } else if (!strcmp(type, "GetTrxCallTokenValue")) {
+ return GetTrxCallTokenValue;
+ } else if (!strcmp(type, "GetTrxTokenId")) {
+ return GetTrxTokenId;
+ } else if (!strcmp(type, "GetTrxCallData")) {
+ return GetTrxCallData;
+ } else if (!strcmp(type, "GetTrxContractWarning")) {
+ return GetTrxContractWarning;
+ } else if (!strcmp(type, "GetTrxMemoHex")) {
+ return GetTrxMemoHex;
+ } else if (!strcmp(type, "GetTrxMemoHash")) {
+ return GetTrxMemoHash;
+ } else if (!strcmp(type, "GetTrxFeeLimit")) {
+ return GetTrxFeeLimit;
+ } else if (!strcmp(type, "GetTrxTimestamp")) {
+ return GetTrxTimestamp;
+ } else if (!strcmp(type, "GetTrxRefBlockNum")) {
+ return GetTrxRefBlockNum;
+ } else if (!strcmp(type, "GetTrxRefBlockBytes")) {
+ return GetTrxRefBlockBytes;
+ } else if (!strcmp(type, "GetTrxRefBlockHash")) {
+ return GetTrxRefBlockHash;
+ } else if (!strcmp(type, "GetTrxPermissionId")) {
+ return GetTrxPermissionId;
+ } else if (!strcmp(type, "GetTrxRawDataHash")) {
+ return GetTrxRawDataHash;
}
return NULL;
}
### src/ui/gui_analyze/multi/web3/gui_general_analyze.h
@@ -1,8 +1,17 @@
-#ifdef WEB3_VERSION
-#ifndef COMPILE_SIMULATOR
#ifndef _GUI_GENERAL_ANALYZE_WIDGETS_H
#define _GUI_GENERAL_ANALYZE_WIDGETS_H
+#ifdef WEB3_VERSION
+#define GUI_SOL_PAGE_TEMPLATE "{\"name\":\"sol_page\",\"type\":\"tabview\",\"pos\":[36,0],\"size\":[408,530],\"bg_color\":0,\"border_width\":0,\"children\":[{\"type\":\"tabview_child\",\"index\":1,\"tab_name\":\"Overview\",\"text_color\":16777215,\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"custom_container\",\"bg_color\":0,\"bg_opa\":0,\"pos\":[0,12],\"custom_show_func\":\"GuiShowSolTxOverview\"}]},{\"type\":\"tabview_child\",\"index\":2,\"tab_name\":\"Advanced\",\"text_color\":16777215,\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"custom_container\",\"bg_color\":0,\"bg_opa\":0,\"pos\":[0,12],\"custom_show_func\":\"GuiShowSolTxAdvanced\"}]},{\"type\":\"tabview_child\",\"index\":3,\"tab_name\":\"Details\",\"text_color\":16777215,\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"custom_container\",\"bg_color\":0,\"bg_opa\":0,\"pos\":[0,12],\"custom_show_func\":\"GuiShowSolTxDetail\"}]}]}"
+
+#define GUI_SOL_MESSAGE_TEMPLATE "{\"table\":{\"utf8_message\":{\"type\":\"custom_container\",\"pos\":[0,39],\"size\":[408,500],\"align\":2,\"bg_color\":16777215,\"bg_opa\":31,\"radius\":24,\"custom_show_func\":\"GuiShowSolMessageReview\"},\"raw_message\":{\"type\":\"custom_container\",\"pos\":[0,39],\"size\":[408,500],\"align\":2,\"bg_color\":16777215,\"bg_opa\":31,\"radius\":24,\"custom_show_func\":\"GuiShowSolMessageReview\"}}}"
+
+#define GUI_ADA_PAGE_TEMPLATE "{\"type\":\"custom_container\",\"pos\":[36,0],\"size\":[408,542],\"bg_color\":0,\"bg_opa\":0,\"custom_show_func\":\"GuiShowAdaTx\"}"
+
+#ifndef COMPILE_SIMULATOR
+
+#include "gui_trx_template.h"
+
#define GUI_ANALYZE_OBJ_SURPLUS \
{\
REMAPVIEW_ETH,\
@@ -27,21 +36,21 @@
},\
{\
REMAPVIEW_TRX,\
- "{\"name\":\"trx_page\",\"type\":\"tabview\",\"pos\":[36,0],\"size\":[408,900],\"bg_color\":0,\"children\":[{\"type\":\"tabview_child\",\"index\":1,\"tab_name\":\"Overview\",\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"container\",\"pos\":[0,12],\"size\":[408,106],\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Value\",\"pos\":[24,16],\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxValue\",\"pos\":[24,50],\"text_color\":16090890,\"font\":\"openSansEnLittleTitle\"}]},{\"type\":\"container\",\"pos\":[0,16],\"size\":[408,62],\"align_to\":-2,\"align\":13,\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Method\",\"pos\":[24,16],\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxMethod\",\"pos\":[120,16],\"font\":\"openSansEnIllustrate\"}]},{\"type\":\"container\",\"pos\":[0,16],\"size\":[408,244],\"align_to\":-2,\"align\":13,\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"From\",\"pos\":[24,16],\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxFromAddress\",\"text_width\":360,\"pos\":[24,54],\"font\":\"openSansEnIllustrate\"},{\"type\":\"label\",\"text\":\"To\",\"pos\":[24,130],\"text_opa\":144,\"font\":\"openSansEnIllustrate\"},{\"type\":\"label\",\"text_func\":\"GetTrxToAddress\",\"text_width\":360,\"pos\":[0,8],\"align_to\":-2,\"align\":13,\"font\":\"openSansEnIllustrate\"}]}]},{\"type\":\"tabview_child\",\"index\":2,\"tab_name\":\"Details\",\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"container\",\"pos\":[0,12],\"size\":[408,62],\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Value\",\"pos\":[24,16],\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxValue\",\"pos\":[92,16],\"text_color\":16090890,\"font\":\"openSansEnIllustrate\"}]},{\"type\":\"container\",\"pos\":[0,16],\"size\":[408,62],\"align_to\":-2,\"align\":13,\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Method\",\"pos\":[24,16],\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxMethod\",\"pos\":[120,16],\"font\":\"openSansEnIllustrate\"}]},{\"type\":\"container\",\"pos\":[0,16],\"size\":[408,244],\"align_to\":-2,\"align\":13,\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"From\",\"pos\":[24,16],\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxFromAddress\",\"text_width\":360,\"pos\":[24,54],\"font\":\"openSansEnIllustrate\"},{\"type\":\"label\",\"text\":\"To\",\"pos\":[24,130],\"text_opa\":144,\"font\":\"openSansEnIllustrate\"},{\"type\":\"label\",\"text_func\":\"GetTrxToAddress\",\"text_width\":360,\"pos\":[0,8],\"align_to\":-2,\"align\":13,\"font\":\"openSansEnIllustrate\"}]},{\"type\":\"container\",\"pos\":[0,16],\"size\":[408,130],\"align_to\":-2,\"align\":13,\"bg_opa\":31,\"radius\":24,\"exist_func\":\"GetTrxContractExist\",\"children\":[{\"type\":\"label\",\"text\":\"Contract Address\",\"pos\":[24,16],\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxContract\",\"pos\":[24,54],\"font\":\"openSansEnIllustrate\",\"text_width\":360}]},{\"type\":\"container\",\"pos\":[0,16],\"size\":[408,62],\"align_to\":-2,\"align\":13,\"bg_opa\":31,\"radius\":24,\"exist_func\":\"GetTrxTokenExist\",\"children\":[{\"type\":\"label\",\"text\":\"Token ID\",\"pos\":[24,16],\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxToken\",\"pos\":[123,16],\"font\":\"openSansEnIllustrate\"}]}]}]}",\
+ GUI_TRX_PAGE_TEMPLATE, \
GuiGetTrxData,\
NULL,\
FreeTrxMemory,\
},\
{\
REMAPVIEW_TRX_PERSONAL_MESSAGE,\
- "{\"table\":{\"utf8_message\":{\"type\":\"container\",\"pos\":[0,39],\"size\":[408,500],\"align\":2,\"bg_color\":16777215,\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"From\",\"pos\":[24,16],\"exist_func\":\"GetTrxMessageFromExist\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxMessageFrom\",\"pos\":[24,54],\"text_width\":360,\"exist_func\":\"GetTrxMessageFromExist\",\"font\":\"openSansEnIllustrate\"},{\"type\":\"custom_container\",\"bg_color\":0,\"bg_opa\":0,\"exist_func\":\"GetTrxMessageFromNotExist\",\"pos\":[0,0],\"custom_show_func\":\"GuiCustomPathNotice\"},{\"type\":\"label\",\"text\":\"Message\",\"pos_func\":\"GetTrxMessagePos\",\"align_to\":-2,\"align\":13,\"text_color\":16777215,\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"container\",\"size\":[360,332],\"pos\":[0,11],\"align_to\":-2,\"align\":13,\"aflag\":16,\"bg_opa\":0,\"children\":[{\"type\":\"label\",\"text_func\":\"GetTrxMessageUtf8\",\"pos\":[0,0],\"text_width\":360,\"font\":\"openSansEnIllustrate\",\"text_color\":16777215}]}]},\"raw_message\":{\"type\":\"container\",\"pos\":[0,39],\"size\":[408,500],\"align\":2,\"bg_color\":16777215,\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Raw Message\",\"pos\":[24,16],\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"container\",\"pos\":[24,54],\"size\":[360,450],\"align\":1,\"aflag\":16,\"bg_opa\":0,\"children\":[{\"type\":\"label\",\"text_func\":\"GetTrxMessageRaw\",\"pos\":[0,0],\"text_width\":360,\"font\":\"illustrate\"}]}]}}}", \
+ GUI_TRX_PERSONAL_MESSAGE_TEMPLATE, \
GuiGetTrxPersonalMessage,\
GetTrxPersonalMessageType,\
FreeTrxMemory,\
},\
{\
REMAPVIEW_TRX_SWAP,\
- "{\"name\":\"trx_swap_page\",\"type\":\"tabview\",\"pos\":[36,0],\"size\":[408,900],\"bg_color\":0,\"children\":[{\"type\":\"tabview_child\",\"index\":1,\"tab_name\":\"Overview\",\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"container\",\"pos\":[0,12],\"size\":[408,190],\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Swap\",\"pos\":[24,16],\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxValue\",\"pos\":[24,50],\"text_color\":16090890,\"font\":\"openSansEnLittleTitle\"},{\"type\":\"label\",\"text\":\"To\",\"pos\":[24,110],\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxSwapDstAsset\",\"pos\":[24,144],\"text_color\":16090890,\"font\":\"openSansEnLittleTitle\"}]},{\"type\":\"container\",\"pos\":[0,16],\"size\":[408,62],\"align_to\":-2,\"align\":13,\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Network\",\"pos\":[24,16],\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxNetwork\",\"pos\":[120,16],\"font\":\"openSansEnIllustrate\",\"text_color\":16777215}]},{\"type\":\"container\",\"pos\":[0,16],\"size\":[408,146],\"align_to\":-2,\"align\":13,\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"From\",\"pos\":[24,16],\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxFromAddress\",\"text_width\":330,\"pos\":[24,54],\"font\":\"openSansEnIllustrate\",\"text_line_space\":8}]},{\"type\":\"container\",\"pos\":[0,16],\"size\":[408,146],\"align_to\":-2,\"align\":13,\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Destination\",\"pos\":[24,16],\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxSwapDstAddress\",\"text_width\":330,\"pos\":[24,54],\"font\":\"openSansEnIllustrate\",\"text_line_space\":8}]}]},{\"type\":\"tabview_child\",\"index\":2,\"tab_name\":\"Details\",\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"container\",\"pos\":[0,12],\"size\":[408,62],\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Network\",\"pos\":[24,16],\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxNetwork\",\"pos\":[114,16],\"text_color\":16777215}]},{\"type\":\"container\",\"pos\":[0,16],\"size\":[408,62],\"align_to\":-2,\"align\":13,\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Method\",\"pos\":[24,16],\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxMethod\",\"pos\":[114,16],\"text_color\":16777215}]},{\"type\":\"container\",\"pos\":[0,16],\"size\":[408,320],\"align_to\":-2,\"align\":13,\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"From\",\"pos\":[24,16],\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxFromAddress\",\"text_width\":360,\"pos\":[24,54],\"text_line_space\":4},{\"type\":\"label\",\"text\":\"To\",\"pos\":[24,130],\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxToAddress\",\"text_width\":360,\"pos\":[24,168],\"text_line_space\":4},{\"type\":\"container\",\"name\":\"v_btn\",\"pos\":[24,230],\"size\":[360,45],\"bg_opa\":0,\"cb\":\"TrxCheckVault\",\"children\":[{\"type\":\"label\",\"text\":\"Check the Vault Address\",\"pos\":[0,0],\"text_color\":1827014,\"text_decor\":1},{\"type\":\"img\",\"img_src\":\"imgQrcodeTurquoise\",\"pos\":[255,2]}]}]},{\"type\":\"container\",\"pos\":[0,16],\"size\":[408,106],\"align_to\":-2,\"align\":13,\"bg_opa\":31,\"radius\":24,\"exist_func\":\"GetTrxContractExist\",\"children\":[{\"type\":\"label\",\"text\":\"Contract Address\",\"pos\":[24,16],\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxContract\",\"text_width\":360,\"pos\":[24,54]}]},{\"type\":\"container\",\"pos\":[0,16],\"size\":[408,340],\"align_to\":-2,\"align\":13,\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Amount\",\"pos\":[24,16],\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxValueRaw\",\"pos\":[24,50]},{\"type\":\"label\",\"text\":\"Memo\",\"pos\":[24,100],\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxMemo\",\"text_width\":360,\"pos\":[24,134],\"text_line_space\":4},{\"type\":\"label\",\"text\":\"Expiration\",\"pos\":[24,250],\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxExpiration\",\"pos\":[24,284]}]}]}]}",\
+ GUI_TRX_SWAP_TEMPLATE,\
GuiGetTrxData,\
NULL,\
FreeTrxMemory,\
@@ -79,14 +88,14 @@
FreeSuiMemory},\
{\
REMAPVIEW_SOL,\
- "{\"name\":\"sol_page\",\"type\":\"tabview\",\"pos\":[36,0],\"size\":[408,530],\"bg_color\":0,\"border_width\":0,\"children\":[{\"type\":\"tabview_child\",\"index\":1,\"tab_name\":\"Overview\",\"text_color\":16777215,\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"custom_container\",\"bg_color\":0,\"bg_opa\":0,\"pos\":[0,12],\"custom_show_func\":\"GuiShowSolTxOverview\"}]},{\"type\":\"tabview_child\",\"index\":2,\"tab_name\":\"Details\",\"text_color\":16777215,\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"custom_container\",\"bg_color\":0,\"bg_opa\":0,\"pos\":[0,12],\"custom_show_func\":\"GuiShowSolTxDetail\"}]}]}",\
+ GUI_SOL_PAGE_TEMPLATE,\
GuiGetSolData,\
NULL,\
FreeSolMemory,\
},\
{\
REMAPVIEW_SOL_MESSAGE,\
- "{\"table\":{\"utf8_message\":{\"type\":\"container\",\"pos\":[0,39],\"size\":[408,500],\"align\":2,\"bg_color\":16777215,\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"From\",\"pos\":[24,16],\"exist_func\":\"GetSolMessageFromExist\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetSolMessageFrom\",\"pos\":[24,54],\"text_width\":360,\"exist_func\":\"GetSolMessageFromExist\",\"font\":\"openSansEnIllustrate\"},{\"type\":\"custom_container\",\"bg_color\":0,\"bg_opa\":0,\"exist_func\":\"GetSolMessageFromNotExist\",\"pos\":[0,0],\"custom_show_func\":\"GuiCustomPathNotice\"},{\"type\":\"label\",\"text\":\"Message\",\"pos_func\":\"GetSolMessagePos\",\"align_to\":-2,\"align\":13,\"text_color\":16777215,\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"container\",\"size\":[360,332],\"pos\":[0,11],\"align_to\":-2,\"align\":13,\"aflag\":16,\"bg_opa\":0,\"children\":[{\"type\":\"label\",\"text_func\":\"GetSolMessageUtf8\",\"pos\":[0,0],\"text_width\":360,\"font\":\"openSansEnIllustrate\",\"text_color\":16777215}]}]},\"raw_message\":{\"type\":\"container\",\"pos\":[0,39],\"size\":[408,500],\"align\":2,\"bg_color\":16777215,\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Raw Message\",\"pos\":[24,16],\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"container\",\"pos\":[24,54],\"size\":[360,450],\"align\":1,\"aflag\":16,\"bg_opa\":0,\"children\":[{\"type\":\"label\",\"text_func\":\"GetSolMessageRaw\",\"pos\":[0,0],\"text_width\":360,\"font\":\"openSansEnIllustrate\"}]}]}}}", \
+ GUI_SOL_MESSAGE_TEMPLATE, \
GuiGetSolMessageData,\
GetSolMessageType,\
FreeSolMemory,\
@@ -100,7 +109,7 @@
},\
{\
REMAPVIEW_ADA,\
- "{\"type\":\"custom_container\",\"pos\":[36,0],\"size\":[408,542],\"bg_color\":0,\"bg_opa\":0,\"custom_show_func\":\"GuiShowAdaTx\"}",\
+ GUI_ADA_PAGE_TEMPLATE,\
GuiGetAdaData,\
NULL,\
FreeAdaMemory,\
### src/ui/gui_analyze/multi/web3/gui_trx_template.h
@@ -0,0 +1,10 @@
+#ifndef GUI_TRX_TEMPLATE_H
+#define GUI_TRX_TEMPLATE_H
+
+#define GUI_TRX_PAGE_TEMPLATE "{\"name\":\"trx_page\",\"type\":\"tabview\",\"pos\":[36,0],\"size\":[408,530],\"bg_color\":0,\"children\":[{\"type\":\"tabview_child\",\"index\":1,\"tab_name\":\"Overview\",\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxContractWarningExist\",\"children\":[{\"type\":\"label\",\"font\":\"illustrate\",\"dynamic\":true,\"text\":\"Warning\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"illustrate\",\"dynamic\":true,\"text_func\":\"GetTrxContractWarning\",\"text_color\":16090890}]},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxContractExist\",\"children\":[{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"Attached TRX\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxCallValue\"},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"Attached assets recipient\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxContract\"}]},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxAttachedTokenExist\",\"children\":[{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"Attached TRC-10 amount (raw units)\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxCallTokenValue\"},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"TRC-10 Token ID\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxTokenId\"}]},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Value\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxValue\",\"text_color\":16090890,\"font\":\"openSansEnLittleTitle\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Method\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxMethod\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"From\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxFromAddress\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true},{\"type\":\"label\",\"text\":\"To\",\"text_opa\":144,\"font\":\"openSansEnIllustrate\",\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxToAddress\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24}],\"dynamic\":true},{\"type\":\"tabview_child\",\"index\":2,\"tab_name\":\"Details\",\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxContractWarningExist\",\"children\":[{\"type\":\"label\",\"font\":\"illustrate\",\"dynamic\":true,\"text\":\"Warning\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"illustrate\",\"dynamic\":true,\"text_func\":\"GetTrxContractWarning\",\"text_color\":16090890}]},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxContractExist\",\"children\":[{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"Attached TRX\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxCallValue\"},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"Attached assets recipient\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxContract\"}]},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxAttachedTokenExist\",\"children\":[{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"Attached TRC-10 amount (raw units)\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxCallTokenValue\"},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"TRC-10 Token ID\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxTokenId\"}]},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Value\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxValue\",\"text_color\":16090890,\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Method\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxMethod\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"From\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxFromAddress\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true},{\"type\":\"label\",\"text\":\"To\",\"text_opa\":144,\"font\":\"openSansEnIllustrate\",\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxToAddress\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"exist_func\":\"GetTrxContractExist\",\"children\":[{\"type\":\"label\",\"text\":\"Contract Address\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxContract\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"exist_func\":\"GetTrxTokenExist\",\"children\":[{\"type\":\"label\",\"text\":\"Token ID\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxToken\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Raw Value\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxValueRaw\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Network\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxNetwork\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Fee Limit (sun)\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxFeeLimit\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Timestamp (ms)\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxTimestamp\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Expiration (ms)\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxExpiration\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Permission ID\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxPermissionId\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Ref Block Bytes\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxRefBlockBytes\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Ref Block Hash\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxRefBlockHash\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Memo (UTF-8)\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"paged_text\",\"text_func\":\"GetTrxMemo\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_len_func\":\"GetTrxMemoLen\"}],\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxMemoExist\"},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Memo Hex\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"paged_text\",\"text_func\":\"GetTrxMemoHex\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_len_func\":\"GetTrxMemoHexLen\"}],\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxMemoBytesExist\"},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Memo SHA-256\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxMemoHash\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxMemoBytesExist\"},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Raw Data SHA-256\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxRawDataHash\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxContractExist\",\"children\":[{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"Call Data (hex)\",\"text_opa\":144},{\"type\":\"paged_text\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxCallData\",\"text_len_func\":\"GetTrxCallDataLen\"}]},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"dynamic\":true,\"content_padding\":24,\"children\":[{\"type\":\"label\",\"text\":\"Ref Block Number\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxRefBlockNum\",\"dynamic\":true}]}],\"dynamic\":true}]}"
+
+#define GUI_TRX_PERSONAL_MESSAGE_TEMPLATE "{\"table\":{\"utf8_message\":{\"type\":\"container\",\"pos\":[0,39],\"size\":[408,500],\"align\":2,\"bg_color\":16777215,\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"From\",\"pos\":[24,16],\"exist_func\":\"GetTrxMessageFromExist\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"label\",\"text_func\":\"GetTrxMessageFrom\",\"pos\":[24,54],\"text_width\":360,\"exist_func\":\"GetTrxMessageFromExist\",\"font\":\"openSansEnIllustrate\"},{\"type\":\"custom_container\",\"bg_color\":0,\"bg_opa\":0,\"exist_func\":\"GetTrxMessageFromNotExist\",\"pos\":[0,0],\"custom_show_func\":\"GuiCustomPathNotice\"},{\"type\":\"label\",\"text\":\"Message\",\"pos_func\":\"GetTrxMessagePos\",\"align_to\":-2,\"align\":13,\"text_color\":16777215,\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"container\",\"size\":[360,332],\"pos\":[0,11],\"align_to\":-2,\"align\":13,\"aflag\":16,\"bg_opa\":0,\"children\":[{\"type\":\"label\",\"text_func\":\"GetTrxMessageUtf8\",\"pos\":[0,0],\"text_width\":360,\"font\":\"openSansEnIllustrate\",\"text_color\":16777215}]}]},\"raw_message\":{\"type\":\"container\",\"pos\":[0,39],\"size\":[408,500],\"align\":2,\"bg_color\":16777215,\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Raw Message\",\"pos\":[24,16],\"font\":\"openSansEnIllustrate\",\"text_opa\":144},{\"type\":\"container\",\"pos\":[24,54],\"size\":[360,450],\"align\":1,\"aflag\":16,\"bg_opa\":0,\"children\":[{\"type\":\"label\",\"text_func\":\"GetTrxMessageRaw\",\"pos\":[0,0],\"text_width\":360,\"font\":\"illustrate\"}]}]}}}"
+
+#define GUI_TRX_SWAP_TEMPLATE "{\"name\":\"trx_swap_page\",\"type\":\"tabview\",\"pos\":[36,0],\"size\":[408,530],\"bg_color\":0,\"children\":[{\"type\":\"tabview_child\",\"index\":1,\"tab_name\":\"Overview\",\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxContractWarningExist\",\"children\":[{\"type\":\"label\",\"font\":\"illustrate\",\"dynamic\":true,\"text\":\"Warning\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"illustrate\",\"dynamic\":true,\"text_func\":\"GetTrxContractWarning\",\"text_color\":16090890}]},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxContractExist\",\"children\":[{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"Attached TRX\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxCallValue\"},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"Attached assets recipient\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxContract\"}]},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxAttachedTokenExist\",\"children\":[{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"Attached TRC-10 amount (raw units)\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxCallTokenValue\"},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"TRC-10 Token ID\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxTokenId\"}]},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Swap\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxValue\",\"text_color\":16090890,\"font\":\"openSansEnLittleTitle\",\"dynamic\":true},{\"type\":\"label\",\"text\":\"To\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxSwapDstAsset\",\"text_color\":16090890,\"font\":\"openSansEnLittleTitle\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Network\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxNetwork\",\"font\":\"openSansEnIllustrate\",\"text_color\":16777215,\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"From\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxFromAddress\",\"font\":\"openSansEnIllustrate\",\"text_line_space\":8,\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Destination\",\"font\":\"openSansEnIllustrate\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxSwapDstAddress\",\"font\":\"openSansEnIllustrate\",\"text_line_space\":8,\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24}],\"dynamic\":true},{\"type\":\"tabview_child\",\"index\":2,\"tab_name\":\"Details\",\"font\":\"openSansEnIllustrate\",\"children\":[{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxContractWarningExist\",\"children\":[{\"type\":\"label\",\"font\":\"illustrate\",\"dynamic\":true,\"text\":\"Warning\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"illustrate\",\"dynamic\":true,\"text_func\":\"GetTrxContractWarning\",\"text_color\":16090890}]},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxContractExist\",\"children\":[{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"Attached TRX\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxCallValue\"},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"Attached assets recipient\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxContract\"}]},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxAttachedTokenExist\",\"children\":[{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"Attached TRC-10 amount (raw units)\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxCallTokenValue\"},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"TRC-10 Token ID\",\"text_opa\":144},{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxTokenId\"}]},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Network\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxNetwork\",\"text_color\":16777215,\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Method\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxMethod\",\"text_color\":16777215,\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"From\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxFromAddress\",\"text_line_space\":4,\"dynamic\":true},{\"type\":\"label\",\"text\":\"To\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxToAddress\",\"text_line_space\":4,\"dynamic\":true},{\"type\":\"container\",\"name\":\"v_btn\",\"bg_opa\":0,\"cb\":\"TrxCheckVault\",\"children\":[{\"type\":\"label\",\"text\":\"Check the Vault Address\",\"text_color\":1827014,\"text_decor\":1,\"dynamic\":true},{\"type\":\"img\",\"img_src\":\"imgQrcodeTurquoise\"}],\"dynamic\":true,\"content_padding\":0}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"exist_func\":\"GetTrxContractExist\",\"children\":[{\"type\":\"label\",\"text\":\"Contract Address\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxContract\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"children\":[{\"type\":\"label\",\"text\":\"Amount\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxValueRaw\",\"dynamic\":true},{\"type\":\"label\",\"text\":\"Memo\",\"text_opa\":144,\"dynamic\":true,\"exist_func\":\"GetTrxMemoExist\"},{\"type\":\"paged_text\",\"text_func\":\"GetTrxMemo\",\"text_line_space\":4,\"dynamic\":true,\"text_len_func\":\"GetTrxMemoLen\",\"exist_func\":\"GetTrxMemoExist\"},{\"type\":\"label\",\"text\":\"Expiration\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxExpiration\",\"dynamic\":true}],\"dynamic\":true,\"content_padding\":24},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"dynamic\":true,\"content_padding\":24,\"exist_func\":\"GetTrxContractExist\",\"children\":[{\"type\":\"label\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text\":\"Call Data (hex)\",\"text_opa\":144},{\"type\":\"paged_text\",\"font\":\"openSansEnIllustrate\",\"dynamic\":true,\"text_func\":\"GetTrxCallData\",\"text_len_func\":\"GetTrxCallDataLen\"}]},{\"type\":\"container\",\"bg_opa\":31,\"radius\":24,\"dynamic\":true,\"content_padding\":24,\"children\":[{\"type\":\"label\",\"text\":\"Ref Block Number\",\"text_opa\":144,\"dynamic\":true},{\"type\":\"label\",\"text_func\":\"GetTrxRefBlockNum\",\"dynamic\":true}]}],\"dynamic\":true}]}"
+
+#endif
### src/ui/gui_assets/font/cn/cnIllustrate.c
@@ -1,7 +1,7 @@
/*******************************************************************************
* Size: 20 px
* Bpp: 2
- * Opts: --bpp 2 --size 20 --no-compress --font NotoSansSC-Regular.ttf --symbols !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~£¥·“”€、。一三上下不与专且业东丢个中为主久么义之乏也了予争二于些交产享人什仅仍从仔他付代令以们件任份优会传但位低体何余作你使例供保信修倒值做停储像充先免入全公共关其具兼内册再写决况准凭出击分切列则创初删利别到制前剩功加务动助励勿包化匙匹区匿升单卡危即原参及反发取受口另只可合同名后吗否含启告员味命和品哈响善器回因团固图在地场址坊块型域基境增备复外多够大天太失头奖套好如妥始威子字存学它安完官定实审容密对寻导将小少尚尝就屏展属岁嵌差己已币希帐带帮常幕年并广序应度建开异式引弱强当录形影彼往径待律得循微心必志忘快态性总恢息您情想意感慎成我或户所手才打托执扩扫批找技投护抬押担拥择括拭持指按振损换据捷授接推掷描提插摄撤播操擦支收改攻放政效敏教数整文断新方旁无既日旦时明易映是显景晰智暴更曾最有服望期未本术机权条来松构析果架某查标校核根格框案检概模次欢款止正此步段母每比气永求池没法泛注洞派流测消涉添清渡港湿源溯滑满漏潜点然照熵片版牢物特状独猜率环现理甄生用由电留略疑白的目直相看真着知短码破硬确示票禁离私种秒积称移程稍空立站笔符第等策签简算管篡类系索约级纹线组细终经给络统继续维缆编缝缺网罗置署老考者而联股胁能脑自至致节芯若英荐莱获藏虑行衍表被装西要见观规觉解言警计认让议记许设访证识词试该详语误说请读调谨象负财责败账货质费资赌赔起超越足路跳身转软轻载较输辖达过迎运返这进连述追送适逆选途通速造遇遵避邀邮部都酌配采释重量金钟钥钮钱铸链销锁错长门闭问间阅队防限除险随隐隔隙障难零需露非面页项顺须预题额风首香验骰高默(),:;? --format lvgl -o ../gui_assets/font/cn/cnIllustrate.c
+ * Opts: --bpp 2 --size 20 --no-compress --font NotoSansSC-Regular.ttf --symbols !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~£¥·“”€、。一三上下不与专且业东丢个中为主久么义之乏也了予争二于些交产享人什仅仍从仔他付代令以们件任份优会传但位低体何余作你使例供保信修倒值做停储像充先免入全公共关其具兼内册再写决况准凭出击分切列则创初删利别到制前剩功加务动助励勿包化匙匹区匿升单卡危即原参及反发取受口另只可合同名后吗否含启告员味命和品哈响善器回因团固图在地场址坊块型域基境增备复外多够大天太失头奖套好如妥始威子字存学它安完官定实审容密对寻导将小少尚尝就屏展属岁嵌差己已币希帐带帮常幕年并广序应度建开异式引弱强当录形影彼往径待律得循微心必志忘快忽态性总恢息您情想意感慎成我或户所手才打托执扩扫批找技投护抬押担拥择括拭持指按振损换据捷授接推掷描提插摄撤播操擦支收改攻放政效敏教数整文断新方旁无既日旦时明易映是显景晰智暴更曾最有服望期未本术机权条来松构析果架某查标校核根格框案检概模次欢款止正此步段母每比气永求池没法泛注洞派流测消涉添清渡港湿源溯滑满漏潜点然照熵片版牢物特状独猜率环现理甄生用由电留略疑白的目直相看真着知短码破硬确示票禁离私种秒积称移程稍空立站笔符第等策签简算管篡类系索约级纹线组细终经给络统继续维缆编缝缺网罗置署老考者而联股胁能脑自至致节芯若英荐莱获藏虑行衍表被装西要见观规觉解言警计认让议记许设访证识词试该详语误说请读调谨象负财责败账货质费资赌赔起超越足路跳身转软轻载较输辖达过迎运近返这进连述追送适逆选途通速造遇遵避邀邮部都酌配采释重量金钟钥钮钱铸链销锁错长门闭问间阅队防附限除险随隐隔隙障难零需露非面页项顺须预题额风首香验骰高默(),:;? --format lvgl -o ../gui_assets/font/cn/cnIllustrate.c
******************************************************************************/
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
@@ -4078,6 +4078,19 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
0x0, 0xfc, 0x2, 0xc7, 0x0, 0x0, 0x28, 0x0,
0x0, 0x0, 0x0, 0x0,
+ /* U+5FFD "忽" */
+ 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0xf0, 0x0,
+ 0x0, 0x0, 0x7, 0x95, 0x55, 0x54, 0x0, 0x3f,
+ 0xff, 0xff, 0xf8, 0x3, 0xc1, 0xd0, 0xe0, 0xd0,
+ 0x7c, 0xe, 0x7, 0x3, 0x42, 0xc0, 0xf0, 0x38,
+ 0xd, 0x0, 0xf, 0x3, 0xc0, 0x70, 0x1, 0xf0,
+ 0x2d, 0x2, 0xc0, 0xe, 0x2, 0xd0, 0xf, 0x0,
+ 0x0, 0x2d, 0xb, 0xf4, 0x0, 0x0, 0x14, 0x15,
+ 0x40, 0x5, 0x28, 0x3c, 0x1, 0x80, 0x38, 0xe0,
+ 0x3c, 0x7, 0x40, 0xd3, 0x80, 0x70, 0x4b, 0xb,
+ 0xe, 0x0, 0x3, 0xe, 0x34, 0x3d, 0x55, 0x6c,
+ 0x24, 0x0, 0x7f, 0xff, 0xd0, 0x0,
+
/* U+6001 "态" */
0x0, 0x0, 0x28, 0x0, 0x0, 0x0, 0x0, 0x38,
0x0, 0x0, 0x0, 0x0, 0x38, 0x0, 0x0, 0x3f,
@@ -8628,6 +8641,20 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
0x38, 0x6, 0xff, 0xff, 0xfc, 0x0, 0x0, 0x0,
0x0, 0x0,
+ /* U+8FD1 "近" */
+ 0x0, 0x0, 0x0, 0x0, 0x50, 0xd, 0x0, 0x6a,
+ 0xbf, 0xf0, 0x7, 0x40, 0xbe, 0xa4, 0x0, 0x2,
+ 0xd0, 0xb0, 0x0, 0x0, 0x0, 0x90, 0xb0, 0x0,
+ 0x0, 0x0, 0x0, 0xb0, 0x0, 0x0, 0x0, 0x0,
+ 0xbf, 0xff, 0xfc, 0x2a, 0x80, 0xba, 0xae, 0xa8,
+ 0x3f, 0xc0, 0xe0, 0xd, 0x0, 0x0, 0xc0, 0xe0,
+ 0xd, 0x0, 0x0, 0xc0, 0xd0, 0xd, 0x0, 0x0,
+ 0xc1, 0xd0, 0xd, 0x0, 0x0, 0xc2, 0xc0, 0xd,
+ 0x0, 0x0, 0xc3, 0x80, 0xd, 0x0, 0x2, 0xd7,
+ 0x0, 0xd, 0x0, 0xf, 0xb8, 0x0, 0x4, 0x0,
+ 0x3c, 0x1f, 0xa5, 0x56, 0xa8, 0x24, 0x1, 0xbf,
+ 0xff, 0xf8, 0x0, 0x0, 0x0, 0x0, 0x0,
+
/* U+8FD4 "返" */
0x0, 0x0, 0x0, 0x0, 0x50, 0xd, 0x0, 0x5a,
0xbf, 0xf0, 0xb, 0x1, 0xff, 0xa5, 0x0, 0x3,
@@ -9254,6 +9281,20 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
0x41, 0xc0, 0xb8, 0x5, 0x6c, 0x7, 0x2, 0x40,
0x1f, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ /* U+9644 "附" */
+ 0x0, 0x0, 0x24, 0x2, 0x41, 0xff, 0xc0, 0xd0,
+ 0xd, 0x7, 0x5f, 0x7, 0x0, 0x34, 0x1c, 0x38,
+ 0x38, 0x0, 0xd0, 0x70, 0xc1, 0xc0, 0x3, 0x81,
+ 0xc7, 0xf, 0x3f, 0xff, 0xd7, 0x38, 0xbc, 0x0,
+ 0x38, 0x1c, 0xa7, 0xf0, 0x0, 0xd0, 0x70, 0xd9,
+ 0xc2, 0x3, 0x41, 0xc2, 0x87, 0xd, 0xd, 0x7,
+ 0x7, 0x1c, 0x2c, 0x34, 0x1c, 0x1c, 0x70, 0x34,
+ 0xd0, 0x70, 0xb1, 0xc0, 0xe3, 0x41, 0xcf, 0x47,
+ 0x0, 0xd, 0x7, 0x10, 0x1c, 0x0, 0x34, 0x1c,
+ 0x0, 0x70, 0x0, 0xd0, 0x70, 0x1, 0xc0, 0x3,
+ 0x41, 0xc0, 0x7, 0x1, 0x5d, 0x7, 0x0, 0xc,
+ 0x7, 0xf0, 0x0, 0x0, 0x0, 0x0, 0x0,
+
/* U+9650 "限" */
0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xd7, 0xff,
0xfe, 0x3, 0x57, 0x5d, 0x55, 0x78, 0xc, 0x1c,
@@ -10036,411 +10077,414 @@ static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
{.bitmap_index = 25453, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
{.bitmap_index = 25539, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
{.bitmap_index = 25629, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 25729, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 25819, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 25910, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 25996, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 26096, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 26187, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 26273, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 26368, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 26458, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 26539, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 26634, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 26729, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 26824, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 26924, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 27015, .adv_w = 320, .box_w = 17, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 27096, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 27196, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 27287, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 27378, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 27473, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 27563, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 27663, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 27763, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 27849, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 27939, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 28034, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 28134, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 28229, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 28320, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 28415, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 28506, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 28596, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 28687, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 28782, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 28877, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 28972, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 29072, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 29167, .adv_w = 320, .box_w = 20, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 29272, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 29367, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 29467, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 29567, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 29667, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 29767, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 29862, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 29962, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 30062, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 30157, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 30248, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 30343, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 30443, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 30543, .adv_w = 320, .box_w = 20, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 30648, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 30743, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 30838, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 30933, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 31028, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 31119, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 31210, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 31305, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 31400, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 31495, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 31590, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 31685, .adv_w = 320, .box_w = 20, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 31790, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 31885, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 31975, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 32070, .adv_w = 320, .box_w = 19, .box_h = 21, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 32170, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 32265, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 32360, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 32451, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 32541, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 32627, .adv_w = 320, .box_w = 14, .box_h = 18, .ofs_x = 3, .ofs_y = -2},
- {.bitmap_index = 32690, .adv_w = 320, .box_w = 18, .box_h = 17, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 32767, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 32858, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 32939, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 33025, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 33116, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 33206, .adv_w = 320, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 33291, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 33386, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 33477, .adv_w = 320, .box_w = 18, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 33567, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 33667, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 33757, .adv_w = 320, .box_w = 16, .box_h = 20, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 33837, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 33932, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 34023, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 34123, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 34209, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 34300, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 34395, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 34490, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 34585, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 34685, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 34785, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 34880, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 34975, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 35070, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 35165, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 35260, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 35350, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 35445, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 35540, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 35630, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 35725, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 35825, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 35925, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 36025, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 36125, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 36220, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 36315, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 36410, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 36510, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 36610, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 36705, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 36800, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 36900, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 36986, .adv_w = 320, .box_w = 19, .box_h = 17, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 37067, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 37162, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 37253, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 37348, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 37439, .adv_w = 320, .box_w = 20, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 37544, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 37630, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 37725, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 37820, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 37920, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 38010, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 38105, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 38196, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 38291, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 38386, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 38481, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 38576, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 38671, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 38766, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 38857, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 38952, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 39052, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 39143, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 39243, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 39333, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 39428, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 39528, .adv_w = 320, .box_w = 18, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 39618, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 39718, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 39804, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 39899, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 39999, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 40090, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 40181, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 40267, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 40367, .adv_w = 320, .box_w = 18, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 40457, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 40557, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 40643, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 40734, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 40829, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 40924, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 41019, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 41114, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 41200, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 41286, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 41376, .adv_w = 320, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 41461, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 41551, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 41637, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 41718, .adv_w = 320, .box_w = 16, .box_h = 19, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 41794, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 2, .ofs_y = -1},
- {.bitmap_index = 41875, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 41961, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 42052, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 42147, .adv_w = 320, .box_w = 15, .box_h = 19, .ofs_x = 3, .ofs_y = -2},
- {.bitmap_index = 42219, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 42305, .adv_w = 320, .box_w = 14, .box_h = 17, .ofs_x = 3, .ofs_y = -1},
- {.bitmap_index = 42365, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 42455, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 42546, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 42637, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 42723, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 42818, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 42913, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 43008, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 43094, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 43194, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 43289, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 43380, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 43471, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 43566, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 43666, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 43752, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 43847, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 43938, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 44029, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 44124, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 44215, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 44315, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 44410, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 44505, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 44586, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 44667, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 44762, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 44848, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 44939, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 45034, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 45134, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 45229, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 45319, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 45410, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 45505, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 45600, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 45695, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 45786, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 25729, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 25815, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 25905, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 25996, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 26082, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 26182, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 26273, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 26359, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 26454, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 26544, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 26625, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 26720, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 26815, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 26910, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 27010, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 27101, .adv_w = 320, .box_w = 17, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 27182, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 27282, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 27373, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 27464, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 27559, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 27649, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 27749, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 27849, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 27935, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 28025, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 28120, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 28220, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 28315, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 28406, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 28501, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 28592, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 28682, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 28773, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 28868, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 28963, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 29058, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 29158, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 29253, .adv_w = 320, .box_w = 20, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 29358, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 29453, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 29553, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 29653, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 29753, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 29853, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 29948, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 30048, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 30148, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 30243, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 30334, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 30429, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 30529, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 30629, .adv_w = 320, .box_w = 20, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 30734, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 30829, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 30924, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 31019, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 31114, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 31205, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 31296, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 31391, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 31486, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 31581, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 31676, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 31771, .adv_w = 320, .box_w = 20, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 31876, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 31971, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 32061, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 32156, .adv_w = 320, .box_w = 19, .box_h = 21, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 32256, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 32351, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 32446, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 32537, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 32627, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 32713, .adv_w = 320, .box_w = 14, .box_h = 18, .ofs_x = 3, .ofs_y = -2},
+ {.bitmap_index = 32776, .adv_w = 320, .box_w = 18, .box_h = 17, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 32853, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 32944, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 33025, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 33111, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 33202, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 33292, .adv_w = 320, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 33377, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 33472, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 33563, .adv_w = 320, .box_w = 18, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 33653, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 33753, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 33843, .adv_w = 320, .box_w = 16, .box_h = 20, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 33923, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 34018, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 34109, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 34209, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 34295, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 34386, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 34481, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 34576, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 34671, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 34771, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 34871, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 34966, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 35061, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 35156, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 35251, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 35346, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 35436, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 35531, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 35626, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 35716, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 35811, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 35911, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 36011, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 36111, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 36211, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 36306, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 36401, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 36496, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 36596, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 36696, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 36791, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 36886, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 36986, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 37072, .adv_w = 320, .box_w = 19, .box_h = 17, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 37153, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 37248, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 37339, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 37434, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 37525, .adv_w = 320, .box_w = 20, .box_h = 21, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 37630, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 37716, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 37811, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 37906, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 38006, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 38096, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 38191, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 38282, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 38377, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 38472, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 38567, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 38662, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 38757, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 38852, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 38943, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 39038, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 39138, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 39229, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 39329, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 39419, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 39514, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 39614, .adv_w = 320, .box_w = 18, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 39704, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 39804, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 39890, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 39985, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 40085, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 40176, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 40267, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 40353, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 40453, .adv_w = 320, .box_w = 18, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 40543, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 40643, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 40729, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 40820, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 40915, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 41010, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 41105, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 41200, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 41286, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 41372, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 41462, .adv_w = 320, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 41547, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 41637, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 41723, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 41804, .adv_w = 320, .box_w = 16, .box_h = 19, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 41880, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 2, .ofs_y = -1},
+ {.bitmap_index = 41961, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 42047, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 42138, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 42233, .adv_w = 320, .box_w = 15, .box_h = 19, .ofs_x = 3, .ofs_y = -2},
+ {.bitmap_index = 42305, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 42391, .adv_w = 320, .box_w = 14, .box_h = 17, .ofs_x = 3, .ofs_y = -1},
+ {.bitmap_index = 42451, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 42541, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 42632, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 42723, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 42809, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 42904, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 42999, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 43094, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 43180, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 43280, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 43375, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 43466, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 43557, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 43652, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 43752, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 43838, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 43933, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 44024, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 44115, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 44210, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 44301, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 44401, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 44496, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 44591, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 44672, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 44753, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 44848, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 44934, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 45025, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 45120, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 45220, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 45315, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 45405, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 45496, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 45591, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 45686, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 45781, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
{.bitmap_index = 45872, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 45958, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 46049, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 46144, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 46239, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 46330, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 46420, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 46506, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 46606, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 46701, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 46801, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 46896, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 46991, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 47077, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 47172, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 47267, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 47362, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 47448, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 47543, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 47638, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 47719, .adv_w = 320, .box_w = 17, .box_h = 18, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 47796, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 47877, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 47968, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 48054, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 48145, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 48236, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 48322, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 48422, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 48517, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 48612, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 48707, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 48802, .adv_w = 320, .box_w = 15, .box_h = 19, .ofs_x = 3, .ofs_y = -2},
- {.bitmap_index = 48874, .adv_w = 320, .box_w = 18, .box_h = 17, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 48951, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 49046, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 49137, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 49223, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 49314, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 49409, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 49504, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 49599, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 49694, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 49794, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 49889, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 49984, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 50084, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 50179, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 50274, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 50369, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 50450, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 50536, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 50622, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 50712, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 50807, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 50893, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 50993, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 51084, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 51179, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 51274, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 51369, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 51460, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 51555, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 51645, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 51740, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 51831, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 51926, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 52012, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 52103, .adv_w = 320, .box_w = 18, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 52193, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 52284, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 52379, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 52479, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 52574, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 52665, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 52756, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 52847, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 52942, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 53028, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 53119, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 53210, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 53296, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 53387, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 53478, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 53573, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 53668, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 53759, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 53854, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 53945, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 54036, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 54131, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 54231, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 54326, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 54421, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 54516, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 54606, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 54701, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 54801, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 54892, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 54987, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 55087, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 55177, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 55268, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 55363, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 55458, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 55553, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 55648, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 55743, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 55838, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 55928, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 56023, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 56118, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 56213, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 56313, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 56408, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 56508, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 56608, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 56703, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 56798, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 56893, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 56988, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 57083, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 57178, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 57273, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 57368, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 57463, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 57558, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 57653, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 57739, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 57825, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 57920, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 58006, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 58097, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 58192, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 58287, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 58378, .adv_w = 320, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 58463, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 58553, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 58644, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 58735, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 58830, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 58920, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 59020, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 59115, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 59210, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 59305, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 59400, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 59491, .adv_w = 320, .box_w = 18, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 59581, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 59667, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 59753, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 59839, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 59925, .adv_w = 320, .box_w = 18, .box_h = 20, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 60015, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 60110, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 60205, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 60300, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 60391, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 60482, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 60568, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 60663, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 60758, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 60849, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 60944, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 61034, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 61120, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 61215, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 61306, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 61387, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 61468, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 61558, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 61653, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 61744, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 61839, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 61934, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 62029, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 62119, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 62205, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 62305, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 62400, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 62491, .adv_w = 320, .box_w = 18, .box_h = 20, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 45958, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 46044, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 46135, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 46230, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 46325, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 46416, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 46506, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 46592, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 46692, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 46787, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 46887, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 46982, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 47077, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 47163, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 47258, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 47353, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 47448, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 47534, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 47629, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 47724, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 47805, .adv_w = 320, .box_w = 17, .box_h = 18, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 47882, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 47963, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 48054, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 48140, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 48231, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 48322, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 48408, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 48508, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 48603, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 48698, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 48793, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 48888, .adv_w = 320, .box_w = 15, .box_h = 19, .ofs_x = 3, .ofs_y = -2},
+ {.bitmap_index = 48960, .adv_w = 320, .box_w = 18, .box_h = 17, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 49037, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 49132, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 49223, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 49309, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 49400, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 49495, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 49590, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 49685, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 49780, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 49880, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 49975, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 50070, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 50170, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 50265, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 50360, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 50455, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 50536, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 50622, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 50708, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 50798, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 50893, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 50979, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 51079, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 51170, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 51265, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 51360, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 51455, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 51546, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 51641, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 51731, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 51826, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 51917, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 52012, .adv_w = 320, .box_w = 19, .box_h = 18, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 52098, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 52189, .adv_w = 320, .box_w = 18, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 52279, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 52370, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 52465, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 52565, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 52660, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 52751, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 52842, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 52933, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 53028, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 53114, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 53205, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 53296, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 53382, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 53473, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 53564, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 53659, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 53754, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 53845, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 53940, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 54031, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 54122, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 54217, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 54317, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 54412, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 54507, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 54602, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 54692, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 54787, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 54887, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 54978, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 55073, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 55173, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 55263, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 55354, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 55449, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 55544, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 55639, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 55734, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 55829, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 55924, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 56014, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 56109, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 56204, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 56299, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 56394, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 56494, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 56589, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 56689, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 56789, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 56884, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 56979, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 57074, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 57169, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 57264, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 57359, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 57454, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 57549, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 57644, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 57739, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 57834, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 57920, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 58006, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 58101, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 58187, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 58278, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 58373, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 58468, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 58559, .adv_w = 320, .box_w = 20, .box_h = 17, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 58644, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 58734, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 58825, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 58916, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 59011, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 59101, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 59201, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 59296, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 59391, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 59486, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 59581, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 59672, .adv_w = 320, .box_w = 18, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 59762, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 59848, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 59934, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 60020, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 60106, .adv_w = 320, .box_w = 18, .box_h = 20, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 60196, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 60291, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 60386, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 60481, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 60576, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 60667, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 60758, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 60844, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 60939, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 61034, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 61125, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 61220, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 61310, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 61396, .adv_w = 320, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 61491, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 61582, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 61663, .adv_w = 320, .box_w = 18, .box_h = 18, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 61744, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 61834, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 61929, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 62020, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 62115, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 62210, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 62305, .adv_w = 320, .box_w = 20, .box_h = 18, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 62395, .adv_w = 320, .box_w = 18, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 62481, .adv_w = 320, .box_w = 20, .box_h = 20, .ofs_x = 0, .ofs_y = -3},
{.bitmap_index = 62581, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 62676, .adv_w = 320, .box_w = 7, .box_h = 20, .ofs_x = 13, .ofs_y = -2},
- {.bitmap_index = 62711, .adv_w = 320, .box_w = 7, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 62746, .adv_w = 320, .box_w = 5, .box_h = 8, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 62756, .adv_w = 320, .box_w = 4, .box_h = 14, .ofs_x = 3, .ofs_y = -1},
- {.bitmap_index = 62770, .adv_w = 320, .box_w = 5, .box_h = 17, .ofs_x = 2, .ofs_y = -4},
- {.bitmap_index = 62792, .adv_w = 320, .box_w = 10, .box_h = 17, .ofs_x = 0, .ofs_y = -1}
+ {.bitmap_index = 62676, .adv_w = 320, .box_w = 19, .box_h = 19, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 62767, .adv_w = 320, .box_w = 18, .box_h = 20, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 62857, .adv_w = 320, .box_w = 20, .box_h = 19, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 62952, .adv_w = 320, .box_w = 7, .box_h = 20, .ofs_x = 13, .ofs_y = -2},
+ {.bitmap_index = 62987, .adv_w = 320, .box_w = 7, .box_h = 20, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 63022, .adv_w = 320, .box_w = 5, .box_h = 8, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 63032, .adv_w = 320, .box_w = 4, .box_h = 14, .ofs_x = 3, .ofs_y = -1},
+ {.bitmap_index = 63046, .adv_w = 320, .box_w = 5, .box_h = 17, .ofs_x = 2, .ofs_y = -4},
+ {.bitmap_index = 63068, .adv_w = 320, .box_w = 10, .box_h = 17, .ofs_x = 0, .ofs_y = -1}
};
/*---------------------
@@ -10480,57 +10524,58 @@ static const uint16_t unicode_list_2[] = {
0x5e03, 0x5e57, 0x5e5d, 0x5e5f, 0x5e6c, 0x5e72, 0x5e8e, 0x5e97,
0x5eb0, 0x5eb2, 0x5ebf, 0x5ece, 0x5ed9, 0x5edd, 0x5ee1, 0x5ee2,
0x5ee8, 0x5ef4, 0x5f07, 0x5f0b, 0x5f20, 0x5f22, 0x5f34, 0x5f35,
- 0x5f48, 0x5f5e, 0x5f84, 0x5f98, 0x5fbf, 0x5fcc, 0x6005, 0x6022,
- 0x6050, 0x606c, 0x607c, 0x60ab, 0x616d, 0x616e, 0x6173, 0x6194,
- 0x619d, 0x61a8, 0x61aa, 0x61b0, 0x61b5, 0x61c4, 0x61c6, 0x61c8,
- 0x61d6, 0x61db, 0x61dd, 0x61f2, 0x6201, 0x6209, 0x6219, 0x6222,
- 0x6242, 0x6246, 0x6249, 0x624a, 0x625e, 0x6264, 0x6266, 0x628c,
- 0x62bc, 0x62bf, 0x62cb, 0x62d4, 0x62e5, 0x6302, 0x6305, 0x6314,
- 0x632c, 0x632d, 0x632f, 0x63a1, 0x6401, 0x640a, 0x642a, 0x6443,
- 0x648c, 0x6493, 0x6496, 0x6498, 0x649b, 0x649c, 0x64a5, 0x64ac,
- 0x64b6, 0x64cd, 0x64d1, 0x64e4, 0x650a, 0x650d, 0x6516, 0x651e,
- 0x653d, 0x653f, 0x6542, 0x6543, 0x6553, 0x656b, 0x6570, 0x657d,
- 0x658c, 0x659b, 0x65cc, 0x65cd, 0x65d7, 0x6611, 0x6651, 0x665b,
- 0x665d, 0x6666, 0x666a, 0x6678, 0x667c, 0x6687, 0x6689, 0x668c,
- 0x6697, 0x66a0, 0x66be, 0x66c2, 0x66db, 0x66e1, 0x66ed, 0x66f9,
- 0x6713, 0x672d, 0x6742, 0x6764, 0x677e, 0x6795, 0x6796, 0x6799,
- 0x67a3, 0x67a5, 0x681d, 0x68df, 0x697e, 0x6a7e, 0x6a7f, 0x6a9b,
- 0x6abf, 0x6ac0, 0x6ac1, 0x6ac2, 0x6b12, 0x6b2a, 0x6b2c, 0x6b31,
- 0x6b71, 0x6b95, 0x6b9f, 0x6bbd, 0x6bfe, 0x6c32, 0x6c38, 0x6c45,
- 0x6c7b, 0x6c9b, 0x6c9e, 0x6ca8, 0x6ce5, 0x6ce6, 0x6d58, 0x6d62,
- 0x6d7e, 0x6d8c, 0x6ddc, 0x6ded, 0x6e0c, 0x6e2e, 0x6e3e, 0x6e6c,
- 0x6eb9, 0x7016, 0x7093, 0x70c4, 0x7112, 0x71a4, 0x71a5, 0x71bf,
- 0x71c6, 0x71d6, 0x7213, 0x7249, 0x7279, 0x72e4, 0x730c, 0x730d,
- 0x7363, 0x7461, 0x747c, 0x7485, 0x748e, 0x7492, 0x74b6, 0x74c2,
- 0x74ee, 0x75da, 0x75e1, 0x764b, 0x7651, 0x7655, 0x7668, 0x767c,
- 0x769d, 0x7742, 0x774a, 0x775e, 0x7791, 0x77c9, 0x77cb, 0x7897,
- 0x78c5, 0x78de, 0x7918, 0x791e, 0x792a, 0x792f, 0x794c, 0x794d,
- 0x7958, 0x7968, 0x796a, 0x79d7, 0x7a28, 0x7a36, 0x7a71, 0x7a83,
- 0x7a89, 0x7aa6, 0x7ab3, 0x7adb, 0x7add, 0x7af4, 0x7afe, 0x7b3e,
- 0x7bd8, 0x7c58, 0x7c7f, 0x7e03, 0x7e04, 0x7e16, 0x7e1c, 0x7e21,
- 0x7e23, 0x7e25, 0x7e2c, 0x7e36, 0x7e39, 0x7e3c, 0x7e44, 0x7e4a,
- 0x7e51, 0x7e63, 0x7e73, 0x7e7a, 0x7e97, 0x7eae, 0x7eb4, 0x7ecb,
- 0x7ecf, 0x7f5e, 0x7f60, 0x7f62, 0x7f69, 0x7fb1, 0x7ffe, 0x801e,
- 0x805a, 0x806e, 0x8147, 0x8150, 0x8151, 0x81df, 0x820c, 0x8242,
- 0x824e, 0x82ad, 0x830e, 0x8314, 0x852c, 0x85ae, 0x87a9, 0x87aa,
- 0x87c5, 0x8808, 0x8822, 0x88dc, 0x88de, 0x891e, 0x891f, 0x8921,
- 0x8926, 0x8940, 0x895d, 0x8ac3, 0x8afe, 0x8b01, 0x8b06, 0x8b0b,
- 0x8b0d, 0x8b15, 0x8b1b, 0x8b1c, 0x8b1e, 0x8b23, 0x8b2a, 0x8b32,
- 0x8b42, 0x8b43, 0x8b4a, 0x8b4c, 0x8b51, 0x8b54, 0x8b58, 0x8b60,
- 0x8b85, 0x8bbe, 0x8c7c, 0x8c7f, 0x8c80, 0x8c82, 0x8c83, 0x8c84,
- 0x8c85, 0x8c96, 0x8ca1, 0x8ca9, 0x8cb1, 0x8cd4, 0x8ce2, 0x8ce7,
- 0x8d10, 0x8d4c, 0x8d50, 0x8e08, 0x8ec9, 0x8ecc, 0x8ed8, 0x8eda,
- 0x8ee0, 0x8ef0, 0x8ef3, 0x8f1b, 0x8f24, 0x8f2b, 0x8f2d, 0x8f31,
- 0x8f36, 0x8f38, 0x8f3b, 0x8f4d, 0x8f5a, 0x8f5e, 0x8f5f, 0x8f63,
- 0x8f66, 0x8f71, 0x8f77, 0x8f7c, 0x8f7d, 0x8fa4, 0x8fd2, 0x8fdc,
- 0x8fdd, 0x900b, 0x9045, 0x905a, 0x90a9, 0x90aa, 0x9124, 0x9127,
- 0x912a, 0x912c, 0x912e, 0x93fc, 0x9402, 0x940b, 0x940e, 0x9455,
- 0x945b, 0x945d, 0x945e, 0x9476, 0x94dc, 0x9545, 0x954a, 0x954b,
- 0x9551, 0x9562, 0x957c, 0x958f, 0x95ad, 0x95c1, 0x95c6, 0x95ec,
- 0x95ed, 0x95f1, 0x95f6, 0x95f9, 0x961b, 0x9653, 0x965d, 0x968f,
- 0x96bb, 0x96bf, 0x97d2, 0x97d6, 0x97d7, 0x97d8, 0x97e1, 0x97f5,
- 0x97fa, 0x982b, 0x98f3, 0x98f6, 0x99e9, 0x9a0d, 0x9a35, 0x9e35,
- 0xfe65, 0xfe66, 0xfe69, 0xfe77, 0xfe78, 0xfe7c
+ 0x5f48, 0x5f5a, 0x5f5e, 0x5f84, 0x5f98, 0x5fbf, 0x5fcc, 0x6005,
+ 0x6022, 0x6050, 0x606c, 0x607c, 0x60ab, 0x616d, 0x616e, 0x6173,
+ 0x6194, 0x619d, 0x61a8, 0x61aa, 0x61b0, 0x61b5, 0x61c4, 0x61c6,
+ 0x61c8, 0x61d6, 0x61db, 0x61dd, 0x61f2, 0x6201, 0x6209, 0x6219,
+ 0x6222, 0x6242, 0x6246, 0x6249, 0x624a, 0x625e, 0x6264, 0x6266,
+ 0x628c, 0x62bc, 0x62bf, 0x62cb, 0x62d4, 0x62e5, 0x6302, 0x6305,
+ 0x6314, 0x632c, 0x632d, 0x632f, 0x63a1, 0x6401, 0x640a, 0x642a,
+ 0x6443, 0x648c, 0x6493, 0x6496, 0x6498, 0x649b, 0x649c, 0x64a5,
+ 0x64ac, 0x64b6, 0x64cd, 0x64d1, 0x64e4, 0x650a, 0x650d, 0x6516,
+ 0x651e, 0x653d, 0x653f, 0x6542, 0x6543, 0x6553, 0x656b, 0x6570,
+ 0x657d, 0x658c, 0x659b, 0x65cc, 0x65cd, 0x65d7, 0x6611, 0x6651,
+ 0x665b, 0x665d, 0x6666, 0x666a, 0x6678, 0x667c, 0x6687, 0x6689,
+ 0x668c, 0x6697, 0x66a0, 0x66be, 0x66c2, 0x66db, 0x66e1, 0x66ed,
+ 0x66f9, 0x6713, 0x672d, 0x6742, 0x6764, 0x677e, 0x6795, 0x6796,
+ 0x6799, 0x67a3, 0x67a5, 0x681d, 0x68df, 0x697e, 0x6a7e, 0x6a7f,
+ 0x6a9b, 0x6abf, 0x6ac0, 0x6ac1, 0x6ac2, 0x6b12, 0x6b2a, 0x6b2c,
+ 0x6b31, 0x6b71, 0x6b95, 0x6b9f, 0x6bbd, 0x6bfe, 0x6c32, 0x6c38,
+ 0x6c45, 0x6c7b, 0x6c9b, 0x6c9e, 0x6ca8, 0x6ce5, 0x6ce6, 0x6d58,
+ 0x6d62, 0x6d7e, 0x6d8c, 0x6ddc, 0x6ded, 0x6e0c, 0x6e2e, 0x6e3e,
+ 0x6e6c, 0x6eb9, 0x7016, 0x7093, 0x70c4, 0x7112, 0x71a4, 0x71a5,
+ 0x71bf, 0x71c6, 0x71d6, 0x7213, 0x7249, 0x7279, 0x72e4, 0x730c,
+ 0x730d, 0x7363, 0x7461, 0x747c, 0x7485, 0x748e, 0x7492, 0x74b6,
+ 0x74c2, 0x74ee, 0x75da, 0x75e1, 0x764b, 0x7651, 0x7655, 0x7668,
+ 0x767c, 0x769d, 0x7742, 0x774a, 0x775e, 0x7791, 0x77c9, 0x77cb,
+ 0x7897, 0x78c5, 0x78de, 0x7918, 0x791e, 0x792a, 0x792f, 0x794c,
+ 0x794d, 0x7958, 0x7968, 0x796a, 0x79d7, 0x7a28, 0x7a36, 0x7a71,
+ 0x7a83, 0x7a89, 0x7aa6, 0x7ab3, 0x7adb, 0x7add, 0x7af4, 0x7afe,
+ 0x7b3e, 0x7bd8, 0x7c58, 0x7c7f, 0x7e03, 0x7e04, 0x7e16, 0x7e1c,
+ 0x7e21, 0x7e23, 0x7e25, 0x7e2c, 0x7e36, 0x7e39, 0x7e3c, 0x7e44,
+ 0x7e4a, 0x7e51, 0x7e63, 0x7e73, 0x7e7a, 0x7e97, 0x7eae, 0x7eb4,
+ 0x7ecb, 0x7ecf, 0x7f5e, 0x7f60, 0x7f62, 0x7f69, 0x7fb1, 0x7ffe,
+ 0x801e, 0x805a, 0x806e, 0x8147, 0x8150, 0x8151, 0x81df, 0x820c,
+ 0x8242, 0x824e, 0x82ad, 0x830e, 0x8314, 0x852c, 0x85ae, 0x87a9,
+ 0x87aa, 0x87c5, 0x8808, 0x8822, 0x88dc, 0x88de, 0x891e, 0x891f,
+ 0x8921, 0x8926, 0x8940, 0x895d, 0x8ac3, 0x8afe, 0x8b01, 0x8b06,
+ 0x8b0b, 0x8b0d, 0x8b15, 0x8b1b, 0x8b1c, 0x8b1e, 0x8b23, 0x8b2a,
+ 0x8b32, 0x8b42, 0x8b43, 0x8b4a, 0x8b4c, 0x8b51, 0x8b54, 0x8b58,
+ 0x8b60, 0x8b85, 0x8bbe, 0x8c7c, 0x8c7f, 0x8c80, 0x8c82, 0x8c83,
+ 0x8c84, 0x8c85, 0x8c96, 0x8ca1, 0x8ca9, 0x8cb1, 0x8cd4, 0x8ce2,
+ 0x8ce7, 0x8d10, 0x8d4c, 0x8d50, 0x8e08, 0x8ec9, 0x8ecc, 0x8ed8,
+ 0x8eda, 0x8ee0, 0x8ef0, 0x8ef3, 0x8f1b, 0x8f24, 0x8f2b, 0x8f2d,
+ 0x8f2e, 0x8f31, 0x8f36, 0x8f38, 0x8f3b, 0x8f4d, 0x8f5a, 0x8f5e,
+ 0x8f5f, 0x8f63, 0x8f66, 0x8f71, 0x8f77, 0x8f7c, 0x8f7d, 0x8fa4,
+ 0x8fd2, 0x8fdc, 0x8fdd, 0x900b, 0x9045, 0x905a, 0x90a9, 0x90aa,
+ 0x9124, 0x9127, 0x912a, 0x912c, 0x912e, 0x93fc, 0x9402, 0x940b,
+ 0x940e, 0x9455, 0x945b, 0x945d, 0x945e, 0x9476, 0x94dc, 0x9545,
+ 0x954a, 0x954b, 0x9551, 0x9562, 0x957c, 0x958f, 0x95a1, 0x95ad,
+ 0x95c1, 0x95c6, 0x95ec, 0x95ed, 0x95f1, 0x95f6, 0x95f9, 0x961b,
+ 0x9653, 0x965d, 0x968f, 0x96bb, 0x96bf, 0x97d2, 0x97d6, 0x97d7,
+ 0x97d8, 0x97e1, 0x97f5, 0x97fa, 0x982b, 0x98f3, 0x98f6, 0x99e9,
+ 0x9a0d, 0x9a35, 0x9e35, 0xfe65, 0xfe66, 0xfe69, 0xfe77, 0xfe78,
+ 0xfe7c
};
/*Collect the unicode lists and glyph_id offsets*/
@@ -10546,7 +10591,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
},
{
.range_start = 163, .range_length = 65149, .glyph_id_start = 95,
- .unicode_list = unicode_list_2, .glyph_id_ofs_list = NULL, .list_length = 662, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
+ .unicode_list = unicode_list_2, .glyph_id_ofs_list = NULL, .list_length = 665, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
}
};
@@ -10652,7 +10697,7 @@ static const uint8_t kern_left_class_mapping[] =
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0
};
/*Map glyph_ids to kern right classes*/
@@ -10752,7 +10797,7 @@ static const uint8_t kern_right_class_mapping[] =
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0
};
/*Kern values between classes*/
### src/ui/gui_assets/font/cn/cnLittleTitle.c
@@ -1,7 +1,7 @@
/*******************************************************************************
* Size: 28 px
* Bpp: 1
- * Opts: --bpp 1 --size 28 --no-compress --font NotoSansSC-Regular.ttf --symbols !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~£¥·€一不专个中为二些交产们件份传低住何使保信修免入全公再准出分创初删利到制功加务动助包化匹升卡取受可合名吗启告周和品围固在地址型基境声备复多失如始子存安完密导将尝屏展已常幕序建开异式弱径志忘态恢息您意成我或所扩扫护持指接掷描擦支收改效数文断新无日明易更最有服未本术机权条查标格检模次款止正此求法注派测消添源片版状环生用电的相知短石码确禁种程站签类系级纹组络维网置联致行要解言警认议记设证词试语误请责败超路输达过这进连通配重量钥钱锁错限除险需页风首验骰 --format lvgl -o ../gui_assets/font/cn/cnLittleTitle.c
+ * Opts: --bpp 1 --size 28 --no-compress --font NotoSansSC-Regular.ttf --symbols !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~£¥·€一不专个中为二些交产们件份传低住何使保信修免入全公再准出分创初删利到制功加务动助包化匹升卡取受可合名吗启告周和品围固在地址型基境声备复多失如始子存安完密导将尝屏展已常幕序建开异式弱径志忘态恢息您意成我或所扩扫护持指接掷描擦支收改效数整文断新无日明易更最有服未本术机权条来查标格检模次款止正此求法注派测消添源片版状环生用电的相知短石码确禁种程站签类系级纹组络维网置联致行要解言警认议记设证词试语误请责败超路输达过这进连通配重量钥钱锁错限除险需页风首验骰 --format lvgl -o ../gui_assets/font/cn/cnLittleTitle.c
******************************************************************************/
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
@@ -2059,6 +2059,19 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
0x7e, 0x1c, 0xe0, 0x79, 0xce, 0x1c, 0x7c, 0xf,
0x3, 0xfc, 0x3, 0x80, 0x60, 0x0, 0x0, 0x0,
+ /* U+6574 "整" */
+ 0x3, 0x0, 0x40, 0x0, 0xc0, 0x30, 0x7, 0xff,
+ 0x8c, 0x0, 0xc, 0x7, 0xff, 0x7f, 0xf3, 0x83,
+ 0x18, 0xcc, 0xf1, 0x86, 0x33, 0x7c, 0x61, 0x8c,
+ 0xc9, 0xb0, 0x7f, 0xf0, 0x3c, 0x1, 0xe0, 0xe,
+ 0x0, 0xfe, 0x7, 0xc0, 0x6c, 0xc7, 0xb8, 0x73,
+ 0x17, 0x83, 0xd0, 0xc0, 0x80, 0x63, 0xff, 0xff,
+ 0xf0, 0xff, 0xff, 0xfc, 0x0, 0xc, 0x0, 0x0,
+ 0x3, 0x0, 0x0, 0x60, 0xc0, 0x0, 0x18, 0x3f,
+ 0xf0, 0x6, 0xc, 0x0, 0x1, 0x83, 0x0, 0x0,
+ 0x60, 0xc0, 0x3, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xc0,
+
/* U+6587 "文" */
0x0, 0x38, 0x0, 0x0, 0xc, 0x0, 0x0, 0x7,
0x0, 0x0, 0x1, 0x80, 0x0, 0x0, 0xc0, 0x7,
@@ -2269,6 +2282,19 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
0xc0, 0xc1, 0xc0, 0xe0, 0x30, 0x38, 0x10, 0x7c,
0x6, 0x0, 0x1e, 0x0, 0x0,
+ /* U+6765 "来" */
+ 0x0, 0xc, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0,
+ 0xc0, 0x0, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff,
+ 0x0, 0x3, 0x0, 0x0, 0xe0, 0xc0, 0xc0, 0x18,
+ 0x30, 0x70, 0x3, 0xc, 0x18, 0x0, 0xc3, 0xc,
+ 0x0, 0x38, 0xc3, 0x0, 0x0, 0x30, 0x80, 0x7f,
+ 0xff, 0xff, 0x9f, 0xff, 0xff, 0xe0, 0x3, 0xf0,
+ 0x0, 0x1, 0xfe, 0x0, 0x0, 0xed, 0xc0, 0x0,
+ 0x73, 0x38, 0x0, 0x38, 0xc7, 0x0, 0x1c, 0x30,
+ 0xe0, 0x1e, 0xc, 0x1e, 0x1e, 0x3, 0x1, 0xef,
+ 0x0, 0xc0, 0x3d, 0x0, 0x30, 0x2, 0x0, 0xc,
+ 0x0, 0x0,
+
/* U+67E5 "查" */
0x0, 0xc, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0,
0xc0, 0x0, 0x0, 0x30, 0x0, 0x7f, 0xff, 0xff,
@@ -3617,113 +3643,115 @@ static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
{.bitmap_index = 11911, .adv_w = 448, .box_w = 25, .box_h = 26, .ofs_x = 2, .ofs_y = -2},
{.bitmap_index = 11993, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 0, .ofs_y = -3},
{.bitmap_index = 12078, .adv_w = 448, .box_w = 26, .box_h = 27, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 12166, .adv_w = 448, .box_w = 25, .box_h = 26, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 12166, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
{.bitmap_index = 12248, .adv_w = 448, .box_w = 25, .box_h = 26, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 12330, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 12412, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 12494, .adv_w = 448, .box_w = 18, .box_h = 24, .ofs_x = 5, .ofs_y = -2},
- {.bitmap_index = 12548, .adv_w = 448, .box_w = 23, .box_h = 25, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 12620, .adv_w = 448, .box_w = 24, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 12692, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 12770, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 12848, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 12933, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 13011, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 13096, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 13181, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 13263, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 13348, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 13433, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 13518, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 13600, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 13685, .adv_w = 448, .box_w = 27, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 13773, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 13858, .adv_w = 448, .box_w = 27, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 13943, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 14028, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 14113, .adv_w = 448, .box_w = 25, .box_h = 24, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 14188, .adv_w = 448, .box_w = 25, .box_h = 23, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 14260, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 14345, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 14430, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 14515, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 14600, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 14682, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 14764, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 14843, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 14925, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 15007, .adv_w = 448, .box_w = 24, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 15082, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 15164, .adv_w = 448, .box_w = 27, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 15249, .adv_w = 448, .box_w = 25, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 15324, .adv_w = 448, .box_w = 24, .box_h = 24, .ofs_x = 2, .ofs_y = -1},
- {.bitmap_index = 15396, .adv_w = 448, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 15468, .adv_w = 448, .box_w = 23, .box_h = 25, .ofs_x = 4, .ofs_y = -2},
- {.bitmap_index = 15540, .adv_w = 448, .box_w = 23, .box_h = 26, .ofs_x = 3, .ofs_y = -2},
- {.bitmap_index = 15615, .adv_w = 448, .box_w = 25, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 15697, .adv_w = 448, .box_w = 24, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 15775, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 15853, .adv_w = 448, .box_w = 25, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 15925, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 16003, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 16082, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 16167, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 16249, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 16331, .adv_w = 448, .box_w = 25, .box_h = 26, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 16413, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 16498, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 16580, .adv_w = 448, .box_w = 24, .box_h = 25, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 16655, .adv_w = 448, .box_w = 27, .box_h = 27, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 16747, .adv_w = 448, .box_w = 27, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 16832, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 16911, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 16996, .adv_w = 448, .box_w = 25, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 17078, .adv_w = 448, .box_w = 23, .box_h = 24, .ofs_x = 3, .ofs_y = -2},
- {.bitmap_index = 17147, .adv_w = 448, .box_w = 24, .box_h = 24, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 17219, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 17301, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 17386, .adv_w = 448, .box_w = 27, .box_h = 26, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 17474, .adv_w = 448, .box_w = 25, .box_h = 26, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 17556, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 17641, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 12330, .adv_w = 448, .box_w = 25, .box_h = 26, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 12412, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 12494, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 12576, .adv_w = 448, .box_w = 18, .box_h = 24, .ofs_x = 5, .ofs_y = -2},
+ {.bitmap_index = 12630, .adv_w = 448, .box_w = 23, .box_h = 25, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 12702, .adv_w = 448, .box_w = 24, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 12774, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 12852, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 12930, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 13015, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 13093, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 13178, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 13263, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 13345, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 13430, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 13515, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 13600, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 13682, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 13764, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 13849, .adv_w = 448, .box_w = 27, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 13937, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 14022, .adv_w = 448, .box_w = 27, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 14107, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 14192, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 14277, .adv_w = 448, .box_w = 25, .box_h = 24, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 14352, .adv_w = 448, .box_w = 25, .box_h = 23, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 14424, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 14509, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 14594, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 14679, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 14764, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 14846, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 14928, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 15007, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 15089, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 15171, .adv_w = 448, .box_w = 24, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 15246, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 15328, .adv_w = 448, .box_w = 27, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 15413, .adv_w = 448, .box_w = 25, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 15488, .adv_w = 448, .box_w = 24, .box_h = 24, .ofs_x = 2, .ofs_y = -1},
+ {.bitmap_index = 15560, .adv_w = 448, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 15632, .adv_w = 448, .box_w = 23, .box_h = 25, .ofs_x = 4, .ofs_y = -2},
+ {.bitmap_index = 15704, .adv_w = 448, .box_w = 23, .box_h = 26, .ofs_x = 3, .ofs_y = -2},
+ {.bitmap_index = 15779, .adv_w = 448, .box_w = 25, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 15861, .adv_w = 448, .box_w = 24, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 15939, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 16017, .adv_w = 448, .box_w = 25, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 16089, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 16167, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 16246, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 16331, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 16413, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 16495, .adv_w = 448, .box_w = 25, .box_h = 26, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 16577, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 16662, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 16744, .adv_w = 448, .box_w = 24, .box_h = 25, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 16819, .adv_w = 448, .box_w = 27, .box_h = 27, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 16911, .adv_w = 448, .box_w = 27, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 16996, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 17075, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 17160, .adv_w = 448, .box_w = 25, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 17242, .adv_w = 448, .box_w = 23, .box_h = 24, .ofs_x = 3, .ofs_y = -2},
+ {.bitmap_index = 17311, .adv_w = 448, .box_w = 24, .box_h = 24, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 17383, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 17465, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 17550, .adv_w = 448, .box_w = 27, .box_h = 26, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 17638, .adv_w = 448, .box_w = 25, .box_h = 26, .ofs_x = 2, .ofs_y = -3},
{.bitmap_index = 17720, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 17805, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 17890, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 17972, .adv_w = 448, .box_w = 25, .box_h = 24, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 18047, .adv_w = 448, .box_w = 26, .box_h = 27, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 18135, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 18213, .adv_w = 448, .box_w = 24, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 18288, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 18370, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 18452, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 18537, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 18619, .adv_w = 448, .box_w = 24, .box_h = 26, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 18697, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 18776, .adv_w = 448, .box_w = 27, .box_h = 26, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 18864, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 18949, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 19031, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 19110, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 19188, .adv_w = 448, .box_w = 25, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 19270, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 19348, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 19433, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 19511, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 19589, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 19668, .adv_w = 448, .box_w = 25, .box_h = 24, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 19743, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 19822, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 19904, .adv_w = 448, .box_w = 27, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 19989, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 20074, .adv_w = 448, .box_w = 24, .box_h = 24, .ofs_x = 3, .ofs_y = -2},
- {.bitmap_index = 20146, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 20228, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 20307, .adv_w = 448, .box_w = 24, .box_h = 25, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 20382, .adv_w = 448, .box_w = 25, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 20457, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 20535, .adv_w = 448, .box_w = 25, .box_h = 26, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 20617, .adv_w = 448, .box_w = 27, .box_h = 25, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 20702, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2}
+ {.bitmap_index = 17805, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 17884, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 17969, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 18054, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 18136, .adv_w = 448, .box_w = 25, .box_h = 24, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 18211, .adv_w = 448, .box_w = 26, .box_h = 27, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 18299, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 18377, .adv_w = 448, .box_w = 24, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 18452, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 18534, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 18616, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 18701, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 18783, .adv_w = 448, .box_w = 24, .box_h = 26, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 18861, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 18940, .adv_w = 448, .box_w = 27, .box_h = 26, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 19028, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 19113, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 19195, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 19274, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 19352, .adv_w = 448, .box_w = 25, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 19434, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 19512, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 19597, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 19675, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 19753, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 19832, .adv_w = 448, .box_w = 25, .box_h = 24, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 19907, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 19986, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 20068, .adv_w = 448, .box_w = 27, .box_h = 25, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 20153, .adv_w = 448, .box_w = 26, .box_h = 26, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 20238, .adv_w = 448, .box_w = 24, .box_h = 24, .ofs_x = 3, .ofs_y = -2},
+ {.bitmap_index = 20310, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 20392, .adv_w = 448, .box_w = 25, .box_h = 25, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 20471, .adv_w = 448, .box_w = 24, .box_h = 25, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 20546, .adv_w = 448, .box_w = 25, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 20621, .adv_w = 448, .box_w = 26, .box_h = 24, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 20699, .adv_w = 448, .box_w = 25, .box_h = 26, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 20781, .adv_w = 448, .box_w = 27, .box_h = 25, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 20866, .adv_w = 448, .box_w = 26, .box_h = 25, .ofs_x = 1, .ofs_y = -2}
};
/*---------------------
@@ -3746,20 +3774,20 @@ static const uint16_t unicode_list_2[] = {
0x5f35, 0x5f5e, 0x5fbf, 0x5fcc, 0x6005, 0x606c, 0x616d, 0x616e,
0x6173, 0x619d, 0x61c6, 0x61c8, 0x6201, 0x625e, 0x6264, 0x6302,
0x6314, 0x632c, 0x6443, 0x648c, 0x6493, 0x6496, 0x64a5, 0x64cd,
- 0x64e4, 0x650a, 0x650d, 0x653d, 0x6542, 0x656b, 0x6570, 0x6651,
- 0x665d, 0x6666, 0x666a, 0x6687, 0x6689, 0x668c, 0x6697, 0x66a0,
- 0x66be, 0x6742, 0x6764, 0x6799, 0x681d, 0x697e, 0x6a7e, 0x6a9b,
- 0x6abf, 0x6ac0, 0x6ac1, 0x6b9f, 0x6c32, 0x6c45, 0x6c9b, 0x6ca8,
- 0x6ce5, 0x6d58, 0x6ded, 0x71a4, 0x71a5, 0x7213, 0x730c, 0x747c,
- 0x7485, 0x7492, 0x75e1, 0x7655, 0x7742, 0x774a, 0x7750, 0x775e,
- 0x77cb, 0x78de, 0x792a, 0x7968, 0x7a36, 0x7adb, 0x7bd8, 0x7c58,
- 0x7e04, 0x7e16, 0x7e21, 0x7e39, 0x7e51, 0x7eae, 0x7ecb, 0x7fb1,
- 0x8151, 0x87a9, 0x88de, 0x8940, 0x895d, 0x8ac3, 0x8b01, 0x8b0b,
- 0x8b0d, 0x8b1b, 0x8b1e, 0x8b2a, 0x8b32, 0x8b4a, 0x8b4c, 0x8b54,
- 0x8c80, 0x8c82, 0x8ce2, 0x8d4c, 0x8ef0, 0x8f1b, 0x8f24, 0x8f36,
- 0x8f38, 0x8f3b, 0x8f77, 0x90aa, 0x912a, 0x912c, 0x9402, 0x940e,
- 0x945e, 0x9476, 0x95ad, 0x95c1, 0x95c6, 0x965d, 0x97d2, 0x982b,
- 0x98f3, 0x99e9, 0x9a0d
+ 0x64d1, 0x64e4, 0x650a, 0x650d, 0x653d, 0x6542, 0x656b, 0x6570,
+ 0x6651, 0x665d, 0x6666, 0x666a, 0x6687, 0x6689, 0x668c, 0x6697,
+ 0x66a0, 0x66be, 0x66c2, 0x6742, 0x6764, 0x6799, 0x681d, 0x697e,
+ 0x6a7e, 0x6a9b, 0x6abf, 0x6ac0, 0x6ac1, 0x6b9f, 0x6c32, 0x6c45,
+ 0x6c9b, 0x6ca8, 0x6ce5, 0x6d58, 0x6ded, 0x71a4, 0x71a5, 0x7213,
+ 0x730c, 0x747c, 0x7485, 0x7492, 0x75e1, 0x7655, 0x7742, 0x774a,
+ 0x7750, 0x775e, 0x77cb, 0x78de, 0x792a, 0x7968, 0x7a36, 0x7adb,
+ 0x7bd8, 0x7c58, 0x7e04, 0x7e16, 0x7e21, 0x7e39, 0x7e51, 0x7eae,
+ 0x7ecb, 0x7fb1, 0x8151, 0x87a9, 0x88de, 0x8940, 0x895d, 0x8ac3,
+ 0x8b01, 0x8b0b, 0x8b0d, 0x8b1b, 0x8b1e, 0x8b2a, 0x8b32, 0x8b4a,
+ 0x8b4c, 0x8b54, 0x8c80, 0x8c82, 0x8ce2, 0x8d4c, 0x8ef0, 0x8f1b,
+ 0x8f24, 0x8f36, 0x8f38, 0x8f3b, 0x8f77, 0x90aa, 0x912a, 0x912c,
+ 0x9402, 0x940e, 0x945e, 0x9476, 0x95ad, 0x95c1, 0x95c6, 0x965d,
+ 0x97d2, 0x982b, 0x98f3, 0x99e9, 0x9a0d
};
/*Collect the unicode lists and glyph_id offsets*/
@@ -3775,7 +3803,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
},
{
.range_start = 163, .range_length = 39438, .glyph_id_start = 95,
- .unicode_list = unicode_list_2, .glyph_id_ofs_list = NULL, .list_length = 227, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
+ .unicode_list = unicode_list_2, .glyph_id_ofs_list = NULL, .list_length = 229, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
}
};
@@ -3827,7 +3855,7 @@ static const uint8_t kern_left_class_mapping[] =
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0
+ 0, 0, 0, 0
};
/*Map glyph_ids to kern right classes*/
@@ -3873,7 +3901,7 @@ static const uint8_t kern_right_class_mapping[] =
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0
+ 0, 0, 0, 0
};
/*Kern values between classes*/
### src/ui/gui_assets/font/cn/cnText.c
@@ -1,7 +1,7 @@
/*******************************************************************************
* Size: 24 px
* Bpp: 2
- * Opts: --bpp 2 --size 24 --no-compress --font NotoSansSC-Regular.ttf --symbols !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~£¥·€、。一三上不与个中为主么了二于互交产享亮什从代以件份传体何作使例保信候允入全公共关准出分列创初删前办功加动助励包化升单卡即压及取受变可号各同名后吗启和固在地址坊型基处备复多天太失奖好如始委子字安完定密导小屏展差已币帐幕广序度建开异式强当径待志忘快念态总恢息悉您情成我或户扩扫拒择持指振换捷接描播擦收改教数文新方日时明易是显更未本机条析查标校格检概模款正毕气永池派测消添熵片版状理生用电白的盘盲相知短码确示禁私种秒称移程稍立端签简算管类系级纹络绝统继续维网置署脚自芯要解言计认记许设访证词试详语误请败账资路跳软载输过这进连退选通道重金钟钥钱链锁错键闭问除随隙页额验骰,:? --format lvgl -o ../gui_assets/font/cn/cnText.c
+ * Opts: --bpp 2 --size 24 --no-compress --font NotoSansSC-Regular.ttf --symbols !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~£¥·€、。一三上不与个中为主么了二于互交产享亮什从代以件份传体何作使例保信候允入全公共关准出分列创初删前办功加动助励包化升单卡即压及取受变可号各同名后吗启和回固在地址坊型基处备复多天太失奖好如始委子字安完定密导小屏展差已币帐幕广序度建开异式强当径待志忘快念态总恢息悉您情成我或户扩扫拒择持指振换捷接描播操擦收改教数文新方日时明易是显更未本机条析查标校格检概模款正毕气永池派测消添熵片版状理生用电白的盘盲相知短码确示禁私种秒称移程稍立端签简算管类系级纹络绝统继续维网置署脚自芯要解言计认记许设访证词试详语误请败账资路跳软载输过返这进连退选通道重金钟钥钱链锁错键闭问除随隙页额验骰,:? --format lvgl -o ../gui_assets/font/cn/cnText.c
******************************************************************************/
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
@@ -2191,6 +2191,23 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
0x0, 0x74, 0x0, 0xe0, 0x0, 0xe0, 0x0, 0x0,
0x0,
+ /* U+56DE "回" */
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xff, 0xff,
+ 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xfc,
+ 0xf0, 0x0, 0x0, 0x0, 0xf, 0x3c, 0x0, 0x0,
+ 0x0, 0x3, 0xcf, 0x0, 0x0, 0x0, 0x0, 0xf3,
+ 0xc0, 0x6a, 0xaa, 0x90, 0x3c, 0xf0, 0x2f, 0xff,
+ 0xf8, 0xf, 0x3c, 0xb, 0x0, 0xe, 0x3, 0xcf,
+ 0x2, 0xc0, 0x3, 0x80, 0xf3, 0xc0, 0xb0, 0x0,
+ 0xe0, 0x3c, 0xf0, 0x2c, 0x0, 0x38, 0xf, 0x3c,
+ 0xb, 0x0, 0xe, 0x3, 0xcf, 0x2, 0xea, 0xab,
+ 0x80, 0xf3, 0xc0, 0xbf, 0xff, 0xe0, 0x3c, 0xf0,
+ 0x0, 0x0, 0x0, 0xf, 0x3c, 0x0, 0x0, 0x0,
+ 0x3, 0xcf, 0x0, 0x0, 0x0, 0x0, 0xf3, 0xc0,
+ 0x0, 0x0, 0x0, 0x3c, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x3e, 0xaa, 0xaa, 0xaa, 0xab, 0xcf, 0x0,
+ 0x0, 0x0, 0x0, 0xf0,
+
/* U+56FA "固" */
0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff,
0xff, 0xff, 0xfa, 0xaa, 0xaa, 0xaa, 0xaf, 0xf0,
@@ -3561,6 +3578,25 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
0xf, 0xaa, 0xaa, 0xe0, 0xf, 0xc0, 0xe, 0x0,
0x0, 0xe0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ /* U+64CD "操" */
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x38, 0x0, 0xff, 0xff,
+ 0xc0, 0x0, 0xe0, 0x3, 0xc0, 0xf, 0x0, 0x3,
+ 0x80, 0xf, 0x0, 0x3c, 0x1, 0x5f, 0x50, 0x3d,
+ 0x55, 0xf0, 0xf, 0xff, 0xc0, 0xff, 0xff, 0xc0,
+ 0x5, 0xe4, 0x0, 0x0, 0x0, 0x0, 0x3, 0x80,
+ 0xff, 0xf3, 0xff, 0xd0, 0xe, 0x3, 0x56, 0xce,
+ 0x57, 0x40, 0x38, 0xc, 0xb, 0x38, 0xd, 0x0,
+ 0xe6, 0x30, 0x2c, 0xe0, 0x34, 0x7, 0xfc, 0xff,
+ 0xf3, 0xff, 0xd2, 0xff, 0x42, 0xaa, 0x9a, 0xaa,
+ 0xf, 0xb8, 0x0, 0x1, 0xd0, 0x0, 0x0, 0xe0,
+ 0x6a, 0xab, 0xaa, 0xa4, 0x3, 0x83, 0xff, 0xff,
+ 0xff, 0xf0, 0xe, 0x0, 0x3, 0xff, 0x0, 0x0,
+ 0x38, 0x0, 0x7d, 0xdf, 0x0, 0x0, 0xe0, 0xb,
+ 0xc7, 0x4f, 0x40, 0x3, 0x81, 0xf8, 0x1d, 0xf,
+ 0xd0, 0xae, 0x3f, 0x40, 0x74, 0x7, 0xc3, 0xf0,
+ 0x10, 0x1, 0xd0, 0x0, 0x0,
+
/* U+64E6 "擦" */
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x38, 0x0,
0x3, 0xc0, 0x0, 0x3, 0x80, 0x0, 0x1d, 0x0,
@@ -5642,6 +5678,25 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
0xea, 0xaf, 0xfe, 0x28, 0x0, 0x6f, 0xff, 0xff,
0xf4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ /* U+8FD4 "返" */
+ 0x0, 0x0, 0x0, 0x0, 0x5, 0x80, 0xf, 0x0,
+ 0x1a, 0xaf, 0xff, 0xf0, 0x7, 0xc0, 0x3f, 0xff,
+ 0xa5, 0x0, 0x2, 0xf0, 0x3c, 0x0, 0x0, 0x0,
+ 0x0, 0xb4, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3f, 0xff,
+ 0xff, 0xd0, 0x0, 0x0, 0x3e, 0xaa, 0xab, 0xc0,
+ 0x0, 0x0, 0x3c, 0x0, 0x3, 0x80, 0x3f, 0xf0,
+ 0x3c, 0x90, 0xb, 0x40, 0x2a, 0xf0, 0x3c, 0xf4,
+ 0xf, 0x0, 0x0, 0xf0, 0x38, 0x3e, 0x3c, 0x0,
+ 0x0, 0xf0, 0x74, 0xb, 0xf4, 0x0, 0x0, 0xf0,
+ 0xb0, 0x3, 0xf0, 0x0, 0x0, 0xf0, 0xf0, 0xf,
+ 0xfd, 0x0, 0x0, 0xf2, 0xd0, 0xbe, 0x1f, 0x40,
+ 0x0, 0xf3, 0xc7, 0xf0, 0x3, 0xd0, 0x1, 0xf0,
+ 0x43, 0x40, 0x0, 0xc0, 0xb, 0xfe, 0x0, 0x0,
+ 0x0, 0x0, 0x3e, 0xb, 0xfa, 0x55, 0x6a, 0xb8,
+ 0x3c, 0x0, 0xbf, 0xff, 0xff, 0xf8, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0,
+
/* U+8FD9 "这" */
0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0,
0x0, 0x3c, 0x0, 0x0, 0xe, 0x0, 0x0, 0x2d,
@@ -6322,216 +6377,219 @@ static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
{.bitmap_index = 13613, .adv_w = 384, .box_w = 21, .box_h = 22, .ofs_x = 2, .ofs_y = -3},
{.bitmap_index = 13729, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
{.bitmap_index = 13861, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 13982, .adv_w = 384, .box_w = 20, .box_h = 22, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 14092, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 14219, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 14357, .adv_w = 384, .box_w = 23, .box_h = 21, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 14478, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 14622, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 14743, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 14881, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 15019, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 15163, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 15301, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 15428, .adv_w = 384, .box_w = 23, .box_h = 21, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 15549, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 15682, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 15820, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 15953, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 16091, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 16218, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 16356, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 16494, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 16615, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 16747, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 16874, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 17006, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 17150, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 17288, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 17415, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 17553, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 17686, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 17819, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 17946, .adv_w = 384, .box_w = 21, .box_h = 21, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 18057, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 18178, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 18316, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 18454, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 18587, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 18731, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 18864, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 19008, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 19129, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 19256, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 19383, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 19510, .adv_w = 384, .box_w = 20, .box_h = 23, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 19625, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 19758, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 19902, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 20029, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 20162, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 20306, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 20439, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 20572, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 20699, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 20837, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 20970, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 21108, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 21241, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 21374, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 21518, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 21651, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 21772, .adv_w = 384, .box_w = 21, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 21898, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 22031, .adv_w = 384, .box_w = 21, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 22157, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 22290, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 22434, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 22578, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 22711, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 22855, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 22999, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 23143, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 23281, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 23419, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 23563, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 23690, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 23823, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 23956, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 24100, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 24238, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 24376, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 24509, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 24641, .adv_w = 384, .box_w = 16, .box_h = 22, .ofs_x = 4, .ofs_y = -3},
- {.bitmap_index = 24729, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 24856, .adv_w = 384, .box_w = 21, .box_h = 23, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 24977, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 25104, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 25242, .adv_w = 384, .box_w = 24, .box_h = 20, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 25362, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 25489, .adv_w = 384, .box_w = 24, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 25621, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 25759, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 25903, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 26047, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 26185, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 26323, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 26461, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 26599, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 26743, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 26881, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 27025, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 27169, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 27313, .adv_w = 384, .box_w = 22, .box_h = 20, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 27423, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 27544, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 27682, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 27815, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 27948, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 28086, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 28219, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 28352, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 28490, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 28623, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 28755, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 28893, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 29031, .adv_w = 384, .box_w = 24, .box_h = 21, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 29157, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 29278, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 29399, .adv_w = 384, .box_w = 21, .box_h = 23, .ofs_x = 3, .ofs_y = -2},
- {.bitmap_index = 29520, .adv_w = 384, .box_w = 18, .box_h = 24, .ofs_x = 3, .ofs_y = -3},
- {.bitmap_index = 29628, .adv_w = 384, .box_w = 21, .box_h = 24, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 29754, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 29881, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 30013, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 30151, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 30278, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 30416, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 30543, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 30675, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 30802, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 30940, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 31078, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 31211, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 31344, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 31477, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 31615, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 31742, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 31869, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -1},
- {.bitmap_index = 31990, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 32128, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 32261, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 32399, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 32537, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 32675, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 32808, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 32935, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 33068, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 33201, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 33345, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 33478, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 33616, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 33743, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 33876, .adv_w = 384, .box_w = 24, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 34008, .adv_w = 384, .box_w = 20, .box_h = 21, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 34113, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 34234, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 34361, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 34494, .adv_w = 384, .box_w = 18, .box_h = 24, .ofs_x = 3, .ofs_y = -3},
- {.bitmap_index = 34602, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 34735, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 34862, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 35000, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 35132, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 35259, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 35392, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 35519, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 35652, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 35779, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 35911, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 36038, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 36165, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 36303, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 36436, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 36569, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 36707, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 36840, .adv_w = 384, .box_w = 24, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 36972, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 37110, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 37231, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 37375, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 37513, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 37657, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 37795, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 37939, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 38066, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 38210, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 38337, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 38481, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 38608, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 38746, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 38884, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 39022, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 39143, .adv_w = 384, .box_w = 24, .box_h = 22, .ofs_x = 0, .ofs_y = -1},
- {.bitmap_index = 39275, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 39408, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 39540, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 39678, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 39822, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
- {.bitmap_index = 39960, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 40104, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 40248, .adv_w = 384, .box_w = 20, .box_h = 22, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 40358, .adv_w = 384, .box_w = 20, .box_h = 23, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 40473, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 40611, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 40749, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 40887, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 41008, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 41152, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 41296, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 41423, .adv_w = 384, .box_w = 5, .box_h = 9, .ofs_x = 3, .ofs_y = -3},
- {.bitmap_index = 41435, .adv_w = 384, .box_w = 4, .box_h = 17, .ofs_x = 4, .ofs_y = -1},
- {.bitmap_index = 41452, .adv_w = 384, .box_w = 12, .box_h = 20, .ofs_x = 0, .ofs_y = -1}
+ {.bitmap_index = 13982, .adv_w = 384, .box_w = 21, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 14098, .adv_w = 384, .box_w = 20, .box_h = 22, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 14208, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 14335, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 14473, .adv_w = 384, .box_w = 23, .box_h = 21, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 14594, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 14738, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 14859, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 14997, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 15135, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 15279, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 15417, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 15544, .adv_w = 384, .box_w = 23, .box_h = 21, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 15665, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 15798, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 15936, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 16069, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 16207, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 16334, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 16472, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 16610, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 16731, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 16863, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 16990, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 17122, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 17266, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 17404, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 17531, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 17669, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 17802, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 17935, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 18062, .adv_w = 384, .box_w = 21, .box_h = 21, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 18173, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 18294, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 18432, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 18570, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 18703, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 18847, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 18980, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 19124, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 19245, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 19372, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 19499, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 19626, .adv_w = 384, .box_w = 20, .box_h = 23, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 19741, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 19874, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 20018, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 20145, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 20278, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 20422, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 20555, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 20688, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 20815, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 20953, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 21086, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 21224, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 21357, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 21490, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 21634, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 21767, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 21888, .adv_w = 384, .box_w = 21, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 22014, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 22147, .adv_w = 384, .box_w = 21, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 22273, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 22406, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 22550, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 22694, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 22827, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 22971, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 23115, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 23259, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 23397, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 23535, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 23679, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 23812, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 23939, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 24072, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 24205, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 24349, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 24487, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 24625, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 24758, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 24890, .adv_w = 384, .box_w = 16, .box_h = 22, .ofs_x = 4, .ofs_y = -3},
+ {.bitmap_index = 24978, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 25105, .adv_w = 384, .box_w = 21, .box_h = 23, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 25226, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 25353, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 25491, .adv_w = 384, .box_w = 24, .box_h = 20, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 25611, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 25738, .adv_w = 384, .box_w = 24, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 25870, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 26008, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 26152, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 26296, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 26434, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 26572, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 26710, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 26848, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 26992, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 27130, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 27274, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 27418, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 27562, .adv_w = 384, .box_w = 22, .box_h = 20, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 27672, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 27793, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 27931, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 28064, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 28197, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 28335, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 28468, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 28601, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 28739, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 28872, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 29004, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 29142, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 29280, .adv_w = 384, .box_w = 24, .box_h = 21, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 29406, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 29527, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 29648, .adv_w = 384, .box_w = 21, .box_h = 23, .ofs_x = 3, .ofs_y = -2},
+ {.bitmap_index = 29769, .adv_w = 384, .box_w = 18, .box_h = 24, .ofs_x = 3, .ofs_y = -3},
+ {.bitmap_index = 29877, .adv_w = 384, .box_w = 21, .box_h = 24, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 30003, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 30130, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 30262, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 30400, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 30527, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 30665, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 30792, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 30924, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 31051, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 31189, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 31327, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 31460, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 31593, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 31726, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 31864, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 31991, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 32118, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 32239, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 32377, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 32510, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 32648, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 32786, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 32924, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 33057, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 33184, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 33317, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 33450, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 33594, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 33727, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 33865, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 33992, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 34125, .adv_w = 384, .box_w = 24, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 34257, .adv_w = 384, .box_w = 20, .box_h = 21, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 34362, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 34483, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 34610, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 34743, .adv_w = 384, .box_w = 18, .box_h = 24, .ofs_x = 3, .ofs_y = -3},
+ {.bitmap_index = 34851, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 34984, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 35111, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 35249, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 35381, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 35508, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 35641, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 35768, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 35901, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 36028, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 36160, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 36287, .adv_w = 384, .box_w = 22, .box_h = 23, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 36414, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 36552, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 36685, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 36818, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 36956, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 37089, .adv_w = 384, .box_w = 24, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 37221, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 37359, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 37480, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 37624, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 37762, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 37906, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 38044, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 38188, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 38315, .adv_w = 384, .box_w = 24, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 38447, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 38591, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 38718, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 38862, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 38989, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 39127, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 39265, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 39403, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 39524, .adv_w = 384, .box_w = 24, .box_h = 22, .ofs_x = 0, .ofs_y = -1},
+ {.bitmap_index = 39656, .adv_w = 384, .box_w = 23, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 39789, .adv_w = 384, .box_w = 22, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 39921, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 40059, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 40203, .adv_w = 384, .box_w = 24, .box_h = 23, .ofs_x = 0, .ofs_y = -2},
+ {.bitmap_index = 40341, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 40485, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 40629, .adv_w = 384, .box_w = 20, .box_h = 22, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 40739, .adv_w = 384, .box_w = 20, .box_h = 23, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 40854, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 40992, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 41130, .adv_w = 384, .box_w = 23, .box_h = 24, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 41268, .adv_w = 384, .box_w = 22, .box_h = 22, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 41389, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 41533, .adv_w = 384, .box_w = 24, .box_h = 24, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 41677, .adv_w = 384, .box_w = 23, .box_h = 22, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 41804, .adv_w = 384, .box_w = 5, .box_h = 9, .ofs_x = 3, .ofs_y = -3},
+ {.bitmap_index = 41816, .adv_w = 384, .box_w = 4, .box_h = 17, .ofs_x = 4, .ofs_y = -1},
+ {.bitmap_index = 41833, .adv_w = 384, .box_w = 12, .box_h = 20, .ofs_x = 0, .ofs_y = -1}
};
/*---------------------
@@ -6548,34 +6606,34 @@ static const uint16_t unicode_list_2[] = {
0x5174, 0x5178, 0x517a, 0x517d, 0x51aa, 0x51fb, 0x51fc, 0x51fd,
0x5205, 0x5206, 0x520e, 0x5262, 0x5273, 0x52a4, 0x52b2, 0x52be,
0x52d0, 0x52e8, 0x5327, 0x5333, 0x5334, 0x5335, 0x534c, 0x5354,
- 0x5361, 0x5369, 0x536a, 0x536b, 0x5374, 0x538c, 0x53e9, 0x5657,
- 0x5685, 0x568d, 0x569d, 0x56a7, 0x56e8, 0x5757, 0x5861, 0x5864,
- 0x586a, 0x5877, 0x5886, 0x5887, 0x588e, 0x58b3, 0x58da, 0x58df,
- 0x5928, 0x5931, 0x5aad, 0x5ab4, 0x5ae6, 0x5ae9, 0x5af7, 0x5b23,
- 0x5b59, 0x5b6c, 0x5bac, 0x5bb2, 0x5d4b, 0x5d4f, 0x5d5e, 0x5d6d,
- 0x5db2, 0x5ddc, 0x5dec, 0x5e03, 0x5e57, 0x5e5d, 0x5e5f, 0x5e6c,
- 0x5e97, 0x5eb0, 0x5ee1, 0x5ee2, 0x5f34, 0x5f35, 0x5f48, 0x5f52,
- 0x5f5e, 0x5f98, 0x5fbf, 0x5fcc, 0x5fe6, 0x6005, 0x6022, 0x616d,
- 0x616e, 0x6173, 0x6194, 0x61c6, 0x61c8, 0x622f, 0x6246, 0x625e,
- 0x6264, 0x628c, 0x62bf, 0x62d4, 0x6302, 0x632c, 0x640a, 0x6443,
- 0x6493, 0x6496, 0x64b6, 0x64cd, 0x64e4, 0x650d, 0x6516, 0x6542,
- 0x6553, 0x656b, 0x6570, 0x658c, 0x659b, 0x6651, 0x6687, 0x6689,
- 0x6697, 0x66be, 0x66ed, 0x6742, 0x6764, 0x677e, 0x6799, 0x681d,
- 0x68df, 0x697e, 0x6a9b, 0x6ac0, 0x6b32, 0x6b71, 0x6b95, 0x6bbd,
- 0x6c9b, 0x6ca8, 0x6ce5, 0x6d58, 0x7112, 0x71a4, 0x71a5, 0x7213,
- 0x7363, 0x747c, 0x7485, 0x7492, 0x75da, 0x75e1, 0x7635, 0x764f,
- 0x7655, 0x7742, 0x774a, 0x775e, 0x77cb, 0x7897, 0x78de, 0x791e,
- 0x792a, 0x792f, 0x794d, 0x7958, 0x7968, 0x796a, 0x7a28, 0x7a4c,
- 0x7adb, 0x7add, 0x7af4, 0x7afe, 0x7bd8, 0x7c58, 0x7e04, 0x7e16,
- 0x7e39, 0x7e3a, 0x7e3c, 0x7e44, 0x7e4a, 0x7e51, 0x7eae, 0x7ecb,
- 0x7ecf, 0x8077, 0x8147, 0x820c, 0x88de, 0x8940, 0x895d, 0x8afe,
- 0x8b01, 0x8b0d, 0x8b15, 0x8b1b, 0x8b1c, 0x8b1e, 0x8b2a, 0x8b32,
- 0x8b43, 0x8b4a, 0x8b4c, 0x8b54, 0x8c82, 0x8c83, 0x8ca1, 0x8d4c,
- 0x8d50, 0x8ecc, 0x8eda, 0x8ef0, 0x8f24, 0x8f36, 0x8f38, 0x8f3b,
- 0x8f5d, 0x8f66, 0x8f77, 0x8fb0, 0x912a, 0x912e, 0x93fc, 0x9402,
- 0x940e, 0x945b, 0x945e, 0x9476, 0x948b, 0x954a, 0x954b, 0x95c1,
- 0x95ec, 0x95f6, 0x97d2, 0x97fa, 0x99e9, 0x9a0d, 0xfe69, 0xfe77,
- 0xfe7c
+ 0x5361, 0x5369, 0x536a, 0x536b, 0x5374, 0x538c, 0x53e9, 0x563b,
+ 0x5657, 0x5685, 0x568d, 0x569d, 0x56a7, 0x56e8, 0x5757, 0x5861,
+ 0x5864, 0x586a, 0x5877, 0x5886, 0x5887, 0x588e, 0x58b3, 0x58da,
+ 0x58df, 0x5928, 0x5931, 0x5aad, 0x5ab4, 0x5ae6, 0x5ae9, 0x5af7,
+ 0x5b23, 0x5b59, 0x5b6c, 0x5bac, 0x5bb2, 0x5d4b, 0x5d4f, 0x5d5e,
+ 0x5d6d, 0x5db2, 0x5ddc, 0x5dec, 0x5e03, 0x5e57, 0x5e5d, 0x5e5f,
+ 0x5e6c, 0x5e97, 0x5eb0, 0x5ee1, 0x5ee2, 0x5f34, 0x5f35, 0x5f48,
+ 0x5f52, 0x5f5e, 0x5f98, 0x5fbf, 0x5fcc, 0x5fe6, 0x6005, 0x6022,
+ 0x616d, 0x616e, 0x6173, 0x6194, 0x61c6, 0x61c8, 0x622f, 0x6246,
+ 0x625e, 0x6264, 0x628c, 0x62bf, 0x62d4, 0x6302, 0x632c, 0x640a,
+ 0x642a, 0x6443, 0x6493, 0x6496, 0x64b6, 0x64cd, 0x64e4, 0x650d,
+ 0x6516, 0x6542, 0x6553, 0x656b, 0x6570, 0x658c, 0x659b, 0x6651,
+ 0x6687, 0x6689, 0x6697, 0x66be, 0x66ed, 0x6742, 0x6764, 0x677e,
+ 0x6799, 0x681d, 0x68df, 0x697e, 0x6a9b, 0x6ac0, 0x6b32, 0x6b71,
+ 0x6b95, 0x6bbd, 0x6c9b, 0x6ca8, 0x6ce5, 0x6d58, 0x7112, 0x71a4,
+ 0x71a5, 0x7213, 0x7363, 0x747c, 0x7485, 0x7492, 0x75da, 0x75e1,
+ 0x7635, 0x764f, 0x7655, 0x7742, 0x774a, 0x775e, 0x77cb, 0x7897,
+ 0x78de, 0x791e, 0x792a, 0x792f, 0x794d, 0x7958, 0x7968, 0x796a,
+ 0x7a28, 0x7a4c, 0x7adb, 0x7add, 0x7af4, 0x7afe, 0x7bd8, 0x7c58,
+ 0x7e04, 0x7e16, 0x7e39, 0x7e3a, 0x7e3c, 0x7e44, 0x7e4a, 0x7e51,
+ 0x7eae, 0x7ecb, 0x7ecf, 0x8077, 0x8147, 0x820c, 0x88de, 0x8940,
+ 0x895d, 0x8afe, 0x8b01, 0x8b0d, 0x8b15, 0x8b1b, 0x8b1c, 0x8b1e,
+ 0x8b2a, 0x8b32, 0x8b43, 0x8b4a, 0x8b4c, 0x8b54, 0x8c82, 0x8c83,
+ 0x8ca1, 0x8d4c, 0x8d50, 0x8ecc, 0x8eda, 0x8ef0, 0x8f24, 0x8f31,
+ 0x8f36, 0x8f38, 0x8f3b, 0x8f5d, 0x8f66, 0x8f77, 0x8fb0, 0x912a,
+ 0x912e, 0x93fc, 0x9402, 0x940e, 0x945b, 0x945e, 0x9476, 0x948b,
+ 0x954a, 0x954b, 0x95c1, 0x95ec, 0x95f6, 0x97d2, 0x97fa, 0x99e9,
+ 0x9a0d, 0xfe69, 0xfe77, 0xfe7c
};
/*Collect the unicode lists and glyph_id offsets*/
@@ -6591,7 +6649,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
},
{
.range_start = 163, .range_length = 65149, .glyph_id_start = 95,
- .unicode_list = unicode_list_2, .glyph_id_ofs_list = NULL, .list_length = 289, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
+ .unicode_list = unicode_list_2, .glyph_id_ofs_list = NULL, .list_length = 292, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
}
};
@@ -6650,7 +6708,8 @@ static const uint8_t kern_left_class_mapping[] =
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0
};
/*Map glyph_ids to kern right classes*/
@@ -6703,7 +6762,8 @@ static const uint8_t kern_right_class_mapping[] =
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0
};
/*Kern values between classes*/
### src/ui/gui_assets/font/cn/cnTitle.c
@@ -1,7 +1,7 @@
/*******************************************************************************
* Size: 36 px
* Bpp: 1
- * Opts: --bpp 1 --size 36 --no-compress --font NotoSansSC-Regular.ttf --symbols !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~£¥·€代件份入分制加助包升名命和固备多子密导建您意所择指新方更有本权查校检法注添源片版的码确种签级纹置言认记设证词语输选重钱限项验 --format lvgl -o ../gui_assets/font/cn/cnTitle.c
+ * Opts: --bpp 1 --size 36 --no-compress --font NotoSansSC-Regular.ttf --symbols !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~£¥·€之代件份入分制前加助包升名命和固备多子密导建您意所择指新方更有本权查校检法注添源片版的码确种签级纹继续置言认记设证词语输选重钱限项验 --format lvgl -o ../gui_assets/font/cn/cnTitle.c
******************************************************************************/
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
@@ -836,6 +836,24 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
0x80, 0xe0, 0x3c, 0x1e, 0x0, 0xff, 0xc0, 0x3,
0xf0,
+ /* U+4E4B "之" */
+ 0x0, 0x3, 0x0, 0x0, 0x0, 0x7, 0x80, 0x0,
+ 0x0, 0x3, 0x80, 0x0, 0x0, 0x1, 0xc0, 0x0,
+ 0x0, 0x1, 0xe0, 0x0, 0x0, 0x0, 0xe0, 0x0,
+ 0x0, 0x0, 0xc0, 0x0, 0x3f, 0xff, 0xff, 0xf0,
+ 0x3f, 0xff, 0xff, 0xf8, 0x0, 0x0, 0x0, 0x70,
+ 0x0, 0x0, 0x0, 0xe0, 0x0, 0x0, 0x1, 0xe0,
+ 0x0, 0x0, 0x3, 0xc0, 0x0, 0x0, 0x7, 0x80,
+ 0x0, 0x0, 0xf, 0x0, 0x0, 0x0, 0xe, 0x0,
+ 0x0, 0x0, 0x1c, 0x0, 0x0, 0x0, 0x38, 0x0,
+ 0x0, 0x0, 0xf0, 0x0, 0x0, 0x1, 0xe0, 0x0,
+ 0x0, 0x3, 0xc0, 0x0, 0x0, 0x7, 0x80, 0x0,
+ 0x0, 0xf, 0x0, 0x0, 0x0, 0x3e, 0x0, 0x0,
+ 0x0, 0x7c, 0x0, 0x0, 0x1, 0xf0, 0x0, 0x0,
+ 0xf, 0xe0, 0x0, 0x0, 0x3f, 0xc0, 0x0, 0x0,
+ 0x78, 0xf8, 0x0, 0x0, 0xf0, 0x7f, 0xff, 0xff,
+ 0x60, 0x7, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0,
+
/* U+4EE3 "代" */
0x0, 0x20, 0x1c, 0x0, 0x0, 0x7, 0x3, 0x86,
0x0, 0x1, 0xc0, 0x70, 0xe0, 0x0, 0x38, 0xe,
@@ -955,6 +973,25 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
0x0, 0x70, 0x0, 0x7, 0x0, 0x70, 0x0, 0xff,
0x0, 0x70, 0x0, 0x7e,
+ /* U+524D "前" */
+ 0x1, 0x0, 0x0, 0x80, 0x3, 0x80, 0x1, 0xe0,
+ 0x1, 0xc0, 0x1, 0xc0, 0x1, 0xe0, 0x3, 0x80,
+ 0x0, 0xe0, 0x3, 0x80, 0x0, 0x60, 0x7, 0x0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x3f, 0xfe, 0xc, 0x1c,
+ 0x3f, 0xfe, 0xc, 0x1c, 0x38, 0x6, 0xc, 0x1c,
+ 0x38, 0x6, 0xc, 0x1c, 0x38, 0x6, 0xc, 0x1c,
+ 0x38, 0x6, 0xc, 0x1c, 0x3f, 0xfe, 0xc, 0x1c,
+ 0x3f, 0xfe, 0xc, 0x1c, 0x38, 0x6, 0xc, 0x1c,
+ 0x38, 0x6, 0xc, 0x1c, 0x38, 0x6, 0xc, 0x1c,
+ 0x3f, 0xfe, 0xc, 0x1c, 0x3f, 0xfe, 0xc, 0x1c,
+ 0x3f, 0xfe, 0xc, 0x1c, 0x38, 0x6, 0xc, 0x1c,
+ 0x38, 0x6, 0x0, 0x1c, 0x38, 0x6, 0x0, 0x1c,
+ 0x38, 0x6, 0x0, 0x1c, 0x38, 0x6, 0x0, 0x1c,
+ 0x38, 0x6, 0x0, 0x1c, 0x38, 0xfe, 0x3, 0xf8,
+ 0x38, 0x7c, 0x3, 0xf8,
+
/* U+52A0 "加" */
0x3, 0x80, 0x0, 0x0, 0x3, 0x80, 0x0, 0x0,
0x3, 0x80, 0x0, 0x0, 0x3, 0x80, 0x0, 0x0,
@@ -1742,6 +1779,45 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
0x3, 0xe0, 0x7c, 0x18, 0x3, 0xf0, 0xf, 0xe0,
0x3, 0xf0, 0x0, 0xf8, 0x0, 0x70, 0x0, 0xc,
+ /* U+7EE7 "继" */
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0, 0x0, 0x60,
+ 0x0, 0xe0, 0x0, 0x30, 0x0, 0x70, 0x60, 0x18,
+ 0x0, 0x38, 0x33, 0xc, 0x30, 0x38, 0x18, 0xc6,
+ 0x38, 0x1c, 0xc, 0x63, 0x18, 0x1c, 0x6, 0x31,
+ 0x9c, 0xe, 0x3, 0xc, 0xcc, 0xe, 0x1d, 0x86,
+ 0x66, 0x7, 0xc, 0xc2, 0x30, 0x7, 0xe, 0x60,
+ 0x18, 0x3, 0xfe, 0x37, 0xff, 0xff, 0xff, 0x1b,
+ 0xff, 0xfd, 0xc7, 0xc, 0x7, 0x80, 0x83, 0x6,
+ 0x7, 0xe0, 0x3, 0x83, 0x3, 0xf0, 0x3, 0x81,
+ 0x83, 0xec, 0x3, 0x80, 0xc1, 0xb7, 0x1, 0x86,
+ 0x61, 0xd9, 0xc1, 0xff, 0x31, 0xcc, 0x71, 0xff,
+ 0x18, 0xc6, 0x39, 0xf0, 0xc, 0xe3, 0xc, 0xc0,
+ 0x6, 0x61, 0x80, 0x0, 0x3, 0x20, 0xc0, 0x0,
+ 0x1, 0x80, 0x60, 0x0, 0x1e, 0xc0, 0x30, 0x0,
+ 0xff, 0x60, 0x18, 0x7, 0xff, 0x30, 0x0, 0x3,
+ 0xf8, 0x18, 0x0, 0x1, 0xe0, 0xf, 0xff, 0xfe,
+ 0x0, 0x7, 0xff, 0xff,
+
+ /* U+7EED "续" */
+ 0x1, 0x80, 0x7, 0x0, 0x1, 0xc0, 0x3, 0x80,
+ 0x0, 0xc0, 0x1, 0xc0, 0x0, 0xe0, 0x3f, 0xff,
+ 0x80, 0x70, 0x1f, 0xff, 0xc0, 0x70, 0x0, 0x38,
+ 0x0, 0x38, 0x0, 0x1c, 0x0, 0x38, 0x0, 0xe,
+ 0x0, 0x1c, 0x60, 0x7, 0x0, 0x1c, 0x33, 0xff,
+ 0xff, 0x8c, 0x39, 0xff, 0xff, 0xce, 0x18, 0x0,
+ 0x0, 0xcf, 0xfc, 0x0, 0x30, 0x67, 0xfc, 0x7,
+ 0x18, 0x71, 0xe, 0x1, 0xcc, 0x30, 0xe, 0x0,
+ 0x76, 0x18, 0x6, 0x3, 0xb, 0x0, 0x7, 0x1,
+ 0xe1, 0x80, 0x7, 0x18, 0x38, 0xc0, 0x7, 0xfc,
+ 0xc, 0x60, 0x7, 0xfc, 0x0, 0x30, 0x7, 0xe0,
+ 0x7f, 0xff, 0xfb, 0x80, 0x3f, 0xff, 0xfc, 0x0,
+ 0x0, 0x1c, 0x0, 0x0, 0x60, 0xe, 0x0, 0x1,
+ 0xf0, 0xe, 0x60, 0x7, 0xf0, 0xf, 0x3c, 0xf,
+ 0xc0, 0xf, 0x7, 0x7, 0x80, 0xf, 0x1, 0xc3,
+ 0x0, 0x1f, 0x0, 0x70, 0x0, 0x3e, 0x0, 0x1c,
+ 0x0, 0x1e, 0x0, 0x6, 0x0, 0x4, 0x0, 0x0,
+ 0x0,
+
/* U+7F6E "置" */
0x3f, 0xff, 0xff, 0xfc, 0x3f, 0xff, 0xff, 0xfc,
0x38, 0x18, 0x18, 0x1c, 0x38, 0x18, 0x18, 0x1c,
@@ -2134,84 +2210,88 @@ static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
{.bitmap_index = 4519, .adv_w = 320, .box_w = 18, .box_h = 26, .ofs_x = 1, .ofs_y = 0},
{.bitmap_index = 4578, .adv_w = 576, .box_w = 8, .box_h = 7, .ofs_x = 14, .ofs_y = 10},
{.bitmap_index = 4585, .adv_w = 320, .box_w = 20, .box_h = 26, .ofs_x = 0, .ofs_y = 0},
- {.bitmap_index = 4650, .adv_w = 576, .box_w = 35, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 4795, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 4936, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 5077, .adv_w = 576, .box_w = 34, .box_h = 32, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 5213, .adv_w = 576, .box_w = 33, .box_h = 34, .ofs_x = 1, .ofs_y = -4},
- {.bitmap_index = 5354, .adv_w = 576, .box_w = 32, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 5486, .adv_w = 576, .box_w = 32, .box_h = 33, .ofs_x = 1, .ofs_y = -4},
- {.bitmap_index = 5618, .adv_w = 576, .box_w = 32, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 5750, .adv_w = 576, .box_w = 34, .box_h = 32, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 5886, .adv_w = 576, .box_w = 34, .box_h = 32, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 6022, .adv_w = 576, .box_w = 29, .box_h = 33, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 6142, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 6283, .adv_w = 576, .box_w = 32, .box_h = 32, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 6411, .adv_w = 576, .box_w = 30, .box_h = 31, .ofs_x = 3, .ofs_y = -3},
- {.bitmap_index = 6528, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 6669, .adv_w = 576, .box_w = 31, .box_h = 33, .ofs_x = 3, .ofs_y = -3},
- {.bitmap_index = 6797, .adv_w = 576, .box_w = 33, .box_h = 30, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 6921, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 7058, .adv_w = 576, .box_w = 32, .box_h = 32, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 7186, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 7323, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 7460, .adv_w = 576, .box_w = 31, .box_h = 33, .ofs_x = 3, .ofs_y = -3},
- {.bitmap_index = 7588, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 7725, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 7866, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 8007, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 8148, .adv_w = 576, .box_w = 33, .box_h = 34, .ofs_x = 1, .ofs_y = -4},
- {.bitmap_index = 8289, .adv_w = 576, .box_w = 33, .box_h = 31, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 8417, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 8554, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 8691, .adv_w = 576, .box_w = 35, .box_h = 33, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 8836, .adv_w = 576, .box_w = 34, .box_h = 32, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 8972, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 9113, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 9250, .adv_w = 576, .box_w = 33, .box_h = 32, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 9382, .adv_w = 576, .box_w = 33, .box_h = 32, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 9514, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 9655, .adv_w = 576, .box_w = 34, .box_h = 32, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 9791, .adv_w = 576, .box_w = 31, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 9919, .adv_w = 576, .box_w = 34, .box_h = 34, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 10064, .adv_w = 576, .box_w = 30, .box_h = 33, .ofs_x = 3, .ofs_y = -3},
- {.bitmap_index = 10188, .adv_w = 576, .box_w = 33, .box_h = 31, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 10316, .adv_w = 576, .box_w = 32, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 10448, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 0, .ofs_y = -3},
- {.bitmap_index = 10589, .adv_w = 576, .box_w = 33, .box_h = 32, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 10721, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 10862, .adv_w = 576, .box_w = 34, .box_h = 32, .ofs_x = 1, .ofs_y = -2},
- {.bitmap_index = 10998, .adv_w = 576, .box_w = 32, .box_h = 31, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 11122, .adv_w = 576, .box_w = 32, .box_h = 33, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 11254, .adv_w = 576, .box_w = 33, .box_h = 32, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 11386, .adv_w = 576, .box_w = 34, .box_h = 32, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 11522, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 11659, .adv_w = 576, .box_w = 34, .box_h = 32, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 11795, .adv_w = 576, .box_w = 31, .box_h = 32, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 11919, .adv_w = 576, .box_w = 33, .box_h = 32, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 12051, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 12192, .adv_w = 576, .box_w = 33, .box_h = 34, .ofs_x = 1, .ofs_y = -4},
- {.bitmap_index = 12333, .adv_w = 576, .box_w = 33, .box_h = 31, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 12461, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 2, .ofs_y = -3},
- {.bitmap_index = 12598, .adv_w = 576, .box_w = 31, .box_h = 32, .ofs_x = 4, .ofs_y = -3},
- {.bitmap_index = 12722, .adv_w = 576, .box_w = 34, .box_h = 31, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 12854, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3}
+ {.bitmap_index = 4650, .adv_w = 576, .box_w = 32, .box_h = 32, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 4778, .adv_w = 576, .box_w = 35, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 4923, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 5064, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 5205, .adv_w = 576, .box_w = 34, .box_h = 32, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 5341, .adv_w = 576, .box_w = 33, .box_h = 34, .ofs_x = 1, .ofs_y = -4},
+ {.bitmap_index = 5482, .adv_w = 576, .box_w = 32, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 5614, .adv_w = 576, .box_w = 32, .box_h = 33, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 5746, .adv_w = 576, .box_w = 32, .box_h = 33, .ofs_x = 1, .ofs_y = -4},
+ {.bitmap_index = 5878, .adv_w = 576, .box_w = 32, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 6010, .adv_w = 576, .box_w = 34, .box_h = 32, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 6146, .adv_w = 576, .box_w = 34, .box_h = 32, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 6282, .adv_w = 576, .box_w = 29, .box_h = 33, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 6402, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 6543, .adv_w = 576, .box_w = 32, .box_h = 32, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 6671, .adv_w = 576, .box_w = 30, .box_h = 31, .ofs_x = 3, .ofs_y = -3},
+ {.bitmap_index = 6788, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 6929, .adv_w = 576, .box_w = 31, .box_h = 33, .ofs_x = 3, .ofs_y = -3},
+ {.bitmap_index = 7057, .adv_w = 576, .box_w = 33, .box_h = 30, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 7181, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 7318, .adv_w = 576, .box_w = 32, .box_h = 32, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 7446, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 7583, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 7720, .adv_w = 576, .box_w = 31, .box_h = 33, .ofs_x = 3, .ofs_y = -3},
+ {.bitmap_index = 7848, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 7985, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 8126, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 8267, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 8408, .adv_w = 576, .box_w = 33, .box_h = 34, .ofs_x = 1, .ofs_y = -4},
+ {.bitmap_index = 8549, .adv_w = 576, .box_w = 33, .box_h = 31, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 8677, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 8814, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 8951, .adv_w = 576, .box_w = 35, .box_h = 33, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 9096, .adv_w = 576, .box_w = 34, .box_h = 32, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 9232, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 9373, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 9510, .adv_w = 576, .box_w = 33, .box_h = 32, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 9642, .adv_w = 576, .box_w = 33, .box_h = 32, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 9774, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 9915, .adv_w = 576, .box_w = 34, .box_h = 32, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 10051, .adv_w = 576, .box_w = 31, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 10179, .adv_w = 576, .box_w = 34, .box_h = 34, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 10324, .adv_w = 576, .box_w = 30, .box_h = 33, .ofs_x = 3, .ofs_y = -3},
+ {.bitmap_index = 10448, .adv_w = 576, .box_w = 33, .box_h = 31, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 10576, .adv_w = 576, .box_w = 32, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 10708, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 0, .ofs_y = -3},
+ {.bitmap_index = 10849, .adv_w = 576, .box_w = 33, .box_h = 32, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 10981, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 11122, .adv_w = 576, .box_w = 34, .box_h = 32, .ofs_x = 1, .ofs_y = -2},
+ {.bitmap_index = 11258, .adv_w = 576, .box_w = 33, .box_h = 32, .ofs_x = 1, .ofs_y = -1},
+ {.bitmap_index = 11390, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 11527, .adv_w = 576, .box_w = 32, .box_h = 31, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 11651, .adv_w = 576, .box_w = 32, .box_h = 33, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 11783, .adv_w = 576, .box_w = 33, .box_h = 32, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 11915, .adv_w = 576, .box_w = 34, .box_h = 32, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 12051, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 12188, .adv_w = 576, .box_w = 34, .box_h = 32, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 12324, .adv_w = 576, .box_w = 31, .box_h = 32, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 12448, .adv_w = 576, .box_w = 33, .box_h = 32, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 12580, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 12721, .adv_w = 576, .box_w = 33, .box_h = 34, .ofs_x = 1, .ofs_y = -4},
+ {.bitmap_index = 12862, .adv_w = 576, .box_w = 33, .box_h = 31, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 12990, .adv_w = 576, .box_w = 33, .box_h = 33, .ofs_x = 2, .ofs_y = -3},
+ {.bitmap_index = 13127, .adv_w = 576, .box_w = 31, .box_h = 32, .ofs_x = 4, .ofs_y = -3},
+ {.bitmap_index = 13251, .adv_w = 576, .box_w = 34, .box_h = 31, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 13383, .adv_w = 576, .box_w = 34, .box_h = 33, .ofs_x = 1, .ofs_y = -3}
};
/*---------------------
* CHARACTER MAPPING
*--------------------*/
static const uint16_t unicode_list_2[] = {
- 0x0, 0x2, 0x14, 0x2009, 0x4e40, 0x4e53, 0x4e5a, 0x50c2,
- 0x5163, 0x5193, 0x51fd, 0x5206, 0x5262, 0x52a4, 0x536a, 0x53da,
- 0x53e9, 0x5657, 0x5864, 0x5877, 0x5aad, 0x5b23, 0x5b59, 0x5e57,
- 0x6005, 0x606c, 0x619d, 0x6246, 0x6264, 0x650d, 0x6516, 0x6651,
- 0x6666, 0x6689, 0x66a0, 0x6742, 0x677e, 0x681d, 0x6c32, 0x6c45,
- 0x6d58, 0x6ded, 0x71a4, 0x71a5, 0x75e1, 0x775e, 0x77cb, 0x792a,
- 0x7adb, 0x7e04, 0x7e16, 0x7ecb, 0x895d, 0x8b01, 0x8b0d, 0x8b1b,
- 0x8b1e, 0x8b2a, 0x8b4a, 0x8ef0, 0x8f66, 0x912a, 0x940e, 0x95ad,
- 0x97d6, 0x99e9
+ 0x0, 0x2, 0x14, 0x2009, 0x4da8, 0x4e40, 0x4e53, 0x4e5a,
+ 0x50c2, 0x5163, 0x5193, 0x51aa, 0x51fd, 0x5206, 0x5262, 0x52a4,
+ 0x536a, 0x53da, 0x53e9, 0x5657, 0x5864, 0x5877, 0x5aad, 0x5b23,
+ 0x5b59, 0x5e57, 0x6005, 0x606c, 0x619d, 0x6246, 0x6264, 0x650d,
+ 0x6516, 0x6651, 0x6666, 0x6689, 0x66a0, 0x6742, 0x677e, 0x681d,
+ 0x6c32, 0x6c45, 0x6d58, 0x6ded, 0x71a4, 0x71a5, 0x75e1, 0x775e,
+ 0x77cb, 0x792a, 0x7adb, 0x7e04, 0x7e16, 0x7e44, 0x7e4a, 0x7ecb,
+ 0x895d, 0x8b01, 0x8b0d, 0x8b1b, 0x8b1e, 0x8b2a, 0x8b4a, 0x8ef0,
+ 0x8f66, 0x912a, 0x940e, 0x95ad, 0x97d6, 0x99e9
};
/*Collect the unicode lists and glyph_id offsets*/
@@ -2227,7 +2307,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
},
{
.range_start = 163, .range_length = 39402, .glyph_id_start = 95,
- .unicode_list = unicode_list_2, .glyph_id_ofs_list = NULL, .list_length = 66, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
+ .unicode_list = unicode_list_2, .glyph_id_ofs_list = NULL, .list_length = 70, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
}
};
@@ -2259,7 +2339,7 @@ static const uint8_t kern_left_class_mapping[] =
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0
+ 0, 0, 0, 0, 0
};
/*Map glyph_ids to kern right classes*/
@@ -2285,7 +2365,7 @@ static const uint8_t kern_right_class_mapping[] =
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0
+ 0, 0, 0, 0, 0
};
/*Kern values between classes*/
### src/ui/gui_assets/font/es/esLittleTitle.c
@@ -1,7 +1,7 @@
/*******************************************************************************
* Size: 28 px
* Bpp: 1
- * Opts: --bpp 1 --size 28 --no-compress --font NotoSans-Regular.ttf --symbols "!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~¡£¥·¿Éáéíñóú€知通 --format lvgl -o ../gui_assets/font/es/esLittleTitle.c
+ * Opts: --bpp 1 --size 28 --no-compress --font NotoSans-Regular.ttf --symbols !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~¡£¥·¿Éáéíñóú€ --format lvgl -o ../gui_assets/font/es/esLittleTitle.c
******************************************************************************/
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
@@ -28,9 +28,6 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = {
/* U+0021 "!" */
0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x1f, 0xf0,
- /* U+0022 "\"" */
- 0xc7, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6,
-
/* U+0023 "#" */
0x3, 0xc, 0x1, 0x86, 0x0, 0xc3, 0x0, 0x61,
0x80, 0x70, 0xc0, 0x30, 0xc1, 0xff, 0xfe, 0xff,
@@ -685,119 +682,118 @@ static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = {
{.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */,
{.bitmap_index = 0, .adv_w = 116, .box_w = 1, .box_h = 1, .ofs_x = 0, .ofs_y = 0},
{.bitmap_index = 1, .adv_w = 121, .box_w = 3, .box_h = 20, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 9, .adv_w = 183, .box_w = 8, .box_h = 7, .ofs_x = 2, .ofs_y = 13},
- {.bitmap_index = 16, .adv_w = 289, .box_w = 17, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 59, .adv_w = 256, .box_w = 13, .box_h = 23, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 97, .adv_w = 372, .box_w = 21, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 150, .adv_w = 328, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 198, .adv_w = 101, .box_w = 2, .box_h = 7, .ofs_x = 2, .ofs_y = 13},
- {.bitmap_index = 200, .adv_w = 134, .box_w = 7, .box_h = 24, .ofs_x = 1, .ofs_y = -4},
- {.bitmap_index = 221, .adv_w = 134, .box_w = 7, .box_h = 24, .ofs_x = 1, .ofs_y = -4},
- {.bitmap_index = 242, .adv_w = 247, .box_w = 13, .box_h = 12, .ofs_x = 1, .ofs_y = 9},
- {.bitmap_index = 262, .adv_w = 256, .box_w = 13, .box_h = 13, .ofs_x = 1, .ofs_y = 3},
- {.bitmap_index = 284, .adv_w = 120, .box_w = 4, .box_h = 6, .ofs_x = 1, .ofs_y = -4},
- {.bitmap_index = 287, .adv_w = 144, .box_w = 7, .box_h = 2, .ofs_x = 1, .ofs_y = 6},
- {.bitmap_index = 289, .adv_w = 120, .box_w = 3, .box_h = 3, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 291, .adv_w = 167, .box_w = 10, .box_h = 20, .ofs_x = 0, .ofs_y = 0},
- {.bitmap_index = 316, .adv_w = 256, .box_w = 14, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 351, .adv_w = 256, .box_w = 8, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
- {.bitmap_index = 371, .adv_w = 256, .box_w = 13, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 404, .adv_w = 256, .box_w = 13, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 437, .adv_w = 256, .box_w = 15, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 475, .adv_w = 256, .box_w = 13, .box_h = 20, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 508, .adv_w = 256, .box_w = 13, .box_h = 20, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 541, .adv_w = 256, .box_w = 13, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 574, .adv_w = 256, .box_w = 14, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 609, .adv_w = 256, .box_w = 13, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 642, .adv_w = 120, .box_w = 3, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 648, .adv_w = 120, .box_w = 4, .box_h = 18, .ofs_x = 1, .ofs_y = -3},
- {.bitmap_index = 657, .adv_w = 256, .box_w = 13, .box_h = 14, .ofs_x = 1, .ofs_y = 3},
- {.bitmap_index = 680, .adv_w = 256, .box_w = 13, .box_h = 7, .ofs_x = 2, .ofs_y = 6},
- {.bitmap_index = 692, .adv_w = 256, .box_w = 13, .box_h = 14, .ofs_x = 1, .ofs_y = 3},
- {.bitmap_index = 715, .adv_w = 194, .box_w = 11, .box_h = 20, .ofs_x = 0, .ofs_y = 0},
- {.bitmap_index = 743, .adv_w = 403, .box_w = 22, .box_h = 22, .ofs_x = 2, .ofs_y = -2},
- {.bitmap_index = 804, .adv_w = 286, .box_w = 18, .box_h = 20, .ofs_x = 0, .ofs_y = 0},
- {.bitmap_index = 849, .adv_w = 291, .box_w = 14, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
- {.bitmap_index = 884, .adv_w = 283, .box_w = 15, .box_h = 20, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 922, .adv_w = 327, .box_w = 16, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
- {.bitmap_index = 962, .adv_w = 249, .box_w = 11, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
- {.bitmap_index = 990, .adv_w = 233, .box_w = 11, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
- {.bitmap_index = 1018, .adv_w = 326, .box_w = 17, .box_h = 20, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 1061, .adv_w = 332, .box_w = 16, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
- {.bitmap_index = 1101, .adv_w = 152, .box_w = 7, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 1119, .adv_w = 122, .box_w = 8, .box_h = 25, .ofs_x = -2, .ofs_y = -5},
- {.bitmap_index = 1144, .adv_w = 277, .box_w = 15, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
- {.bitmap_index = 1182, .adv_w = 235, .box_w = 12, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
- {.bitmap_index = 1212, .adv_w = 406, .box_w = 20, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
- {.bitmap_index = 1262, .adv_w = 340, .box_w = 16, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
- {.bitmap_index = 1302, .adv_w = 350, .box_w = 19, .box_h = 20, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 1350, .adv_w = 271, .box_w = 13, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
- {.bitmap_index = 1383, .adv_w = 350, .box_w = 19, .box_h = 25, .ofs_x = 2, .ofs_y = -5},
- {.bitmap_index = 1443, .adv_w = 279, .box_w = 14, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
- {.bitmap_index = 1478, .adv_w = 246, .box_w = 14, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 1513, .adv_w = 249, .box_w = 15, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 1551, .adv_w = 327, .box_w = 16, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
- {.bitmap_index = 1591, .adv_w = 269, .box_w = 17, .box_h = 20, .ofs_x = 0, .ofs_y = 0},
- {.bitmap_index = 1634, .adv_w = 417, .box_w = 26, .box_h = 20, .ofs_x = 0, .ofs_y = 0},
- {.bitmap_index = 1699, .adv_w = 263, .box_w = 16, .box_h = 20, .ofs_x = 0, .ofs_y = 0},
- {.bitmap_index = 1739, .adv_w = 254, .box_w = 17, .box_h = 20, .ofs_x = 0, .ofs_y = 0},
- {.bitmap_index = 1782, .adv_w = 256, .box_w = 14, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 1817, .adv_w = 147, .box_w = 7, .box_h = 24, .ofs_x = 2, .ofs_y = -4},
- {.bitmap_index = 1838, .adv_w = 167, .box_w = 10, .box_h = 20, .ofs_x = 0, .ofs_y = 0},
- {.bitmap_index = 1863, .adv_w = 147, .box_w = 7, .box_h = 24, .ofs_x = 1, .ofs_y = -4},
- {.bitmap_index = 1884, .adv_w = 256, .box_w = 14, .box_h = 13, .ofs_x = 1, .ofs_y = 7},
- {.bitmap_index = 1907, .adv_w = 199, .box_w = 13, .box_h = 2, .ofs_x = 0, .ofs_y = -4},
- {.bitmap_index = 1911, .adv_w = 126, .box_w = 6, .box_h = 5, .ofs_x = 1, .ofs_y = 17},
- {.bitmap_index = 1915, .adv_w = 251, .box_w = 12, .box_h = 15, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 1938, .adv_w = 276, .box_w = 14, .box_h = 21, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 1975, .adv_w = 215, .box_w = 11, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 1996, .adv_w = 276, .box_w = 14, .box_h = 21, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 2033, .adv_w = 253, .box_w = 13, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 2058, .adv_w = 154, .box_w = 11, .box_h = 21, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 2087, .adv_w = 276, .box_w = 14, .box_h = 22, .ofs_x = 2, .ofs_y = -7},
- {.bitmap_index = 2126, .adv_w = 277, .box_w = 13, .box_h = 21, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 2161, .adv_w = 116, .box_w = 3, .box_h = 21, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 2169, .adv_w = 116, .box_w = 7, .box_h = 28, .ofs_x = -1, .ofs_y = -7},
- {.bitmap_index = 2194, .adv_w = 239, .box_w = 13, .box_h = 21, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 2229, .adv_w = 116, .box_w = 3, .box_h = 21, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 2237, .adv_w = 419, .box_w = 21, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 2277, .adv_w = 277, .box_w = 13, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 2302, .adv_w = 271, .box_w = 14, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 2329, .adv_w = 276, .box_w = 14, .box_h = 22, .ofs_x = 2, .ofs_y = -7},
- {.bitmap_index = 2368, .adv_w = 276, .box_w = 14, .box_h = 22, .ofs_x = 2, .ofs_y = -7},
- {.bitmap_index = 2407, .adv_w = 185, .box_w = 9, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 2424, .adv_w = 215, .box_w = 11, .box_h = 15, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 2445, .adv_w = 162, .box_w = 9, .box_h = 19, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 2467, .adv_w = 277, .box_w = 13, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 2492, .adv_w = 228, .box_w = 14, .box_h = 15, .ofs_x = 0, .ofs_y = 0},
- {.bitmap_index = 2519, .adv_w = 352, .box_w = 22, .box_h = 15, .ofs_x = 0, .ofs_y = 0},
- {.bitmap_index = 2561, .adv_w = 237, .box_w = 14, .box_h = 15, .ofs_x = 0, .ofs_y = 0},
- {.bitmap_index = 2588, .adv_w = 228, .box_w = 14, .box_h = 22, .ofs_x = 0, .ofs_y = -7},
- {.bitmap_index = 2627, .adv_w = 211, .box_w = 11, .box_h = 15, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 2648, .adv_w = 170, .box_w = 10, .box_h = 24, .ofs_x = 0, .ofs_y = -4},
- {.bitmap_index = 2678, .adv_w = 247, .box_w = 2, .box_h = 28, .ofs_x = 7, .ofs_y = -7},
- {.bitmap_index = 2685, .adv_w = 170, .box_w = 9, .box_h = 24, .ofs_x = 1, .ofs_y = -4},
- {.bitmap_index = 2712, .adv_w = 256, .box_w = 13, .box_h = 4, .ofs_x = 1, .ofs_y = 8},
- {.bitmap_index = 2719, .adv_w = 121, .box_w = 3, .box_h = 19, .ofs_x = 2, .ofs_y = -4},
- {.bitmap_index = 2727, .adv_w = 256, .box_w = 14, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 2762, .adv_w = 256, .box_w = 15, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 2800, .adv_w = 120, .box_w = 3, .box_h = 3, .ofs_x = 2, .ofs_y = 8},
- {.bitmap_index = 2802, .adv_w = 194, .box_w = 11, .box_h = 20, .ofs_x = 1, .ofs_y = -5},
- {.bitmap_index = 2830, .adv_w = 249, .box_w = 11, .box_h = 26, .ofs_x = 3, .ofs_y = 0},
- {.bitmap_index = 2866, .adv_w = 251, .box_w = 12, .box_h = 22, .ofs_x = 1, .ofs_y = 0},
- {.bitmap_index = 2899, .adv_w = 253, .box_w = 13, .box_h = 22, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 2935, .adv_w = 116, .box_w = 6, .box_h = 21, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 2951, .adv_w = 277, .box_w = 13, .box_h = 20, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 2984, .adv_w = 271, .box_w = 14, .box_h = 22, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 3023, .adv_w = 277, .box_w = 13, .box_h = 22, .ofs_x = 2, .ofs_y = 0},
- {.bitmap_index = 3059, .adv_w = 256, .box_w = 15, .box_h = 20, .ofs_x = 1, .ofs_y = 0}
+ {.bitmap_index = 9, .adv_w = 289, .box_w = 17, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 52, .adv_w = 256, .box_w = 13, .box_h = 23, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 90, .adv_w = 372, .box_w = 21, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 143, .adv_w = 328, .box_w = 19, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 191, .adv_w = 101, .box_w = 2, .box_h = 7, .ofs_x = 2, .ofs_y = 13},
+ {.bitmap_index = 193, .adv_w = 134, .box_w = 7, .box_h = 24, .ofs_x = 1, .ofs_y = -4},
+ {.bitmap_index = 214, .adv_w = 134, .box_w = 7, .box_h = 24, .ofs_x = 1, .ofs_y = -4},
+ {.bitmap_index = 235, .adv_w = 247, .box_w = 13, .box_h = 12, .ofs_x = 1, .ofs_y = 9},
+ {.bitmap_index = 255, .adv_w = 256, .box_w = 13, .box_h = 13, .ofs_x = 1, .ofs_y = 3},
+ {.bitmap_index = 277, .adv_w = 120, .box_w = 4, .box_h = 6, .ofs_x = 1, .ofs_y = -4},
+ {.bitmap_index = 280, .adv_w = 144, .box_w = 7, .box_h = 2, .ofs_x = 1, .ofs_y = 6},
+ {.bitmap_index = 282, .adv_w = 120, .box_w = 3, .box_h = 3, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 284, .adv_w = 167, .box_w = 10, .box_h = 20, .ofs_x = 0, .ofs_y = 0},
+ {.bitmap_index = 309, .adv_w = 256, .box_w = 14, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 344, .adv_w = 256, .box_w = 8, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
+ {.bitmap_index = 364, .adv_w = 256, .box_w = 13, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 397, .adv_w = 256, .box_w = 13, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 430, .adv_w = 256, .box_w = 15, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 468, .adv_w = 256, .box_w = 13, .box_h = 20, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 501, .adv_w = 256, .box_w = 13, .box_h = 20, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 534, .adv_w = 256, .box_w = 13, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 567, .adv_w = 256, .box_w = 14, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 602, .adv_w = 256, .box_w = 13, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 635, .adv_w = 120, .box_w = 3, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 641, .adv_w = 120, .box_w = 4, .box_h = 18, .ofs_x = 1, .ofs_y = -3},
+ {.bitmap_index = 650, .adv_w = 256, .box_w = 13, .box_h = 14, .ofs_x = 1, .ofs_y = 3},
+ {.bitmap_index = 673, .adv_w = 256, .box_w = 13, .box_h = 7, .ofs_x = 2, .ofs_y = 6},
+ {.bitmap_index = 685, .adv_w = 256, .box_w = 13, .box_h = 14, .ofs_x = 1, .ofs_y = 3},
+ {.bitmap_index = 708, .adv_w = 194, .box_w = 11, .box_h = 20, .ofs_x = 0, .ofs_y = 0},
+ {.bitmap_index = 736, .adv_w = 403, .box_w = 22, .box_h = 22, .ofs_x = 2, .ofs_y = -2},
+ {.bitmap_index = 797, .adv_w = 286, .box_w = 18, .box_h = 20, .ofs_x = 0, .ofs_y = 0},
+ {.bitmap_index = 842, .adv_w = 291, .box_w = 14, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
+ {.bitmap_index = 877, .adv_w = 283, .box_w = 15, .box_h = 20, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 915, .adv_w = 327, .box_w = 16, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
+ {.bitmap_index = 955, .adv_w = 249, .box_w = 11, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
+ {.bitmap_index = 983, .adv_w = 233, .box_w = 11, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
+ {.bitmap_index = 1011, .adv_w = 326, .box_w = 17, .box_h = 20, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 1054, .adv_w = 332, .box_w = 16, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
+ {.bitmap_index = 1094, .adv_w = 152, .box_w = 7, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 1112, .adv_w = 122, .box_w = 8, .box_h = 25, .ofs_x = -2, .ofs_y = -5},
+ {.bitmap_index = 1137, .adv_w = 277, .box_w = 15, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
+ {.bitmap_index = 1175, .adv_w = 235, .box_w = 12, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
+ {.bitmap_index = 1205, .adv_w = 406, .box_w = 20, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
+ {.bitmap_index = 1255, .adv_w = 340, .box_w = 16, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
+ {.bitmap_index = 1295, .adv_w = 350, .box_w = 19, .box_h = 20, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 1343, .adv_w = 271, .box_w = 13, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
+ {.bitmap_index = 1376, .adv_w = 350, .box_w = 19, .box_h = 25, .ofs_x = 2, .ofs_y = -5},
+ {.bitmap_index = 1436, .adv_w = 279, .box_w = 14, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
+ {.bitmap_index = 1471, .adv_w = 246, .box_w = 14, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 1506, .adv_w = 249, .box_w = 15, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 1544, .adv_w = 327, .box_w = 16, .box_h = 20, .ofs_x = 3, .ofs_y = 0},
+ {.bitmap_index = 1584, .adv_w = 269, .box_w = 17, .box_h = 20, .ofs_x = 0, .ofs_y = 0},
+ {.bitmap_index = 1627, .adv_w = 417, .box_w = 26, .box_h = 20, .ofs_x = 0, .ofs_y = 0},
+ {.bitmap_index = 1692, .adv_w = 263, .box_w = 16, .box_h = 20, .ofs_x = 0, .ofs_y = 0},
+ {.bitmap_index = 1732, .adv_w = 254, .box_w = 17, .box_h = 20, .ofs_x = 0, .ofs_y = 0},
+ {.bitmap_index = 1775, .adv_w = 256, .box_w = 14, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 1810, .adv_w = 147, .box_w = 7, .box_h = 24, .ofs_x = 2, .ofs_y = -4},
+ {.bitmap_index = 1831, .adv_w = 167, .box_w = 10, .box_h = 20, .ofs_x = 0, .ofs_y = 0},
+ {.bitmap_index = 1856, .adv_w = 147, .box_w = 7, .box_h = 24, .ofs_x = 1, .ofs_y = -4},
+ {.bitmap_index = 1877, .adv_w = 256, .box_w = 14, .box_h = 13, .ofs_x = 1, .ofs_y = 7},
+ {.bitmap_index = 1900, .adv_w = 199, .box_w = 13, .box_h = 2, .ofs_x = 0, .ofs_y = -4},
+ {.bitmap_index = 1904, .adv_w = 126, .box_w = 6, .box_h = 5, .ofs_x = 1, .ofs_y = 17},
+ {.bitmap_index = 1908, .adv_w = 251, .box_w = 12, .box_h = 15, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 1931, .adv_w = 276, .box_w = 14, .box_h = 21, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 1968, .adv_w = 215, .box_w = 11, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 1989, .adv_w = 276, .box_w = 14, .box_h = 21, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 2026, .adv_w = 253, .box_w = 13, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 2051, .adv_w = 154, .box_w = 11, .box_h = 21, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 2080, .adv_w = 276, .box_w = 14, .box_h = 22, .ofs_x = 2, .ofs_y = -7},
+ {.bitmap_index = 2119, .adv_w = 277, .box_w = 13, .box_h = 21, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 2154, .adv_w = 116, .box_w = 3, .box_h = 21, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 2162, .adv_w = 116, .box_w = 7, .box_h = 28, .ofs_x = -1, .ofs_y = -7},
+ {.bitmap_index = 2187, .adv_w = 239, .box_w = 13, .box_h = 21, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 2222, .adv_w = 116, .box_w = 3, .box_h = 21, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 2230, .adv_w = 419, .box_w = 21, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 2270, .adv_w = 277, .box_w = 13, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 2295, .adv_w = 271, .box_w = 14, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 2322, .adv_w = 276, .box_w = 14, .box_h = 22, .ofs_x = 2, .ofs_y = -7},
+ {.bitmap_index = 2361, .adv_w = 276, .box_w = 14, .box_h = 22, .ofs_x = 2, .ofs_y = -7},
+ {.bitmap_index = 2400, .adv_w = 185, .box_w = 9, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 2417, .adv_w = 215, .box_w = 11, .box_h = 15, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 2438, .adv_w = 162, .box_w = 9, .box_h = 19, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 2460, .adv_w = 277, .box_w = 13, .box_h = 15, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 2485, .adv_w = 228, .box_w = 14, .box_h = 15, .ofs_x = 0, .ofs_y = 0},
+ {.bitmap_index = 2512, .adv_w = 352, .box_w = 22, .box_h = 15, .ofs_x = 0, .ofs_y = 0},
+ {.bitmap_index = 2554, .adv_w = 237, .box_w = 14, .box_h = 15, .ofs_x = 0, .ofs_y = 0},
+ {.bitmap_index = 2581, .adv_w = 228, .box_w = 14, .box_h = 22, .ofs_x = 0, .ofs_y = -7},
+ {.bitmap_index = 2620, .adv_w = 211, .box_w = 11, .box_h = 15, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 2641, .adv_w = 170, .box_w = 10, .box_h = 24, .ofs_x = 0, .ofs_y = -4},
+ {.bitmap_index = 2671, .adv_w = 247, .box_w = 2, .box_h = 28, .ofs_x = 7, .ofs_y = -7},
+ {.bitmap_index = 2678, .adv_w = 170, .box_w = 9, .box_h = 24, .ofs_x = 1, .ofs_y = -4},
+ {.bitmap_index = 2705, .adv_w = 256, .box_w = 13, .box_h = 4, .ofs_x = 1, .ofs_y = 8},
+ {.bitmap_index = 2712, .adv_w = 121, .box_w = 3, .box_h = 19, .ofs_x = 2, .ofs_y = -4},
+ {.bitmap_index = 2720, .adv_w = 256, .box_w = 14, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 2755, .adv_w = 256, .box_w = 15, .box_h = 20, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 2793, .adv_w = 120, .box_w = 3, .box_h = 3, .ofs_x = 2, .ofs_y = 8},
+ {.bitmap_index = 2795, .adv_w = 194, .box_w = 11, .box_h = 20, .ofs_x = 1, .ofs_y = -5},
+ {.bitmap_index = 2823, .adv_w = 249, .box_w = 11, .box_h = 26, .ofs_x = 3, .ofs_y = 0},
+ {.bitmap_index = 2859, .adv_w = 251, .box_w = 12, .box_h = 22, .ofs_x = 1, .ofs_y = 0},
+ {.bitmap_index = 2892, .adv_w = 253, .box_w = 13, .box_h = 22, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 2928, .adv_w = 116, .box_w = 6, .box_h = 21, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 2944, .adv_w = 277, .box_w = 13, .box_h = 20, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 2977, .adv_w = 271, .box_w = 14, .box_h = 22, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 3016, .adv_w = 277, .box_w = 13, .box_h = 22, .ofs_x = 2, .ofs_y = 0},
+ {.bitmap_index = 3052, .adv_w = 256, .box_w = 15, .box_h = 20, .ofs_x = 1, .ofs_y = 0}
};
/*---------------------
* CHARACTER MAPPING
*--------------------*/
-static const uint16_t unicode_list_1[] = {
+static const uint16_t unicode_list_2[] = {
0x0, 0x2, 0x4, 0x16, 0x1e, 0x28, 0x40, 0x48,
0x4c, 0x50, 0x52, 0x59, 0x200b
};
@@ -806,12 +802,16 @@ static const uint16_t unicode_list_1[] = {
static const lv_font_fmt_txt_cmap_t cmaps[] =
{
{
- .range_start = 32, .range_length = 95, .glyph_id_start = 1,
+ .range_start = 32, .range_length = 2, .glyph_id_start = 1,
+ .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
+ },
+ {
+ .range_start = 35, .range_length = 92, .glyph_id_start = 3,
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
},
{
- .range_start = 161, .range_length = 8204, .glyph_id_start = 96,
- .unicode_list = unicode_list_1, .glyph_id_ofs_list = NULL, .list_length = 13, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
+ .range_start = 161, .range_length = 8204, .glyph_id_start = 95,
+ .unicode_list = unicode_list_2, .glyph_id_ofs_list = NULL, .list_length = 13, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY
}
};
@@ -836,7 +836,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = {
.cmaps = cmaps,
.kern_dsc = NULL,
.kern_scale = 0,
- .cmap_num = 2,
+ .cmap_num = 3,
.bpp = 1,
.kern_classes = 0,
.bitmap_format = 0,
### src/ui/gui_assets/font/ja/jaIllustrate.c
[binary or diff unavailable]
### src/ui/gui_assets/font/ja/jaLittleTitle.c
[binary or diff unavailable]
### src/ui/gui_assets/font/ja/jaText.c
[binary or diff unavailable]
### src/ui/gui_assets/font/ja/jaTitle.c
[binary or diff unavailable]
### src/ui/gui_assets/font/ko/koIllustrate.c
[binary or diff unavailable]
### src/ui/gui_assets/font/ko/koText.c
[binary or diff unavailable]
### src/ui/gui_assets/font/ko/koTitle.c
[binary or diff unavailable]
### src/ui/gui_assets/font/ru/ruTitle.c
[binary or diff unavailable]
### src/ui/gui_assets/images_hash.txt
[binary or diff unavailable]
### src/ui/gui_assets/img/imgVerifyAddress.c
[binary or diff unavailable]
### src/ui/gui_assets/wallet/walletBeacon.c
[binary or diff unavailable]
### src/ui/gui_assets/wallet/walletKeeper.c
[binary or diff unavailable]
### src/ui/gui_chain/gui_btc.c
[binary or diff unavailable]
### src/ui/gui_chain/gui_chain_components.c
[binary or diff unavailable]
### src/ui/gui_chain/gui_chain_components.h
[binary or diff unavailable]
### src/ui/gui_chain/multi/cypherpunk/gui_monero.c
[binary or diff unavailable]
### src/ui/gui_chain/multi/cypherpunk/gui_monero.h
[binary or diff unavailable]
### src/ui/gui_chain/multi/gui_zcash.c
[binary or diff unavailable]
### src/ui/gui_chain/multi/web3/gui_ada.c
[binary or diff unavailable]
### src/ui/gui_chain/multi/web3/gui_cosmos.c
[binary or diff unavailable]
### src/ui/gui_chain/multi/web3/gui_sol.c
[binary or diff unavailable]
### src/ui/gui_chain/multi/web3/gui_sol.h
[binary or diff unavailable]
### src/ui/gui_chain/multi/web3/gui_stellar.c
[binary or diff unavailable]
### src/ui/gui_chain/multi/web3/gui_sui.c
[binary or diff unavailable]
### src/ui/gui_chain/multi/web3/gui_ton.c
[binary or diff unavailable]
### src/ui/gui_chain/multi/web3/gui_trx.c
[binary or diff unavailable]
### src/ui/gui_chain/multi/web3/gui_trx.h
[binary or diff unavailable]
### src/ui/gui_components/gui_button.c
[binary or diff unavailable]
### src/ui/gui_components/gui_button.h
[binary or diff unavailable]
### src/ui/gui_components/gui_hintbox.c
[binary or diff unavailable]
### src/ui/gui_components/gui_hintbox.h
[binary or diff unavailable]
### src/ui/gui_components/gui_status_bar.c
[binary or diff unavailable]
### src/ui/gui_frame/gui.h
[binary or diff unavailable]
### src/ui/gui_frame/gui_api.c
[binary or diff unavailable]
### src/ui/gui_frame/gui_framework.c
[binary or diff unavailable]
### src/ui/gui_frame/gui_obj.h
[binary or diff unavailable]
### src/ui/gui_frame/gui_resource.h
[binary or diff unavailable]
### src/ui/gui_model/gui_model.c
[binary or diff unavailable]
### src/ui/gui_model/gui_model.h
[binary or diff unavailable]
### src/ui/gui_views/gui_create_share_view.c
[binary or diff unavailable]
### src/ui/gui_views/gui_import_phrase_view.c
[binary or diff unavailable]
### src/ui/gui_views/gui_import_share_view.c
[binary or diff unavailable]
### src/ui/gui_views/gui_setting_view.c
[binary or diff unavailable]
### src/ui/gui_views/gui_single_phrase_view.c
[binary or diff unavailable]
### src/ui/gui_views/gui_transaction_detail_view.c
[binary or diff unavailable]
### src/ui/gui_views/gui_views.c
[binary or diff unavailable]
### src/ui/gui_views/gui_views.h
[binary or diff unavailable]
### src/ui/gui_views/multi/cypherpunk/gui_zcash_verify_result_view.c
[binary or diff unavailable]
### src/ui/gui_views/multi/cypherpunk/gui_zcash_verify_view.c
[binary or diff unavailable]
### src/ui/gui_wallet/multi/web3/gui_wallet.c
[binary or diff unavailable]
### src/ui/gui_widgets/btc_only/gui_home_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/btc_only/multi_sig/gui_multisig_transaction_signature_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/btc_only/multi_sig/gui_multisig_wallet_export_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/btc_only/multi_sig/gui_multisig_wallet_export_widgets.h
[binary or diff unavailable]
### src/ui/gui_widgets/gui_connect_wallet_widgets.h
[binary or diff unavailable]
### src/ui/gui_widgets/gui_create_wallet_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/gui_enter_passcode.c
[binary or diff unavailable]
### src/ui/gui_widgets/gui_export_pubkey_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/gui_firmware_update_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/gui_forget_pass_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/gui_import_phrase_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/gui_lock_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/gui_passphrase_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/gui_purpose_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/gui_scan_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/gui_scan_widgets.h
[binary or diff unavailable]
### src/ui/gui_widgets/gui_setup_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/gui_setup_widgets.h
[binary or diff unavailable]
### src/ui/gui_widgets/gui_single_phrase_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/gui_transaction_detail_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/gui_transaction_detail_widgets.h
[binary or diff unavailable]
### src/ui/gui_widgets/gui_utxo_receive_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/gui_wallet_tutorial_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/gui_web_auth_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/multi/cypherpunk/gui_connect_wallet_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/multi/cypherpunk/gui_cypherpunk_home_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/multi/cypherpunk/gui_zcash_batch_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/multi/cypherpunk/gui_zcash_verify_result_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/multi/cypherpunk/gui_zcash_verify_result_widgets.h
[binary or diff unavailable]
### src/ui/gui_widgets/multi/cypherpunk/gui_zcash_verify_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/multi/cypherpunk/gui_zcash_verify_widgets.h
[binary or diff unavailable]
### src/ui/gui_widgets/multi/gui_key_derivation_request_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/multi/gui_standard_receive_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/multi/web3/gui_connect_wallet_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/multi/web3/gui_general_home_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/setting/gui_fingerprint_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/setting/gui_passphrase_setting_widgets.c
[binary or diff unavailable]
### src/ui/gui_widgets/setting/gui_setting_widgets.h
[binary or diff unavailable]
### src/ui/gui_widgets/setting/gui_wallet_setting_widgets.c
[binary or diff unavailable]
### src/ui/lv_i18n/data.csv
[binary or diff unavailable]
### src/ui/lv_i18n/get_font_contain.py
[binary or diff unavailable]
### src/ui/lv_i18n/lv_i18n.c
[binary or diff unavailable]
### src/utils/assert.c
[binary or diff unavailable]
### src/utils/assert.h
[binary or diff unavailable]
### src/utils/diagnostic_location.h
[binary or diff unavailable]
### src/utils/log/log_print.c
[binary or diff unavailable]
### ui_simulator/.gitignore
[binary or diff unavailable]
### ui_simulator/main.c
[binary or diff unavailable]
### ui_simulator/simulator_model.c
[binary or diff unavailable]
### ui_simulator/simulator_model.h
[binary or diff unavailable]
### ui_simulator/simulator_storage.c
[binary or diff unavailable]Why this scored 61/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.