PageRenderTime 77ms CodeModel.GetById 40ms RepoModel.GetById 1ms app.codeStats 0ms

/src/outputtype.h

https://github.com/bitcoin/bitcoin
C Header | 54 lines | 28 code | 11 blank | 15 comment | 0 complexity | 2efcec9b210f24a0b34efb21e3ff97f0 MD5 | raw file
  1. // Copyright (c) 2009-2010 Satoshi Nakamoto
  2. // Copyright (c) 2009-2021 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. #ifndef BITCOIN_OUTPUTTYPE_H
  6. #define BITCOIN_OUTPUTTYPE_H
  7. #include <attributes.h>
  8. #include <script/signingprovider.h>
  9. #include <script/standard.h>
  10. #include <array>
  11. #include <optional>
  12. #include <string>
  13. #include <vector>
  14. enum class OutputType {
  15. LEGACY,
  16. P2SH_SEGWIT,
  17. BECH32,
  18. BECH32M,
  19. };
  20. static constexpr auto OUTPUT_TYPES = std::array{
  21. OutputType::LEGACY,
  22. OutputType::P2SH_SEGWIT,
  23. OutputType::BECH32,
  24. OutputType::BECH32M,
  25. };
  26. std::optional<OutputType> ParseOutputType(const std::string& str);
  27. const std::string& FormatOutputType(OutputType type);
  28. /**
  29. * Get a destination of the requested type (if possible) to the specified key.
  30. * The caller must make sure LearnRelatedScripts has been called beforehand.
  31. */
  32. CTxDestination GetDestinationForKey(const CPubKey& key, OutputType);
  33. /** Get all destinations (potentially) supported by the wallet for the given key. */
  34. std::vector<CTxDestination> GetAllDestinationsForKey(const CPubKey& key);
  35. /**
  36. * Get a destination of the requested type (if possible) to the specified script.
  37. * This function will automatically add the script (and any other
  38. * necessary scripts) to the keystore.
  39. */
  40. CTxDestination AddAndGetDestinationForScript(FillableSigningProvider& keystore, const CScript& script, OutputType);
  41. /** Get the OutputType for a CTxDestination */
  42. std::optional<OutputType> OutputTypeFromDestination(const CTxDestination& dest);
  43. #endif // BITCOIN_OUTPUTTYPE_H