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 <TrustWalletCore/TWAccount.h>
8

9
#include "../Keystore/Account.h"
10

11
using namespace TW;
12

13 0
struct TWAccount *_Nonnull TWAccountCreate(TWString *_Nonnull address, enum TWCoinType coin, TWString *_Nonnull derivationPath, TWString *_Nonnull extendedPublicKey) {
14 0
    auto& addressString = *reinterpret_cast<const std::string*>(address);
15 0
    auto& derivationPathString = *reinterpret_cast<const std::string*>(derivationPath);
16 0
    auto& extendedPublicKeyString = *reinterpret_cast<const std::string*>(extendedPublicKey);
17 0
    const auto dp = DerivationPath(derivationPathString);
18 0
    return new TWAccount{ Keystore::Account(addressString, coin, dp, extendedPublicKeyString) };
19
}
20

21 1
void TWAccountDelete(struct TWAccount *_Nonnull account) {
22 1
    delete account;
23
}
24

25 1
TWString *_Nonnull TWAccountAddress(struct TWAccount *_Nonnull account) {
26 1
    return TWStringCreateWithUTF8Bytes(account->impl.address.c_str());
27
}
28

29 0
TWString *_Nonnull TWAccountDerivationPath(struct TWAccount *_Nonnull account) {
30 0
    return TWStringCreateWithUTF8Bytes(account->impl.derivationPath.string().c_str());
31
}
32

33 0
TWString *_Nonnull TWAccountExtendedPublicKey(struct TWAccount *_Nonnull account) {
34 0
    return TWStringCreateWithUTF8Bytes(account->impl.extendedPublicKey.c_str());
35
}
36

37 0
enum TWCoinType TWAccountCoin(struct TWAccount *_Nonnull account) {
38 0
    return account->impl.coin;
39
}

Read our documentation on viewing source code .

Loading