Bitcoin Core  22.99.0
P2P Digital Currency
outputtype.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2020 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_OUTPUTTYPE_H
7 #define BITCOIN_OUTPUTTYPE_H
8 
9 #include <attributes.h>
10 #include <script/signingprovider.h>
11 #include <script/standard.h>
12 
13 #include <array>
14 #include <string>
15 #include <vector>
16 
17 enum class OutputType {
18  LEGACY,
20  BECH32,
21  BECH32M,
22 };
23 
24 static constexpr auto OUTPUT_TYPES = std::array{
29 };
30 
31 [[nodiscard]] bool ParseOutputType(const std::string& str, OutputType& output_type);
32 const std::string& FormatOutputType(OutputType type);
33 
39 
41 std::vector<CTxDestination> GetAllDestinationsForKey(const CPubKey& key);
42 
49 
51 std::optional<OutputType> OutputTypeFromDestination(const CTxDestination& dest);
52 
53 #endif // BITCOIN_OUTPUTTYPE_H
OutputType
OutputType
Definition: outputtype.h:17
FormatOutputType
const std::string & FormatOutputType(OutputType type)
Definition: outputtype.cpp:41
OUTPUT_TYPES
static constexpr auto OUTPUT_TYPES
Definition: outputtype.h:24
AddAndGetDestinationForScript
CTxDestination AddAndGetDestinationForScript(FillableSigningProvider &keystore, const CScript &script, OutputType)
Get a destination of the requested type (if possible) to the specified script.
Definition: outputtype.cpp:85
OutputType::LEGACY
@ LEGACY
FillableSigningProvider
Fillable signing provider that keeps keys in an address->secret map.
Definition: signingprovider.h:67
OutputType::BECH32M
@ BECH32M
signingprovider.h
CTxDestination
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
OutputTypeFromDestination
std::optional< OutputType > OutputTypeFromDestination(const CTxDestination &dest)
Get the OutputType for a CTxDestination.
Definition: outputtype.cpp:112
standard.h
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:404
attributes.h
OutputType::P2SH_SEGWIT
@ P2SH_SEGWIT
OutputType::BECH32
@ BECH32
GetAllDestinationsForKey
std::vector< CTxDestination > GetAllDestinationsForKey(const CPubKey &key)
Get all destinations (potentially) supported by the wallet for the given key.
Definition: outputtype.cpp:72
CPubKey
An encapsulated public key.
Definition: pubkey.h:32
ParseOutputType
bool ParseOutputType(const std::string &str, OutputType &output_type)
Definition: outputtype.cpp:23
GetDestinationForKey
CTxDestination GetDestinationForKey(const CPubKey &key, OutputType)
Get a destination of the requested type (if possible) to the specified key.
Definition: outputtype.cpp:52