You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
2.7 KiB

  1. // Copyright (C) 2018-2020, Zpalmtree
  2. //
  3. // Please see the included LICENSE file for more information.
  4. export interface WalletBackendJSON {
  5. walletFileFormatVersion: number;
  6. subWallets: SubWalletsJSON;
  7. walletSynchronizer: WalletSynchronizerJSON;
  8. }
  9. export interface WalletSynchronizerJSON {
  10. startTimestamp: number;
  11. startHeight: number;
  12. privateViewKey: string;
  13. transactionSynchronizerStatus: SynchronizationStatusJSON;
  14. }
  15. export interface SubWalletJSON {
  16. unspentInputs: TransactionInputJSON[];
  17. lockedInputs: TransactionInputJSON[];
  18. spentInputs: TransactionInputJSON[];
  19. unconfirmedIncomingAmounts: UnconfirmedInputJSON[];
  20. publicSpendKey: string;
  21. /* NULL_SECRET_KEY if view wallet */
  22. privateSpendKey: string;
  23. syncStartTimestamp: number;
  24. syncStartHeight: number;
  25. address: string;
  26. isPrimaryAddress: boolean;
  27. }
  28. export interface TransactionJSON {
  29. transfers: TransfersJSON[];
  30. hash: string;
  31. fee: number;
  32. blockHeight: number;
  33. timestamp: number;
  34. paymentID: string;
  35. unlockTime: number;
  36. isCoinbaseTransaction: boolean;
  37. }
  38. export interface SubWalletsJSON {
  39. publicSpendKeys: string[];
  40. subWallet: SubWalletJSON[];
  41. transactions: TransactionJSON[];
  42. lockedTransactions: TransactionJSON[];
  43. privateViewKey: string;
  44. isViewWallet: boolean;
  45. txPrivateKeys: TxPrivateKeysJSON[];
  46. }
  47. export interface TxPrivateKeysJSON {
  48. transactionHash: string;
  49. txPrivateKey: string;
  50. }
  51. export function txPrivateKeysToVector(txPrivateKeys: Map<string, string>): TxPrivateKeysJSON[] {
  52. const arr: TxPrivateKeysJSON[] = [];
  53. for (const [hash, privateKey] of txPrivateKeys) {
  54. arr.push({transactionHash: hash, txPrivateKey: privateKey});
  55. }
  56. return arr;
  57. }
  58. export interface TransfersJSON {
  59. amount: number;
  60. publicKey: string;
  61. }
  62. export function transfersToVector(transfers: Map<string, number>): TransfersJSON[] {
  63. const arr: TransfersJSON[] = [];
  64. for (const [publicKey, amount] of transfers) {
  65. arr.push({amount, publicKey});
  66. }
  67. return arr;
  68. }
  69. export interface TransactionInputJSON {
  70. keyImage: string;
  71. amount: number;
  72. blockHeight: number;
  73. transactionPublicKey: string;
  74. transactionIndex: number;
  75. globalOutputIndex: number;
  76. key: string;
  77. spendHeight: number;
  78. unlockTime: number;
  79. parentTransactionHash: string;
  80. privateEphemeral?: string;
  81. }
  82. export interface UnconfirmedInputJSON {
  83. amount: number;
  84. key: string;
  85. parentTransactionHash: string;
  86. }
  87. export interface SynchronizationStatusJSON {
  88. blockHashCheckpoints: string[];
  89. lastKnownBlockHashes: string[];
  90. lastKnownBlockHeight: number;
  91. }