diff --git a/images/coin/coinCacao.png b/images/coin/coinCacao.png new file mode 100644 index 000000000..dfadde1b7 Binary files /dev/null and b/images/coin/coinCacao.png differ diff --git a/rust/apps/cosmos/src/lib.rs b/rust/apps/cosmos/src/lib.rs index 86c5fded3..93b35307a 100644 --- a/rust/apps/cosmos/src/lib.rs +++ b/rust/apps/cosmos/src/lib.rs @@ -148,6 +148,45 @@ mod tests { } } + #[test] + fn test_parse_tx() { + // transfer cacao + let raw_tx = "0a570a500a0e2f74797065732e4d736753656e64123e0a14d2a392d2d0e98f64dd0f9aa422da9b37b21944501214ead5b280c71c6ae156ee581cff8c9147a64cca1f1a100a0472756e65120831303030303030301203626d79125a0a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2103b1f26f209231b1ee90a8c52a981038794195fd7e08c47df02ff8bb7c1ce2a43512040a020801180012061080cab5ee011a1474686f72636861696e2d6d61696e6e65742d763120bdb106"; + let data_type = transaction::structs::DataType::Direct; + let parsed_tx = parse(&hex::decode(raw_tx).unwrap(), data_type).unwrap(); + + let overview = parsed_tx.overview; + let network = overview.common.network; + assert_eq!("MAYAChain", network.as_str(),) + } + + #[test] + fn test_derive_mayachain_address_by_seed() { + let seed = [ + 150, 6, 60, 69, 19, 44, 132, 15, 126, 22, 101, 163, 185, 120, 20, 216, 235, 37, 134, + 243, 75, 217, 69, 240, 111, 161, 91, 147, 39, 238, 190, 53, 95, 101, 78, 129, 198, 35, + 58, 82, 20, 157, 122, 149, 234, 116, 134, 235, 141, 105, 145, 102, 245, 103, 126, 80, + 117, 41, 72, 37, 153, 98, 76, 220, + ]; + let path = "M/44'/931'/0'/0/0"; + let pub_key = + keystore::algorithms::secp256k1::get_public_key_by_seed(&seed, &path.to_string()) + .unwrap(); + let address = generate_address(pub_key, "maya").unwrap(); + assert_eq!("maya14vc9484wvt66f7upncl7hq8kcvdd7qm80gnre6", address); + } + + #[test] + fn test_derive_mayachain_address_by_xpub() { + { + let root_path = "44'/931'/0'"; + let root_xpub = "xpub6CexGUAW8CXpTAZ19JxEGRxt2g4W7YNc3XSopBxw27jjBWDF67KShM7JqUibfQpHTsjzBdEwAw9X7QsBTVxjRpgK3bUbhS4e3y6kVhUfkek"; + let hd_path = "44'/931'/0'/0/0"; + let address = derive_address(hd_path, root_xpub, root_path, "maya").unwrap(); + assert_eq!("maya14vc9484wvt66f7upncl7hq8kcvdd7qm80gnre6", address); + } + } + #[test] fn test_derive_address() { { diff --git a/rust/apps/cosmos/src/transaction/utils.rs b/rust/apps/cosmos/src/transaction/utils.rs index 11e0f0593..ad3808608 100644 --- a/rust/apps/cosmos/src/transaction/utils.rs +++ b/rust/apps/cosmos/src/transaction/utils.rs @@ -49,7 +49,9 @@ pub fn get_network_by_chain_id(chain_id: &str) -> Result { map.insert("quicksilver", "Quicksilver"); map.insert("phoenix", "Terra"); map.insert("columbus", "Terra Classic"); + map.insert("mayachain-mainnet", "MAYAChain"); map.insert("thorchain", "THORChain"); + let chain_id_parts: Vec<&str> = chain_id.split("-").collect(); let chain_id_prefix = if chain_id_parts.len() > 1 { chain_id_parts[..chain_id_parts.len() - 1].join("-") @@ -95,7 +97,9 @@ pub fn get_chain_id_by_address(address: &str) -> String { map.insert("kava", "kava_2222-10"); map.insert("quick", "quicksilver-1"); map.insert("terra", "phoenix-1"); + map.insert("maya", "mayachain-mainnet"); map.insert("thor", "thorchain"); + for (k, v) in map { if address.starts_with(k) { return v.to_string(); diff --git a/rust/apps/wallets/src/thor_wallet.rs b/rust/apps/wallets/src/thor_wallet.rs index 83a62f9e7..586a2995e 100644 --- a/rust/apps/wallets/src/thor_wallet.rs +++ b/rust/apps/wallets/src/thor_wallet.rs @@ -27,6 +27,7 @@ const BTC_SEGWIT_PREFIX: &str = "m/49'/0'/0'"; const BTC_NATIVE_SEGWIT_PREFIX: &str = "m/84'/0'/0'"; const ETH_STANDARD_PREFIX: &str = "m/44'/60'/0'"; const ETH_LEDGER_LIVE_PREFIX: &str = "m/44'/60'"; //overlap with ETH_STANDARD at 0 +const MAYACHAIN_PREFIX: &str = "m/44'/931'/0'"; const THORCHAIN_PREFIX: &str = "m/44'/931'/0'"; pub fn generate_crypto_multi_accounts( @@ -42,6 +43,7 @@ pub fn generate_crypto_multi_accounts( BTC_LEGACY_PREFIX.to_string(), BTC_SEGWIT_PREFIX.to_string(), BTC_NATIVE_SEGWIT_PREFIX.to_string(), + MAYACHAIN_PREFIX.to_string(), THORCHAIN_PREFIX.to_string(), ]; for ele in extended_public_keys { diff --git a/src/crypto/account_public_info.c b/src/crypto/account_public_info.c index c95541e0a..421c072ba 100644 --- a/src/crypto/account_public_info.c +++ b/src/crypto/account_public_info.c @@ -111,6 +111,7 @@ static const ChainItem_t g_chainTable[] = { {XPUB_TYPE_TERRA, SECP256K1, "terra", "M/44'/330'/0'" }, {XPUB_TYPE_XRP, SECP256K1, "xrp", "M/44'/144'/0'" }, {XPUB_TYPE_THOR, SECP256K1, "thor", "M/44'/931'/0'" }, + {XPUB_TYPE_MAYA, SECP256K1, "maya", "M/44'/931'/0'" }, {XPUB_TYPE_SOL_BIP44_0, ED25519, "sol_bip44_0", "M/44'/501'/0'" }, {XPUB_TYPE_SOL_BIP44_1, ED25519, "sol_bip44_1", "M/44'/501'/1'" }, {XPUB_TYPE_SOL_BIP44_2, ED25519, "sol_bip44_2", "M/44'/501'/2'" }, diff --git a/src/crypto/account_public_info.h b/src/crypto/account_public_info.h index 4d5331ace..e10b012da 100644 --- a/src/crypto/account_public_info.h +++ b/src/crypto/account_public_info.h @@ -44,6 +44,7 @@ typedef enum { XPUB_TYPE_TERRA, XPUB_TYPE_XRP, XPUB_TYPE_THOR, + XPUB_TYPE_MAYA, XPUB_TYPE_SOL_BIP44_0, XPUB_TYPE_SOL_BIP44_1, XPUB_TYPE_SOL_BIP44_2, diff --git a/src/ui/gui_chain/gui_chain.h b/src/ui/gui_chain/gui_chain.h index 6cc48699e..a85272a69 100644 --- a/src/ui/gui_chain/gui_chain.h +++ b/src/ui/gui_chain/gui_chain.h @@ -47,6 +47,7 @@ typedef enum { CHAIN_ATOM, CHAIN_CRO, CHAIN_RUNE, + CHAIN_CACAO, CHAIN_KAVA, CHAIN_LUNC, CHAIN_AXL, diff --git a/src/ui/gui_chain/others/gui_cosmos.c b/src/ui/gui_chain/others/gui_cosmos.c index f1bce002d..6cd665738 100644 --- a/src/ui/gui_chain/others/gui_cosmos.c +++ b/src/ui/gui_chain/others/gui_cosmos.c @@ -9,7 +9,7 @@ #include "user_memory.h" #include "account_manager.h" #include "gui_chain.h" -#define MAX_COSMOS_ADDR_LEN 61 +#define MAX_COSMOS_ADDR_LEN 62 static bool g_isMulti = false; static URParseResult *g_urResult = NULL; @@ -26,6 +26,7 @@ static const CosmosChain_t g_cosmosChains[COSMOS_CHAINS_LEN] = { {CHAIN_SCRT, "secret", 529, XPUB_TYPE_SCRT, "secret-4"}, {CHAIN_AKT, "akash", 118, XPUB_TYPE_COSMOS, "akashnet-2"}, {CHAIN_CRO, "cro", 394, XPUB_TYPE_CRO, "crypto-org-chain-mainnet-1"}, + {CHAIN_CACAO, "maya", 931, XPUB_TYPE_MAYA, "mayachain-mainnet-v1"}, {CHAIN_RUNE, "thor", 931, XPUB_TYPE_THOR, "thorchain-1"}, {CHAIN_IOV, "star", 234, XPUB_TYPE_IOV, "iov-mainnet-ibc"}, {CHAIN_ROWAN, "sif", 118, XPUB_TYPE_COSMOS, "sifchain-1"}, diff --git a/src/ui/gui_chain/others/gui_cosmos.h b/src/ui/gui_chain/others/gui_cosmos.h index ea0d5e60a..a72a40578 100644 --- a/src/ui/gui_chain/others/gui_cosmos.h +++ b/src/ui/gui_chain/others/gui_cosmos.h @@ -1,6 +1,6 @@ #include "rust.h" #include "account_public_info.h" -#define COSMOS_CHAINS_LEN 33 +#define COSMOS_CHAINS_LEN 34 typedef struct { uint8_t index; @@ -71,4 +71,4 @@ void GetCosmosTextOfKind(void *indata, void *param, uint32_t maxLen); void GetCosmosDetailItemValue(void *indata, void *param, uint32_t maxLen); bool IsCosmosMsg(ViewType viewType); char *GetKeplrConnectionDisplayAddressByIndex(uint32_t index); -char *GetCosmosChainAddressByCoinTypeAndIndex(uint8_t chainType, uint32_t address_index); \ No newline at end of file +char *GetCosmosChainAddressByCoinTypeAndIndex(uint8_t chainType, uint32_t address_index); diff --git a/src/ui/gui_components/gui_status_bar.c b/src/ui/gui_components/gui_status_bar.c index 29b610d21..e32d3daae 100644 --- a/src/ui/gui_components/gui_status_bar.c +++ b/src/ui/gui_components/gui_status_bar.c @@ -76,7 +76,7 @@ const static CoinWalletInfo_t g_coinWalletBtn[] = { {HOME_WALLET_CARD_COSMOS, "", &coinCosmos}, {HOME_WALLET_CARD_TIA, "", &coinTia}, {HOME_WALLET_CARD_DYM, "", &coinDym}, {HOME_WALLET_CARD_OSMO, "", &coinOsmo}, {HOME_WALLET_CARD_INJ, "", &coinInj}, {HOME_WALLET_CARD_ATOM, "", &coinAtom}, - {HOME_WALLET_CARD_CRO, "", &coinCro}, {HOME_WALLET_CARD_RUNE, "", &coinRune}, + {HOME_WALLET_CARD_CRO, "", &coinCro}, {HOME_WALLET_CARD_RUNE, "", &coinRune}, {HOME_WALLET_CARD_CACAO, "", &coinCacao}, {HOME_WALLET_CARD_KAVA, "", &coinKava}, {HOME_WALLET_CARD_LUNC, "", &coinLunc}, {HOME_WALLET_CARD_AXL, "", &coinAxl}, {HOME_WALLET_CARD_LUNA, "", &coinLuna}, {HOME_WALLET_CARD_AKT, "", &coinAkt}, {HOME_WALLET_CARD_STRD, "", &coinStrd}, {HOME_WALLET_CARD_SCRT, "", &coinScrt}, diff --git a/src/ui/gui_frame/gui_resource.h b/src/ui/gui_frame/gui_resource.h index 6bc67a5a2..12efff63b 100644 --- a/src/ui/gui_frame/gui_resource.h +++ b/src/ui/gui_frame/gui_resource.h @@ -228,6 +228,7 @@ LV_IMG_DECLARE(coinTrac); LV_IMG_DECLARE(coinSats); LV_IMG_DECLARE(coinXlm); LV_IMG_DECLARE(coinRune); +LV_IMG_DECLARE(coinCacao); LV_IMG_DECLARE(coinHelium); // wallet diff --git a/src/ui/gui_widgets/general/gui_home_widgets.c b/src/ui/gui_widgets/general/gui_home_widgets.c index 74de8c49c..d5788f0eb 100644 --- a/src/ui/gui_widgets/general/gui_home_widgets.c +++ b/src/ui/gui_widgets/general/gui_home_widgets.c @@ -65,6 +65,7 @@ static WalletState_t g_walletState[HOME_WALLET_CARD_BUTT] = { {HOME_WALLET_CARD_ATOM, false, "ATOM", true}, {HOME_WALLET_CARD_CRO, false, "CRO", true}, {HOME_WALLET_CARD_RUNE, false, "RUNE", true}, + {HOME_WALLET_CARD_CACAO, false, "CACAO", true}, {HOME_WALLET_CARD_KAVA, false, "KAVA", true}, {HOME_WALLET_CARD_LUNC, false, "LUNC", true}, {HOME_WALLET_CARD_AXL, false, "AXL", true}, @@ -279,6 +280,12 @@ static const ChainCoinCard_t g_coinCardArray[HOME_WALLET_CARD_BUTT] = { .chain = "THORChain", .icon = &coinRune, }, + { + .index = HOME_WALLET_CARD_CACAO, + .coin = "CACAO", + .chain = "MAYAChain", + .icon = &coinCacao, + }, { .index = HOME_WALLET_CARD_KAVA, .coin = "KAVA", diff --git a/src/ui/gui_widgets/general/gui_home_widgets.h b/src/ui/gui_widgets/general/gui_home_widgets.h index 6f9b787d6..bdd5b76c4 100644 --- a/src/ui/gui_widgets/general/gui_home_widgets.h +++ b/src/ui/gui_widgets/general/gui_home_widgets.h @@ -36,6 +36,7 @@ typedef enum { HOME_WALLET_CARD_ATOM, HOME_WALLET_CARD_CRO, HOME_WALLET_CARD_RUNE, + HOME_WALLET_CARD_CACAO, HOME_WALLET_CARD_KAVA, HOME_WALLET_CARD_LUNC, HOME_WALLET_CARD_AXL, diff --git a/src/ui/gui_widgets/general/gui_standard_receive_widgets.c b/src/ui/gui_widgets/general/gui_standard_receive_widgets.c index bfe99846d..38f741513 100644 --- a/src/ui/gui_widgets/general/gui_standard_receive_widgets.c +++ b/src/ui/gui_widgets/general/gui_standard_receive_widgets.c @@ -167,6 +167,7 @@ static uint32_t g_umeeChainSelectIndex[3] = {0}; static uint32_t g_qckChainSelectIndex[3] = {0}; static uint32_t g_tgdChainSelectIndex[3] = {0}; static uint32_t g_thorChainSelectIndex[3] = {0}; +static uint32_t g_mayaChainSelectIndex[3] = {0}; static PageWidget_t *g_pageWidget; static uint32_t g_selectedIndex[3] = {0}; @@ -984,6 +985,7 @@ void GuiResetCurrentStandardAddressIndex(uint8_t index) g_qckChainSelectIndex[index] = 0; g_tgdChainSelectIndex[index] = 0; g_thorChainSelectIndex[index] = 0; + g_mayaChainSelectIndex[index] = 0; } void GuiResetAllStandardAddressIndex(void) @@ -1026,6 +1028,7 @@ void GuiResetAllStandardAddressIndex(void) memset_s(g_qckChainSelectIndex, sizeof(g_qckChainSelectIndex), 0, sizeof(g_qckChainSelectIndex)); memset_s(g_tgdChainSelectIndex, sizeof(g_tgdChainSelectIndex), 0, sizeof(g_tgdChainSelectIndex)); memset_s(g_thorChainSelectIndex, sizeof(g_thorChainSelectIndex), 0, sizeof(g_thorChainSelectIndex)); + memset_s(g_mayaChainSelectIndex, sizeof(g_mayaChainSelectIndex), 0, sizeof(g_mayaChainSelectIndex)); } static uint32_t* GetCosmosChainCurrentSelectIndex() @@ -1130,6 +1133,9 @@ static uint32_t* GetCosmosChainCurrentSelectIndex() case HOME_WALLET_CARD_RUNE: return &g_thorChainSelectIndex[GetCurrentAccountIndex()]; break; + case HOME_WALLET_CARD_CACAO: + return &g_mayaChainSelectIndex[GetCurrentAccountIndex()]; + break; default: return NULL; diff --git a/src/ui/gui_widgets/gui_connect_wallet_widgets.c b/src/ui/gui_widgets/gui_connect_wallet_widgets.c index 8a8e0dcc0..5fb0b10cc 100644 --- a/src/ui/gui_widgets/gui_connect_wallet_widgets.c +++ b/src/ui/gui_widgets/gui_connect_wallet_widgets.c @@ -181,11 +181,12 @@ static const lv_img_dsc_t *g_tonKeeperCoinArray[1] = { &coinTon, }; -static const lv_img_dsc_t *g_ThorWalletCoinArray[3] = { +static const lv_img_dsc_t *g_ThorWalletCoinArray[4] = { // todo thorchain will support bitcoin later // &coinBtc, &coinEth, &coinRune, + &coinCacao, }; static CoinState_t g_defaultFewchaState[FEWCHA_COINS_BUTT] = { @@ -2068,4 +2069,4 @@ void GuiConnectWalletDeInit(void) uint8_t GuiConnectWalletGetWalletIndex(void) { return g_connectWalletTileView.walletIndex; -} \ No newline at end of file +} diff --git a/src/ui/wallet/gui_wallet.c b/src/ui/wallet/gui_wallet.c index 06b3399fc..3d548c5f1 100644 --- a/src/ui/wallet/gui_wallet.c +++ b/src/ui/wallet/gui_wallet.c @@ -731,12 +731,13 @@ UREncodeResult *GuiGetBackpackData(void) UREncodeResult *GuiGetThorWalletBtcData(void) { + uint8_t mfp[4] = {0}; GetMasterFingerPrint(mfp); PtrT_CSliceFFI_ExtendedPublicKey public_keys = SRAM_MALLOC(sizeof(CSliceFFI_ExtendedPublicKey)); - ExtendedPublicKey keys[5]; + ExtendedPublicKey keys[6]; public_keys->data = keys; public_keys->size = 5; keys[0].path = "m/84'/0'/0'"; @@ -749,6 +750,8 @@ UREncodeResult *GuiGetThorWalletBtcData(void) keys[3].xpub = GetCurrentAccountPublicKey(XPUB_TYPE_THOR); keys[4].path = "m/44'/60'/0'"; keys[4].xpub = GetCurrentAccountPublicKey(XPUB_TYPE_ETH_BIP44_STANDARD); + keys[5].path = "m/44'/931'/0'"; + keys[5].xpub = GetCurrentAccountPublicKey(XPUB_TYPE_MAYA); char serialNumber[256]; GetSerialNumber(serialNumber);