|
|
|
@ -40,6 +40,12 @@
|
|
|
|
|
// Public interface for libwallet library
|
|
|
|
|
namespace Monero {
|
|
|
|
|
|
|
|
|
|
enum NetworkType : uint8_t {
|
|
|
|
|
MAINNET = 0,
|
|
|
|
|
TESTNET,
|
|
|
|
|
STAGENET
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
namespace Utils {
|
|
|
|
|
bool isAddressLocal(const std::string &hostaddr);
|
|
|
|
|
void onStartup();
|
|
|
|
@ -358,7 +364,10 @@ struct Wallet
|
|
|
|
|
virtual std::string address(uint32_t accountIndex = 0, uint32_t addressIndex = 0) const = 0;
|
|
|
|
|
std::string mainAddress() const { return address(0, 0); }
|
|
|
|
|
virtual std::string path() const = 0;
|
|
|
|
|
virtual bool testnet() const = 0;
|
|
|
|
|
virtual NetworkType nettype() const = 0;
|
|
|
|
|
bool mainnet() const { return nettype() == MAINNET; }
|
|
|
|
|
bool testnet() const { return nettype() == TESTNET; }
|
|
|
|
|
bool stagenet() const { return nettype() == STAGENET; }
|
|
|
|
|
//! returns current hard fork info
|
|
|
|
|
virtual void hardForkInfo(uint8_t &version, uint64_t &earliest_height) const = 0;
|
|
|
|
|
//! check if hard fork rules should be used
|
|
|
|
@ -529,9 +538,21 @@ struct Wallet
|
|
|
|
|
static uint64_t amountFromDouble(double amount);
|
|
|
|
|
static std::string genPaymentId();
|
|
|
|
|
static bool paymentIdValid(const std::string &paiment_id);
|
|
|
|
|
static bool addressValid(const std::string &str, bool testnet);
|
|
|
|
|
static bool keyValid(const std::string &secret_key_string, const std::string &address_string, bool isViewKey, bool testnet, std::string &error);
|
|
|
|
|
static std::string paymentIdFromAddress(const std::string &str, bool testnet);
|
|
|
|
|
static bool addressValid(const std::string &str, NetworkType nettype);
|
|
|
|
|
static bool addressValid(const std::string &str, bool testnet) // deprecated
|
|
|
|
|
{
|
|
|
|
|
return addressValid(str, testnet ? MAINNET : TESTNET);
|
|
|
|
|
}
|
|
|
|
|
static bool keyValid(const std::string &secret_key_string, const std::string &address_string, bool isViewKey, NetworkType nettype, std::string &error);
|
|
|
|
|
static bool keyValid(const std::string &secret_key_string, const std::string &address_string, bool isViewKey, bool testnet, std::string &error) // deprecated
|
|
|
|
|
{
|
|
|
|
|
return keyValid(secret_key_string, address_string, isViewKey, testnet ? TESTNET : MAINNET, error);
|
|
|
|
|
}
|
|
|
|
|
static std::string paymentIdFromAddress(const std::string &str, NetworkType nettype);
|
|
|
|
|
static std::string paymentIdFromAddress(const std::string &str, bool testnet) // deprecated
|
|
|
|
|
{
|
|
|
|
|
return paymentIdFromAddress(str, testnet ? TESTNET : MAINNET);
|
|
|
|
|
}
|
|
|
|
|
static uint64_t maximumAllowedAmount();
|
|
|
|
|
// Easylogger wrapper
|
|
|
|
|
static void init(const char *argv0, const char *default_log_base_name);
|
|
|
|
@ -750,47 +771,66 @@ struct WalletManager
|
|
|
|
|
* \param path Name of wallet file
|
|
|
|
|
* \param password Password of wallet file
|
|
|
|
|
* \param language Language to be used to generate electrum seed mnemonic
|
|
|
|
|
* \param nettype Network type
|
|
|
|
|
* \return Wallet instance (Wallet::status() needs to be called to check if created successfully)
|
|
|
|
|
*/
|
|
|
|
|
virtual Wallet * createWallet(const std::string &path, const std::string &password, const std::string &language, bool testnet = false) = 0;
|
|
|
|
|
virtual Wallet * createWallet(const std::string &path, const std::string &password, const std::string &language, NetworkType nettype = MAINNET) = 0;
|
|
|
|
|
Wallet * createWallet(const std::string &path, const std::string &password, const std::string &language, bool testnet = false) // deprecated
|
|
|
|
|
{
|
|
|
|
|
return createWallet(path, password, language, testnet ? TESTNET : MAINNET);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Opens existing wallet
|
|
|
|
|
* \param path Name of wallet file
|
|
|
|
|
* \param password Password of wallet file
|
|
|
|
|
* \param nettype Network type
|
|
|
|
|
* \return Wallet instance (Wallet::status() needs to be called to check if opened successfully)
|
|
|
|
|
*/
|
|
|
|
|
virtual Wallet * openWallet(const std::string &path, const std::string &password, bool testnet = false) = 0;
|
|
|
|
|
virtual Wallet * openWallet(const std::string &path, const std::string &password, NetworkType nettype = MAINNET) = 0;
|
|
|
|
|
Wallet * openWallet(const std::string &path, const std::string &password, bool testnet = false) // deprecated
|
|
|
|
|
{
|
|
|
|
|
return openWallet(path, password, testnet ? TESTNET : MAINNET);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief recovers existing wallet using mnemonic (electrum seed)
|
|
|
|
|
* \param path Name of wallet file to be created
|
|
|
|
|
* \param password Password of wallet file
|
|
|
|
|
* \param mnemonic mnemonic (25 words electrum seed)
|
|
|
|
|
* \param testnet testnet
|
|
|
|
|
* \param nettype Network type
|
|
|
|
|
* \param restoreHeight restore from start height
|
|
|
|
|
* \return Wallet instance (Wallet::status() needs to be called to check if recovered successfully)
|
|
|
|
|
*/
|
|
|
|
|
virtual Wallet * recoveryWallet(const std::string &path, const std::string &password, const std::string &mnemonic,
|
|
|
|
|
bool testnet = false, uint64_t restoreHeight = 0) = 0;
|
|
|
|
|
NetworkType nettype = MAINNET, uint64_t restoreHeight = 0) = 0;
|
|
|
|
|
Wallet * recoveryWallet(const std::string &path, const std::string &password, const std::string &mnemonic,
|
|
|
|
|
bool testnet = false, uint64_t restoreHeight = 0) // deprecated
|
|
|
|
|
{
|
|
|
|
|
return recoveryWallet(path, password, mnemonic, testnet ? TESTNET : MAINNET, restoreHeight);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \deprecated this method creates a wallet WITHOUT a passphrase, use the alternate recoverWallet() method
|
|
|
|
|
* \brief recovers existing wallet using mnemonic (electrum seed)
|
|
|
|
|
* \param path Name of wallet file to be created
|
|
|
|
|
* \param mnemonic mnemonic (25 words electrum seed)
|
|
|
|
|
* \param testnet testnet
|
|
|
|
|
* \param nettype Network type
|
|
|
|
|
* \param restoreHeight restore from start height
|
|
|
|
|
* \return Wallet instance (Wallet::status() needs to be called to check if recovered successfully)
|
|
|
|
|
*/
|
|
|
|
|
virtual Wallet * recoveryWallet(const std::string &path, const std::string &mnemonic, bool testnet = false, uint64_t restoreHeight = 0) = 0;
|
|
|
|
|
virtual Wallet * recoveryWallet(const std::string &path, const std::string &mnemonic, NetworkType nettype = MAINNET, uint64_t restoreHeight = 0) = 0;
|
|
|
|
|
Wallet * recoveryWallet(const std::string &path, const std::string &mnemonic, bool testnet = false, uint64_t restoreHeight = 0) // deprecated
|
|
|
|
|
{
|
|
|
|
|
return recoveryWallet(path, mnemonic, testnet ? TESTNET : MAINNET, restoreHeight);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief recovers existing wallet using keys. Creates a view only wallet if spend key is omitted
|
|
|
|
|
* \param path Name of wallet file to be created
|
|
|
|
|
* \param password Password of wallet file
|
|
|
|
|
* \param language language
|
|
|
|
|
* \param testnet testnet
|
|
|
|
|
* \param nettype Network type
|
|
|
|
|
* \param restoreHeight restore from start height
|
|
|
|
|
* \param addressString public address
|
|
|
|
|
* \param viewKeyString view key
|
|
|
|
@ -800,18 +840,29 @@ struct WalletManager
|
|
|
|
|
virtual Wallet * createWalletFromKeys(const std::string &path,
|
|
|
|
|
const std::string &password,
|
|
|
|
|
const std::string &language,
|
|
|
|
|
bool testnet,
|
|
|
|
|
NetworkType nettype,
|
|
|
|
|
uint64_t restoreHeight,
|
|
|
|
|
const std::string &addressString,
|
|
|
|
|
const std::string &viewKeyString,
|
|
|
|
|
const std::string &spendKeyString = "") = 0;
|
|
|
|
|
Wallet * createWalletFromKeys(const std::string &path,
|
|
|
|
|
const std::string &password,
|
|
|
|
|
const std::string &language,
|
|
|
|
|
bool testnet,
|
|
|
|
|
uint64_t restoreHeight,
|
|
|
|
|
const std::string &addressString,
|
|
|
|
|
const std::string &viewKeyString,
|
|
|
|
|
const std::string &spendKeyString = "") // deprecated
|
|
|
|
|
{
|
|
|
|
|
return createWalletFromKeys(path, password, language, testnet ? TESTNET : MAINNET, restoreHeight, addressString, viewKeyString, spendKeyString);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \deprecated this method creates a wallet WITHOUT a passphrase, use createWalletFromKeys(..., password, ...) instead
|
|
|
|
|
* \brief recovers existing wallet using keys. Creates a view only wallet if spend key is omitted
|
|
|
|
|
* \param path Name of wallet file to be created
|
|
|
|
|
* \param language language
|
|
|
|
|
* \param testnet testnet
|
|
|
|
|
* \param nettype Network type
|
|
|
|
|
* \param restoreHeight restore from start height
|
|
|
|
|
* \param addressString public address
|
|
|
|
|
* \param viewKeyString view key
|
|
|
|
@ -820,11 +871,21 @@ struct WalletManager
|
|
|
|
|
*/
|
|
|
|
|
virtual Wallet * createWalletFromKeys(const std::string &path,
|
|
|
|
|
const std::string &language,
|
|
|
|
|
bool testnet,
|
|
|
|
|
NetworkType nettype,
|
|
|
|
|
uint64_t restoreHeight,
|
|
|
|
|
const std::string &addressString,
|
|
|
|
|
const std::string &viewKeyString,
|
|
|
|
|
const std::string &spendKeyString = "") = 0;
|
|
|
|
|
Wallet * createWalletFromKeys(const std::string &path,
|
|
|
|
|
const std::string &language,
|
|
|
|
|
bool testnet,
|
|
|
|
|
uint64_t restoreHeight,
|
|
|
|
|
const std::string &addressString,
|
|
|
|
|
const std::string &viewKeyString,
|
|
|
|
|
const std::string &spendKeyString = "") // deprecated
|
|
|
|
|
{
|
|
|
|
|
return createWalletFromKeys(path, language, testnet ? TESTNET : MAINNET, restoreHeight, addressString, viewKeyString, spendKeyString);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Closes wallet. In case operation succeded, wallet object deleted. in case operation failed, wallet object not deleted
|
|
|
|
|