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
#pragma once
8

9
#include <TrustWalletCore/TWCoinType.h>
10

11
namespace TW::Bitcoin {
12

13
/// Interface for transaction fee calculator.
14 1
class FeeCalculator {
15
public:
16
    virtual int64_t calculate(int64_t inputs, int64_t outputs = 2, int64_t byteFee = 1) const = 0;
17
    virtual int64_t calculateSingleInput(int64_t byteFee) const = 0;
18
};
19

20
/// Default Bitcoin transaction fee calculator, non-segwit.
21 1
class DefaultFeeCalculator : public FeeCalculator {
22
public:
23
    int64_t calculate(int64_t inputs, int64_t outputs = 2, int64_t byteFee = 1) const override;
24
    int64_t calculateSingleInput(int64_t byteFee) const override;
25
  
26
    static DefaultFeeCalculator instance;
27
};
28

29
/// Return the fee calculator for the given coin.
30
FeeCalculator& getFeeCalculator(TWCoinType coinType);
31

32
} // namespace TW::Bitcoin

Read our documentation on viewing source code .

Loading