2017-09-19 18:12:25 -07:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
|
|
|
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
2022-05-11 15:47:12 -07:00
|
|
|
// Copyright (c) 2016-2022 The Zcash developers
|
2017-09-19 18:12:25 -07:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2019-07-18 07:16:09 -07:00
|
|
|
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
2017-09-19 18:12:25 -07:00
|
|
|
|
2018-03-22 07:19:44 -07:00
|
|
|
#ifndef BITCOIN_KEY_IO_H
|
|
|
|
#define BITCOIN_KEY_IO_H
|
2017-09-19 18:12:25 -07:00
|
|
|
|
|
|
|
#include <chainparams.h>
|
|
|
|
#include <key.h>
|
|
|
|
#include <pubkey.h>
|
|
|
|
#include <script/standard.h>
|
|
|
|
#include <zcash/Address.hpp>
|
|
|
|
|
2020-07-09 17:00:45 -07:00
|
|
|
#include <vector>
|
2017-09-19 18:12:25 -07:00
|
|
|
#include <string>
|
|
|
|
|
2020-07-09 15:53:54 -07:00
|
|
|
class KeyIO {
|
|
|
|
private:
|
2020-07-09 17:00:45 -07:00
|
|
|
const KeyConstants& keyConstants;
|
2017-09-19 18:12:25 -07:00
|
|
|
|
2020-07-09 15:53:54 -07:00
|
|
|
public:
|
2020-07-09 17:00:45 -07:00
|
|
|
KeyIO(const KeyConstants& keyConstants): keyConstants(keyConstants) { }
|
2017-09-19 18:12:25 -07:00
|
|
|
|
2022-02-17 17:27:15 -08:00
|
|
|
CKey DecodeSecret(const std::string& str) const;
|
|
|
|
std::string EncodeSecret(const CKey& key) const;
|
2017-09-19 18:12:25 -07:00
|
|
|
|
2022-02-17 17:27:15 -08:00
|
|
|
CExtKey DecodeExtKey(const std::string& str) const;
|
|
|
|
std::string EncodeExtKey(const CExtKey& extkey) const;
|
|
|
|
CExtPubKey DecodeExtPubKey(const std::string& str) const;
|
|
|
|
std::string EncodeExtPubKey(const CExtPubKey& extpubkey) const;
|
2017-09-19 18:12:25 -07:00
|
|
|
|
2022-02-17 17:27:15 -08:00
|
|
|
std::string EncodeDestination(const CTxDestination& dest) const;
|
|
|
|
CTxDestination DecodeDestination(const std::string& str) const;
|
2017-09-19 18:12:25 -07:00
|
|
|
|
2022-02-17 17:27:15 -08:00
|
|
|
bool IsValidDestinationString(const std::string& str) const;
|
2020-07-09 15:53:54 -07:00
|
|
|
|
2022-02-17 17:27:15 -08:00
|
|
|
std::string EncodePaymentAddress(const libzcash::PaymentAddress& zaddr) const;
|
|
|
|
std::optional<libzcash::PaymentAddress> DecodePaymentAddress(const std::string& str) const;
|
|
|
|
bool IsValidPaymentAddressString(const std::string& str) const;
|
2020-07-09 15:53:54 -07:00
|
|
|
|
2022-02-17 17:27:15 -08:00
|
|
|
std::string EncodeViewingKey(const libzcash::ViewingKey& vk) const;
|
|
|
|
std::optional<libzcash::ViewingKey> DecodeViewingKey(const std::string& str) const;
|
2020-07-09 15:53:54 -07:00
|
|
|
|
2022-02-17 17:27:15 -08:00
|
|
|
std::string EncodeSpendingKey(const libzcash::SpendingKey& zkey) const;
|
|
|
|
std::optional<libzcash::SpendingKey> DecodeSpendingKey(const std::string& str) const;
|
2020-07-09 15:53:54 -07:00
|
|
|
};
|
2017-09-19 18:12:25 -07:00
|
|
|
|
2018-03-22 07:19:44 -07:00
|
|
|
#endif // BITCOIN_KEY_IO_H
|