mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
wallet: add -signer argument for external signer command
Create basic ExternalSigner class with contructor. A Signer(<cmd>) is added to CWallet on load if -signer=<cmd> is set.
This commit is contained in:
parent
f7eb7ecc67
commit
8cf543f96d
6 changed files with 49 additions and 1 deletions
|
@ -265,6 +265,7 @@ BITCOIN_CORE_H = \
|
||||||
wallet/crypter.h \
|
wallet/crypter.h \
|
||||||
wallet/db.h \
|
wallet/db.h \
|
||||||
wallet/dump.h \
|
wallet/dump.h \
|
||||||
|
wallet/external_signer.h \
|
||||||
wallet/feebumper.h \
|
wallet/feebumper.h \
|
||||||
wallet/fees.h \
|
wallet/fees.h \
|
||||||
wallet/ismine.h \
|
wallet/ismine.h \
|
||||||
|
@ -379,6 +380,7 @@ libbitcoin_wallet_a_SOURCES = \
|
||||||
wallet/crypter.cpp \
|
wallet/crypter.cpp \
|
||||||
wallet/db.cpp \
|
wallet/db.cpp \
|
||||||
wallet/dump.cpp \
|
wallet/dump.cpp \
|
||||||
|
wallet/external_signer.cpp \
|
||||||
wallet/feebumper.cpp \
|
wallet/feebumper.cpp \
|
||||||
wallet/fees.cpp \
|
wallet/fees.cpp \
|
||||||
wallet/interfaces.cpp \
|
wallet/interfaces.cpp \
|
||||||
|
|
|
@ -38,6 +38,7 @@ void DummyWalletInit::AddWalletOptions(ArgsManager& argsman) const
|
||||||
"-paytxfee=<amt>",
|
"-paytxfee=<amt>",
|
||||||
"-rescan",
|
"-rescan",
|
||||||
"-salvagewallet",
|
"-salvagewallet",
|
||||||
|
"-signer=<cmd>",
|
||||||
"-spendzeroconfchange",
|
"-spendzeroconfchange",
|
||||||
"-txconfirmtarget=<n>",
|
"-txconfirmtarget=<n>",
|
||||||
"-wallet=<path>",
|
"-wallet=<path>",
|
||||||
|
|
8
src/wallet/external_signer.cpp
Normal file
8
src/wallet/external_signer.cpp
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
// Copyright (c) 2018-2021 The Bitcoin Core developers
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#include <wallet/external_signer.h>
|
||||||
|
#include <util/system.h>
|
||||||
|
|
||||||
|
ExternalSigner::ExternalSigner(const std::string& command, const std::string& fingerprint): m_command(command), m_fingerprint(fingerprint) {}
|
34
src/wallet/external_signer.h
Normal file
34
src/wallet/external_signer.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
// Copyright (c) 2018-2021 The Bitcoin Core developers
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#ifndef BITCOIN_WALLET_EXTERNAL_SIGNER_H
|
||||||
|
#define BITCOIN_WALLET_EXTERNAL_SIGNER_H
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
|
#include <univalue.h>
|
||||||
|
|
||||||
|
class ExternalSignerException : public std::runtime_error {
|
||||||
|
public:
|
||||||
|
using std::runtime_error::runtime_error;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Enables interaction with an external signing device or service, such as
|
||||||
|
//! a hardware wallet. See doc/external-signer.md
|
||||||
|
class ExternalSigner
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
//! The command which handles interaction with the external signer.
|
||||||
|
std::string m_command;
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! @param[in] command the command which handles interaction with the external signer
|
||||||
|
//! @param[in] fingerprint master key fingerprint of the signer
|
||||||
|
ExternalSigner(const std::string& command, const std::string& fingerprint);
|
||||||
|
|
||||||
|
//! Master key fingerprint of the signer
|
||||||
|
std::string m_fingerprint;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BITCOIN_WALLET_EXTERNAL_SIGNER_H
|
|
@ -61,6 +61,9 @@ void WalletInit::AddWalletOptions(ArgsManager& argsman) const
|
||||||
argsman.AddArg("-paytxfee=<amt>", strprintf("Fee (in %s/kB) to add to transactions you send (default: %s)",
|
argsman.AddArg("-paytxfee=<amt>", strprintf("Fee (in %s/kB) to add to transactions you send (default: %s)",
|
||||||
CURRENCY_UNIT, FormatMoney(CFeeRate{DEFAULT_PAY_TX_FEE}.GetFeePerK())), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
CURRENCY_UNIT, FormatMoney(CFeeRate{DEFAULT_PAY_TX_FEE}.GetFeePerK())), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||||
argsman.AddArg("-rescan", "Rescan the block chain for missing wallet transactions on startup", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
argsman.AddArg("-rescan", "Rescan the block chain for missing wallet transactions on startup", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||||
|
#ifdef ENABLE_EXTERNAL_SIGNER
|
||||||
|
argsman.AddArg("-signer=<cmd>", "External signing tool, see docs/external-signer.md", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||||
|
#endif
|
||||||
argsman.AddArg("-spendzeroconfchange", strprintf("Spend unconfirmed change when sending transactions (default: %u)", DEFAULT_SPEND_ZEROCONF_CHANGE), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
argsman.AddArg("-spendzeroconfchange", strprintf("Spend unconfirmed change when sending transactions (default: %u)", DEFAULT_SPEND_ZEROCONF_CHANGE), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||||
argsman.AddArg("-txconfirmtarget=<n>", strprintf("If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: %u)", DEFAULT_TX_CONFIRM_TARGET), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
argsman.AddArg("-txconfirmtarget=<n>", strprintf("If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: %u)", DEFAULT_TX_CONFIRM_TARGET), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
|
||||||
argsman.AddArg("-wallet=<path>", "Specify wallet path to load at startup. Can be used multiple times to load multiple wallets. Path is to a directory containing wallet data and log files. If the path is not absolute, it is interpreted relative to <walletdir>. This only loads existing wallets and does not create new ones. For backwards compatibility this also accepts names of existing top-level data files in <walletdir>.", ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::WALLET);
|
argsman.AddArg("-wallet=<path>", "Specify wallet path to load at startup. Can be used multiple times to load multiple wallets. Path is to a directory containing wallet data and log files. If the path is not absolute, it is interpreted relative to <walletdir>. This only loads existing wallets and does not create new ones. For backwards compatibility this also accepts names of existing top-level data files in <walletdir>.", ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::WALLET);
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <wallet/coinselection.h>
|
#include <wallet/coinselection.h>
|
||||||
#include <wallet/crypter.h>
|
#include <wallet/crypter.h>
|
||||||
#include <wallet/scriptpubkeyman.h>
|
#include <wallet/scriptpubkeyman.h>
|
||||||
|
#include <wallet/external_signer.h>
|
||||||
#include <wallet/walletdb.h>
|
#include <wallet/walletdb.h>
|
||||||
#include <wallet/walletutil.h>
|
#include <wallet/walletutil.h>
|
||||||
|
|
||||||
|
@ -95,7 +96,6 @@ constexpr CAmount DEFAULT_TRANSACTION_MAXFEE{COIN / 10};
|
||||||
constexpr CAmount HIGH_TX_FEE_PER_KB{COIN / 100};
|
constexpr CAmount HIGH_TX_FEE_PER_KB{COIN / 100};
|
||||||
//! -maxtxfee will warn if called with a higher fee than this amount (in satoshis)
|
//! -maxtxfee will warn if called with a higher fee than this amount (in satoshis)
|
||||||
constexpr CAmount HIGH_MAX_TX_FEE{100 * HIGH_TX_FEE_PER_KB};
|
constexpr CAmount HIGH_MAX_TX_FEE{100 * HIGH_TX_FEE_PER_KB};
|
||||||
|
|
||||||
//! Pre-calculated constants for input size estimation in *virtual size*
|
//! Pre-calculated constants for input size estimation in *virtual size*
|
||||||
static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91;
|
static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue