1
// Copyright © 2017-2020 Trust Wallet.
2
//
3
// This file is part of Trust. The full Trust copyright notice, including
4
// terms governing use, modification, and redistribution, is contained in the
5
// file LICENSE at the root of the source code distribution tree.
6

7
#include "WalletConsole.h"
8
#include "CommandExecutor.h"
9
#include "Keys.h"
10
#include "Coins.h"
11
#include "Util.h"
12
#include "Address.h"
13
#include "TonCoin.h"
14

15
#include "Base64.h"
16
#include "HexCoding.h"
17
#include "Data.h"
18

19
#include <iostream>
20
#include <vector>
21
#include <cassert>
22

23
namespace TW::WalletConsole {
24

25
using namespace std;
26
using namespace TW;
27

28

29 1
void WalletConsole::init() {
30 1
    _outst << endl;
31 1
    _outst << "Wallet-core Console                          (c) TrustWallet" << endl;
32 1
    _outst << "Type 'help' for list of commands." << endl;
33 1
    _outst << endl;
34

35 1
    _executor.init();
36
}
37

38 1
void WalletConsole::loop() {
39 1
    while (true) {
40 1
        _outst << "> ";
41 1
        string line;
42 1
        getline(_inst, line);
43 1
        Util::trimLeft(line);
44 1
        if (line.length() == 0) { continue; }
45 1
        if (isExit(line)) {
46 1
            break;
47
        }
48

49 1
        _executor.executeLine(line);
50
    }
51 1
    _outst << "Bye!" << endl << endl;
52
}
53

54 1
bool WalletConsole::isExit(const string& line) {
55 1
    if (line.length() < 4) return false;
56 1
    string first4 = line.substr(0, 4);
57 1
    if (first4 == "quit" || first4 == "exit") { return true; }
58 1
    return false;
59
}
60

61
} // namespace TW::WalletConsole

Read our documentation on viewing source code .

Loading