Skip to content

Commit

Permalink
Merge pull request #885 from qtumproject/time/guihwi
Browse files Browse the repository at this point in the history
Add GUI support for hardware wallet
  • Loading branch information
qtum-neil authored Nov 25, 2021
2 parents a8362fe + bf6f871 commit f5a195c
Show file tree
Hide file tree
Showing 100 changed files with 5,773 additions and 430 deletions.
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AC_PREREQ([2.69])
define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 20)
define(_CLIENT_VERSION_REVISION, 3)
define(_CLIENT_VERSION_REVISION, 4)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_RC, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
Expand Down Expand Up @@ -1360,7 +1360,7 @@ fi
# These packages don't provide pkgconfig config files across all
# platforms, so we use older autoconf detection mechanisms:
AC_CHECK_HEADER([gmp.h],,AC_MSG_ERROR(libgmp headers missing))
AC_CHECK_LIB([gmp],[[__gmpn_sub_n]],GMP_LIBS=-lgmp, [AC_MSG_ERROR(libgmp missing)])
AC_CHECK_LIB([gmp],[__gmpn_sub_n],GMP_LIBS=-lgmp, [AC_MSG_ERROR(libgmp missing)])

AC_CHECK_HEADER([gmpxx.h],,AC_MSG_ERROR(libgmpxx headers missing))
AC_CHECK_LIB([gmpxx],[main],GMPXX_LIBS=-lgmpxx, [AC_MSG_ERROR(libgmpxx missing)])
Expand Down
39 changes: 39 additions & 0 deletions doc/hardware-wallet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
HARDWARE WALLET
====================

## Tools for hardware device support

Use [Ledger Nano S Loader](https://github.com/qtumproject/qtum-ledger-loader/releases) to install the Ledger Nano S Wallet and Ledger Nano S Stake application.

Use [HWI](https://github.com/qtumproject/HWI) for command line interaction with the Hardware Wallet.

## Graphical interface for hardware device

`qtum-qt` provides an interface for interacting with hardware wallet devices.

Set the HWI tool path using the the menu `Settings -> Option -> Main -> HWI Tool Path` and restart `qtum-qt`, the tool is needed for hardware wallet interaction.

Use the menu `File -> Create Wallet... -> Use a hardware device` for creating hardware wallet. The hardware wallet needs to be connected and the wallet application started.

Use hardware wallets to send/receive coins.

Ledger Nano S has support for smart contracts using the wallet application that can be installed with [Ledger Nano S Loader](https://github.com/qtumproject/qtum-ledger-loader/releases), it also supports delegation to a staker for offline staking.

## Graphical interface for hardware device staking

Ledger Nano S has support for staking using the staking application that can be installed with [Ledger Nano S Loader](https://github.com/qtumproject/qtum-ledger-loader/releases).

Using the menu `Settings -> Option -> Main -> Select Ledger device for staking` to select ledger for staking that the `qtum-qt` will automatically connect when started.

The staking will be active until the application is closed and will be automatically started when `qtum-qt` is started and the staking wallet is loaded.

## Command line interface for hardware device staking

`qtumd -hwitoolpath=<HWI Tool Path> -stakerledgerid=<Ledger device for staking> -wallet <Hardware wallet>`

`<HWI Tool Path>` is the location where the HWI is installed. In GUI, the value in menu `Settings -> Option -> Main -> HWI Tool Path`.

`<Ledger device for staking>` is the ledger fingerprint that will be used for staking. In GUI, the value in menu `Settings -> Option -> Main -> Select Ledger device for staking`. you can also get the fingerprint for the device by running `./hwi.py enumerate` from the command line in the HWI folder.

`<Hardware wallet>` is the name of the hardware device wallet that was created.

4 changes: 3 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ BITCOIN_CORE_H = \
qtum/storageresults.h \
qtum/qtumutils.h \
qtum/qtumdelegation.h \
qtum/qtumtoken.h
qtum/qtumtoken.h \
qtum/qtumledger.h

obj/build.h: FORCE
@$(MKDIR_P) $(builddir)/obj
Expand Down Expand Up @@ -347,6 +348,7 @@ libbitcoin_server_a_SOURCES = \
qtum/storageresults.cpp \
qtum/qtumdelegation.cpp \
qtum/qtumtoken.cpp \
qtum/qtumledger.cpp \
$(BITCOIN_CORE_H)

if ENABLE_WALLET
Expand Down
33 changes: 30 additions & 3 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ QT_FORMS_UI = \
qt/forms/delegationitemwidget.ui \
qt/forms/delegationpage.ui \
qt/forms/delegationsstakerdialog.ui \
qt/forms/derivationpathdialog.ui \
qt/forms/editaddressdialog.ui \
qt/forms/editcontractinfodialog.ui \
qt/forms/editsuperstakerdialog.ui \
qt/forms/hardwaredevicedialog.ui \
qt/forms/hardwarekeystoredialog.ui \
qt/forms/hardwaresigntxdialog.ui \
qt/forms/helpmessagedialog.ui \
qt/forms/intro.ui \
qt/forms/modaloverlay.ui \
Expand Down Expand Up @@ -89,9 +93,13 @@ QT_MOC_CPP = \
qt/moc_delegationpage.cpp \
qt/moc_delegationsstakerdialog.cpp \
qt/moc_delegationstakeritemmodel.cpp \
qt/moc_derivationpathdialog.cpp \
qt/moc_editaddressdialog.cpp \
qt/moc_editcontractinfodialog.cpp \
qt/moc_editsuperstakerdialog.cpp \
qt/moc_hardwaredevicedialog.cpp \
qt/moc_hardwarekeystoredialog.cpp \
qt/moc_hardwaresigntxdialog.cpp \
qt/moc_guiutil.cpp \
qt/moc_intro.cpp \
qt/moc_macdockiconhandler.cpp \
Expand Down Expand Up @@ -152,6 +160,9 @@ QT_MOC_CPP = \
qt/moc_utilitydialog.cpp \
qt/moc_walletcontroller.cpp \
qt/moc_qtumversionchecker.cpp \
qt/moc_qtumhwitool.cpp \
qt/moc_waitmessagebox.cpp \
qt/moc_hardwaresigntx.cpp \
qt/moc_walletframe.cpp \
qt/moc_walletmodel.cpp \
qt/moc_walletview.cpp
Expand Down Expand Up @@ -213,11 +224,15 @@ BITCOIN_QT_H = \
qt/delegationpage.h \
qt/delegationsstakerdialog.h \
qt/delegationstakeritemmodel.h \
qt/derivationpathdialog.h \
qt/editaddressdialog.h \
qt/editcontractinfodialog.h \
qt/editsuperstakerdialog.h \
qt/eventlog.h \
qt/execrpccommand.h \
qt/hardwaredevicedialog.h \
qt/hardwarekeystoredialog.h \
qt/hardwaresigntxdialog.h \
qt/guiconstants.h \
qt/guiutil.h \
qt/intro.h \
Expand Down Expand Up @@ -287,12 +302,15 @@ BITCOIN_QT_H = \
qt/utilitydialog.h \
qt/walletcontroller.h \
qt/qtumversionchecker.h \
qt/waitmessagebox.h \
qt/walletframe.h \
qt/walletmodel.h \
qt/walletmodeltransaction.h \
qt/walletview.h \
qt/winshutdownmonitor.h \
qt/qtumpushbutton.h
qt/qtumpushbutton.h \
qt/qtumhwitool.h \
qt/hardwaresigntx.h

RES_ICONS = \
qt/res/icons/add.png \
Expand Down Expand Up @@ -367,7 +385,9 @@ RES_ICONS = \
qt/res/icons/plus_full.png \
qt/res/icons/split.png \
qt/res/icons/delegate.png \
qt/res/icons/superstake.png
qt/res/icons/superstake.png \
qt/res/icons/ledger_on.png \
qt/res/icons/ledger_off.png

BITCOIN_QT_BASE_CPP = \
qt/bantablemodel.cpp \
Expand Down Expand Up @@ -407,7 +427,9 @@ BITCOIN_QT_BASE_CPP = \
qt/trafficgraphwidget.cpp \
qt/utilitydialog.cpp\
qt/qtumversionchecker.cpp \
qt/qtumpushbutton.cpp
qt/qtumpushbutton.cpp \
qt/qtumhwitool.cpp \
qt/hardwaresigntx.cpp

BITCOIN_QT_WINDOWS_CPP = qt/winshutdownmonitor.cpp

Expand Down Expand Up @@ -436,12 +458,16 @@ BITCOIN_QT_WALLET_CPP = \
qt/delegationlistwidget.cpp \
qt/delegationpage.cpp \
qt/delegationsstakerdialog.cpp \
qt/derivationpathdialog.cpp \
qt/eventlog.cpp \
qt/execrpccommand.cpp \
qt/createwalletdialog.cpp \
qt/editaddressdialog.cpp \
qt/editcontractinfodialog.cpp \
qt/editsuperstakerdialog.cpp \
qt/hardwaredevicedialog.cpp \
qt/hardwarekeystoredialog.cpp \
qt/hardwaresigntxdialog.cpp \
qt/openuridialog.cpp \
qt/overviewpage.cpp \
qt/paymentserver.cpp \
Expand Down Expand Up @@ -479,6 +505,7 @@ BITCOIN_QT_WALLET_CPP = \
qt/tokenitemwidget.cpp \
qt/tokenlistwidget.cpp \
qt/walletcontroller.cpp \
qt/waitmessagebox.cpp \
qt/walletframe.cpp \
qt/walletmodel.cpp \
qt/walletmodeltransaction.cpp \
Expand Down
33 changes: 19 additions & 14 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ class CMainParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000002621183875d3ed75577"); // qtum
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000002ee39fbaf66506e5c57"); // qtum

// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0x02caf7a26b995e5054462715a4d31e1a7ff220c53fead7c06de720ac54510433"); // 888000
consensus.defaultAssumeValid = uint256S("0x8ef924fb7d2a28e0420c8731fb34301c204d15fe8d1e68461e5ebe959df011f2"); // 1405000

/**
* The message start string is designed to be unlikely to occur in normal data.
Expand All @@ -124,7 +124,7 @@ class CMainParams : public CChainParams {
pchMessageStart[3] = 0xd3;
nDefaultPort = 3888;
nPruneAfterHeight = 100000;
m_assumed_blockchain_size = 8;
m_assumed_blockchain_size = 14;
m_assumed_chain_state_size = 1;

genesis = CreateGenesisBlock(1504695029, 8026361, 0x1f00ffff, 1, 50 * COIN);
Expand Down Expand Up @@ -157,6 +157,7 @@ class CMainParams : public CChainParams {
fMineBlocksOnDemand = false;
m_is_test_chain = false;
m_is_mockable_chain = false;
fHasHardwareWalletSupport = true;

checkpointData = {
{
Expand All @@ -171,15 +172,16 @@ class CMainParams : public CChainParams {
{ 498000, uint256S("497f28fd4b1dadc9ff6dd2ac771483acfd16e4c4664eb45d0a6008dc33811418")},
{ 708000, uint256S("23c66194def65cfea20d32a71f23807a93a0b207b3d7251246e2c351204fe9d3")},
{ 888000, uint256S("02caf7a26b995e5054462715a4d31e1a7ff220c53fead7c06de720ac54510433")},
{ 1405000, uint256S("8ef924fb7d2a28e0420c8731fb34301c204d15fe8d1e68461e5ebe959df011f2")},
}
};

chainTxData = ChainTxData{
// Data as of block 76b1e67fcff0fcfd078d499c65494cee4319f256da09f5fdefa574433f7d4e3c (height 709065)
1602362976, // * UNIX timestamp of last known number of transactions
4340534, // * total number of transactions between genesis and that timestamp
// Data as of block 87ee4ec601b335d411e01378936e21044b1a47a3d989feaaaed0e8eaa2929e4b (height 1407838)
1637774408, // * UNIX timestamp of last known number of transactions
6434923, // * total number of transactions between genesis and that timestamp
// (the tx=... number in the SetBestChain debug.log lines)
0.02433574394826639 // * estimated number of transactions per second after that timestamp
0.0842613440826197 // * estimated number of transactions per second after that timestamp
};

consensus.nBlocktimeDownscaleFactor = 4;
Expand Down Expand Up @@ -248,18 +250,18 @@ class CTestNetParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000b17fc0aa1093c32edb"); // qtum
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000f64ad2ae9a92bd2de8"); // qtum

// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0x6bb6312088d81ca5484460b3466c66c01ff7d1cd4ef91e1dc9555a15b51d025d"); // 944000
consensus.defaultAssumeValid = uint256S("0xaff1f9c768e83f90d10a55306993e9042b5740251abc1afdde1429d09e95fa66"); // 1405000

pchMessageStart[0] = 0x0d;
pchMessageStart[1] = 0x22;
pchMessageStart[2] = 0x15;
pchMessageStart[3] = 0x06;
nDefaultPort = 13888;
nPruneAfterHeight = 1000;
m_assumed_blockchain_size = 4;
m_assumed_blockchain_size = 6;
m_assumed_chain_state_size = 1;

genesis = CreateGenesisBlock(1504695029, 7349697, 0x1f00ffff, 1, 50 * COIN);
Expand Down Expand Up @@ -287,6 +289,7 @@ class CTestNetParams : public CChainParams {
fMineBlocksOnDemand = false;
m_is_test_chain = true;
m_is_mockable_chain = false;
fHasHardwareWalletSupport = true;

checkpointData = {
{
Expand All @@ -299,14 +302,15 @@ class CTestNetParams : public CChainParams {
{491300, uint256S("75a7db2865423d3af5f0dfd70cfef6053b91f3c018c4b28a4e28c09a8c011e78")},
{690000, uint256S("89b010b5333fa9d22c7fcf157c7eeaee1ccfe80c435390243b3d782a1fc1eff7")},
{944000, uint256S("6bb6312088d81ca5484460b3466c66c01ff7d1cd4ef91e1dc9555a15b51d025d")},
{1405000, uint256S("aff1f9c768e83f90d10a55306993e9042b5740251abc1afdde1429d09e95fa66")},
}
};

chainTxData = ChainTxData{
// Data as of block 8947ec20d2e17bb48365d50833d6967115ceb2358b13edf99b5624da3f156f37 (height 694595)
1602363600,
1505398,
0.016913121136215
// Data as of block eac806357d6afadecc7fcbc79256e51b170187bbe4497c5192b023bd0b422a48 (height 1457136)
1637778400,
3068076,
0.06376731417354913
};

consensus.nBlocktimeDownscaleFactor = 4;
Expand Down Expand Up @@ -403,6 +407,7 @@ class CRegTestParams : public CChainParams {
fMineBlocksOnDemand = true;
m_is_test_chain = true;
m_is_mockable_chain = true;
fHasHardwareWalletSupport = true;

checkpointData = {
{
Expand Down
2 changes: 2 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class CChainParams
void UpdatePowNoRetargeting(bool fValue);
void UpdatePoSNoRetargeting(bool fValue);
void UpdateMuirGlacierHeight(int nHeight);
bool HasHardwareWalletSupport() const { return fHasHardwareWalletSupport; }
protected:
dev::eth::Network GetEVMNetwork() const;
CChainParams() {}
Expand All @@ -127,6 +128,7 @@ class CChainParams
bool m_is_mockable_chain;
CCheckpointData checkpointData;
ChainTxData chainTxData;
bool fHasHardwareWalletSupport;
};

/**
Expand Down
1 change: 1 addition & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ void SetupServerArgs()
gArgs.AddArg("-torpassword=<pass>", "Tor control port password (default: empty)", ArgsManager::ALLOW_ANY | ArgsManager::SENSITIVE, OptionsCategory::CONNECTION);
gArgs.AddArg("-dgpstorage", "Receiving data from DGP via storage (default: -dgpevm)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
gArgs.AddArg("-dgpevm", "Receiving data from DGP via a contract call (default: -dgpevm)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
gArgs.AddArg("-hwitoolpath=<path>", "Specify HWI tool path", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);

#ifdef USE_UPNP
#if USE_UPNP
Expand Down
Loading

0 comments on commit f5a195c

Please sign in to comment.