forked from trustwallet/wallet-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TransactionCompiler.h
34 lines (26 loc) · 1.55 KB
/
TransactionCompiler.h
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
// Copyright © 2017-2022 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
#pragma once
#include <TrustWalletCore/TWCoinType.h>
#include "Data.h"
#include "CoinEntry.h"
#include <string>
#include <vector>
namespace TW {
/// Non-core transaction utility methods, like building a transaction using an external signature
class TransactionCompiler {
public:
/// Build a coin-specific SigningInput protobuf transaction input, from simple transaction parameters
static Data buildInput(TWCoinType coinType, const std::string& from, const std::string& to, const std::string& amount, const std::string& asset, const std::string& memo, const std::string& chainId);
/// Obtain pre-signing hash of a transaction.
/// It will return a proto object named `PreSigningOutput` which will include hash.
/// We provide a default `PreSigningOutput` in TransactionCompiler.proto.
/// For some special coins, such as bitcoin, we will create a custom `PreSigningOutput` object in its proto file.
static Data preImageHashes(TWCoinType coinType, const Data& txInputData);
/// Compile a complete transation with an external signature, put together from transaction input and provided public key and signature
static Data compileWithSignatures(TWCoinType coinType, const Data& txInputData, const std::vector<Data>& signatures, const std::vector<Data>& publicKeys);
};
} // namespace TW