coins.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * This file is part of the Trezor project, https://trezor.io/
  3. *
  4. * Copyright (C) 2014 Pavol Rusnak <stick@satoshilabs.com>
  5. *
  6. * This library is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this library. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef __COINS_H__
  20. #define __COINS_H__
  21. #include <stdbool.h>
  22. #include <stdint.h>
  23. #include "../crypto/bip32.h"
  24. #include "../crypto/hasher.h"
  25. typedef struct _CoinInfo {
  26. const char *coin_name;
  27. const char *coin_shortcut;
  28. uint64_t maxfee_kb;
  29. const char *signed_message_header;
  30. uint32_t decimals;
  31. bool has_segwit;
  32. bool has_taproot;
  33. bool has_fork_id;
  34. bool force_bip143;
  35. bool decred;
  36. // address types > 0xFF represent a two-byte prefix in big-endian order
  37. uint32_t address_type;
  38. uint32_t address_type_p2sh;
  39. uint32_t xpub_magic;
  40. uint32_t xpub_magic_segwit_p2sh;
  41. uint32_t xpub_magic_segwit_native;
  42. uint32_t xpub_magic_multisig_segwit_p2sh;
  43. uint32_t xpub_magic_multisig_segwit_native;
  44. uint32_t fork_id;
  45. const char *bech32_prefix;
  46. const char *cashaddr_prefix;
  47. uint32_t coin_type;
  48. bool negative_fee;
  49. const char *curve_name;
  50. const curve_info *curve;
  51. bool extra_data;
  52. bool timestamp;
  53. bool overwintered;
  54. } CoinInfo;
  55. #include "coin_info.h"
  56. // SLIP-44 hardened coin type for Bitcoin
  57. #define SLIP44_BITCOIN 0x80000000
  58. // SLIP-44 hardened coin type for all Testnet coins
  59. #define SLIP44_TESTNET 0x80000001
  60. const CoinInfo *coinByName(const char *name);
  61. const CoinInfo *coinByAddressType(uint32_t address_type);
  62. const CoinInfo *coinBySlip44(uint32_t coin_type);
  63. bool coinExtractAddressType(const CoinInfo *coin, const char *addr,
  64. uint32_t *address_type);
  65. bool coinExtractAddressTypeRaw(const CoinInfo *coin, const uint8_t *addr_raw,
  66. uint32_t *address_type);
  67. #endif