This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
api.txt
132 lines (115 loc) · 4.33 KB
/
api.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
class Promise<ResolveType, RejectType>{};
class Error{
public string error_code;
public string error_message;
};
/*
* Error codes:
*
* ERROR_NOT_IMPLEMENTED
* ERROR_GENERIC (see error_message)
* ERROR_UNKNOWN_NETWORK
* ERROR_WALLET_NOT_FOUND
* ERROR_EXCHANGE_SAME_CURRENCY
* ERROR_INSUFFICIENT_FUNDS
* ERROR_CRITERION_NOT_SUPPORTED
* ERROR_UNSUPPORTED_CURRENCY
*
*/
enum SortCriterion{
newest_first,
oldest_first,
}
class Application{
public Promise<Wallet, Error> get_wallet_by_id(number id);
public Promise<List<CryptoNetwork>, ErrorCode> get_networks();
public Promise<CryptoNetwork, ErrorCode> get_network(string id);
public Promise<List<Wallet>, Error> get_wallets();
public Promise<Wallet, Error> create_wallet(string name, string network);
public Promise<Wallet, Error> wallet_from_phrase(string phrase, string network);
public Promise<List<Exchange>, Error> get_exchanges();
public Promise<List<TransactionRecord>, Error> get_history(number page, number page_size, SortCriterion criterion);
public Promise<bignum, Error> currency_conversion(bignum amount, string src_network, string dst_network);
public Promise<bool, Error> is_address_valid(string address, string network);
public Promise<void, Error> set_display_currency(string symbol);
public Promise<string[], Error> get_fiat_currencies();
public Promise<PortfolioElement, Error> get_portfolio();
}
class CryptoNetwork{
public string name; //E.g. BTC, ETH
public string display_name; //E.g. Bitcoind, Ethereum
public string symbol; //E.g. BTC, ETH
public number decimal_places;
public string image;
public bool is_testnet;
public string get_tx_explorer_url(string txid);
};
enum FeeWeight{
low,
normal,
high,
}
class Wallet{
public Promise<number, Error> get_id();
public Promise<string, Error> get_name();
public Promise<void, Error> set_name(string name);
public Promise<string, Error> get_network();
public Promise<string, Error> get_phrase();
public Promise<Amount, Error> get_balance();
public Promise<List<string>, Error> get_addresses();
public Promise<string, Error> generate_address();
public Promise<string, Error> get_receive_address();
public Promise<TxEstimation, Error> estimate_tx(string dst_address, bignum value, FeeWeight weight);
public Promise<List<TransactionRecord>, Error> get_history(number page, number page_size, SortCriterion criterion);
public Promise<void, Error> delete();
}
class Amount{
public bignum value;
public string unit;
public bignum fiat_value;
public string fiat_unit;
}
class TxEstimation{
public Amount amount;
public Amount fees;
public Amount total;
public Promise<SendTxResult, Error> confirm();
}
class SendTxResult{
public bool success;
public string tx_hash;
}
enum TransactionType{
transfer,
exchange,
};
class TransactionRecord{
public string type;
public Amount input;
public Amount output;
public Wallet src;
public Wallet dst;
public number timestamp;
public string tx_hash;
}
class Exchange{
public int get_model();
}
class ExchangeModel1 extends Exchange{
public Promise<ExchangeEstimation1, Error> estimate_exchange(Wallet src, Wallet dst, bignum src_amount);
}
class ExchangeEstimation1{
public Amount src_amount;
public Amount fees;
public Amount dst_amount;
public Promise<SendTxResult, Error> confirm();
}
class PortfolioElement{
public string currency; // cryptocurrency to which the element applies
public number balance; // in display currency
public number change; // in percentage
}
class Portfolio{
public PortfolioElement total;
public PortfolioElement[] currencies;
}