Merge #16944: gui: create PSBT with watch-only wallet

c6dd565c88 [gui] watch-only wallet: copy PSBT to clipboard (Sjors Provoost)
39465d545d [wallet] add fillPSBT to interface (Sjors Provoost)
848f889208 [gui] send: include watch-only (Sjors Provoost)
40537f0909 [wallet] ListCoins: include watch-only for wallets without private keys (Sjors Provoost)

Pull request description:

  For wallets with `WALLET_FLAG_DISABLE_PRIVATE_KEYS` this makes the watch-only balance available on the send screen (including coin selection). Instead of sending a transaction it generates a PSBT.

  The user can take this PSBT and process it with [HWI](https://github.com/bitcoin-core/HWI) or put it an SD card for hardware wallets that support that.

  The PSBT is copied to the clipboard. This was the easiest approach; we can add a dialog later to display it, as well as an option to save to disk.

ACKs for top commit:
  instagibbs:
    test and code review ACK c6dd565c88
  meshcollider:
    re-ACK c6dd565c88

Tree-SHA512: ebc3da0737e33b255ed926191b84569aedb6097d14868662bd5dce726ce3048e86e9a31eba987b10dffe1482b35c21ae1cd595c2caa4634bc4cf78a826a83852
This commit is contained in:
Samuel Dobson
2019-11-23 08:43:54 +13:00
6 changed files with 85 additions and 23 deletions

View File

@@ -18,8 +18,9 @@
#include <wallet/feebumper.h>
#include <wallet/fees.h>
#include <wallet/ismine.h>
#include <wallet/rpcwallet.h>
#include <wallet/load.h>
#include <wallet/psbtwallet.h>
#include <wallet/rpcwallet.h>
#include <wallet/wallet.h>
#include <memory>
@@ -357,6 +358,14 @@ public:
}
return {};
}
TransactionError fillPSBT(PartiallySignedTransaction& psbtx,
bool& complete,
int sighash_type = 1 /* SIGHASH_ALL */,
bool sign = true,
bool bip32derivs = false) override
{
return FillPSBT(m_wallet.get(), psbtx, complete, sighash_type, sign, bip32derivs);
}
WalletBalances getBalances() override
{
const auto bal = m_wallet->GetBalance();

View File

@@ -14,6 +14,7 @@
#include <functional>
#include <map>
#include <memory>
#include <psbt.h>
#include <stdint.h>
#include <string>
#include <tuple>
@@ -194,6 +195,13 @@ public:
bool& in_mempool,
int& num_blocks) = 0;
//! Fill PSBT.
virtual TransactionError fillPSBT(PartiallySignedTransaction& psbtx,
bool& complete,
int sighash_type = 1 /* SIGHASH_ALL */,
bool sign = true,
bool bip32derivs = false) = 0;
//! Get balances.
virtual WalletBalances getBalances() = 0;