Commit graph

23986 commits

Author SHA1 Message Date
Amiti Uttarwar
50fc4df6c4 [mempool] Persist unbroadcast set to mempool.dat
Ensure that the unbroadcast set will still be meaningful if the node is
restarted.
2020-04-23 14:42:25 -07:00
Amiti Uttarwar
297a178536 [test] Integration tests for unbroadcast functionality
Check that...
- mempool tracks & reattempts delivery of a transaction where a GETDATA hasn't
  been requested by a peer yet.
- transaction delivery is not attempted again after GETDATA is received.
- transaction is removed from the unbroadcast set when its removed from the
  mempool.
2020-04-23 14:42:25 -07:00
Amiti Uttarwar
6851502472 [refactor/test] Extract P2PTxInvStore into test framework 2020-04-23 14:42:25 -07:00
Amiti Uttarwar
dc1da48dc5 [wallet] Update the rebroadcast frequency to be ~1/day.
Since the mempool unbroadcast mechanism handles the reattempts for initial
broadcast, the wallet rebroadcast attempts can be much less frequent
(previously ~1/30 min)
2020-04-23 14:42:25 -07:00
Amiti Uttarwar
e25e42f20a [p2p] Reattempt initial send of unbroadcast transactions
Every 10-15 minutes, the scheduler kicks off a job that queues unbroadcast
transactions onto each node.
2020-04-23 14:42:25 -07:00
Amiti Uttarwar
7e93eecce3 [util] Add method that returns random time in milliseconds 2020-04-23 14:42:25 -07:00
Amiti Uttarwar
89eeb4a333 [mempool] Track "unbroadcast" transactions
- Mempool tracks locally submitted transactions (wallet or rpc)
- Transactions are removed from set when the node receives a GETDATA request
  from a peer, or if the transaction is removed from the mempool.
2020-04-23 14:42:25 -07:00
Andrew Chow
223588b1bb Add a --descriptors option to various tests
Adds a --descriptors option globally to the test framework. This will
make the test create and use descriptor wallets. However some tests may
not work with this.

Some tests are modified to work with --descriptors and run with that
option in test_runer:
* wallet_basic.py
* wallet_encryption.py
* wallet_keypool.py
* wallet_keypool_topup.py
* wallet_labels.py
* wallet_avoidreuse.py
2020-04-23 13:59:48 -04:00
Andrew Chow
869f7ab30a tests: Add RPCOverloadWrapper which overloads some disabled RPCs
RPCOverloadWrapper overloads some deprecated or disabled RPCs with
an implementation using other RPCs to avoid having a ton of code churn
around replacing those RPCs.
2020-04-23 13:59:48 -04:00
Andrew Chow
cf06062859 Correctly check for default wallet 2020-04-23 13:59:48 -04:00
Andrew Chow
886e0d75f5 Implement CWallet::IsSpentKey for non-LegacySPKMans 2020-04-23 13:59:48 -04:00
Andrew Chow
3c19fdd2a2 Return error when no ScriptPubKeyMan is available for specified type
When a CWallet doesn't have a ScriptPubKeyMan for the requested type
in GetNewDestination, give a meaningful error. Also handle this in
Qt which did not do anything with errors.
2020-04-23 13:59:48 -04:00
Andrew Chow
388ba94231 Change wallet_encryption.py to use signmessage instead of dumpprivkey 2020-04-23 13:59:48 -04:00
Andrew Chow
1346e14831 Functional tests for descriptor wallets 2020-04-23 13:59:48 -04:00
Hugo Nguyen
f193ea889d add importdescriptors RPC and tests for native descriptor wallets
Co-authored-by: Andrew Chow <achow101-github@achow101.com>
2020-04-23 13:59:48 -04:00
Andrew Chow
ce24a94494 Add IsLegacy to CWallet so that the GUI knows whether to show watchonly 2020-04-23 13:59:48 -04:00
Andrew Chow
1cb42b22b1 Generate new descriptors when encrypting 2020-04-23 13:59:48 -04:00
Andrew Chow
82ae02b165 Be able to create new wallets with DescriptorScriptPubKeyMans as backing 2020-04-23 13:59:48 -04:00
Andrew Chow
b713baa75a Implement GetMetadata in DescriptorScriptPubKeyMan 2020-04-23 13:59:48 -04:00
Andrew Chow
8b9603bd0b Change GetMetadata to use unique_ptr<CKeyMetadata> 2020-04-23 13:59:48 -04:00
Andrew Chow
72a9540df9 Implement FillPSBT in DescriptorScriptPubKeyMan
FillPSBT will add our own scripts to the PSBT if those inputs are ours.
If an input also lists pubkeys that we happen to know the private keys
for, we will sign those inputs too.
2020-04-23 13:59:48 -04:00
Andrew Chow
84b4978c02 Implement SignMessage for descriptor wallets 2020-04-23 13:59:48 -04:00
Andrew Chow
bde7c9fa38 Implement SignTransaction in DescriptorScriptPubKeyMan 2020-04-23 13:59:48 -04:00
Andrew Chow
d50c8ddd41 Implement GetSolvingProvider for DescriptorScriptPubKeyMan
Internally, a GetSigningProvider function is introduced which allows for
some private keys to be optionally included. This can be called with a
script as the argument (i.e. a scriptPubKey from our wallet when we are
signing) or with a pubkey. In order to know what index to expand the
private keys for that pubkey, we need to also cache all of the pubkeys
involved when we expand the descriptor. So SetCache and TopUp are
updated to do this too.
2020-04-23 13:59:48 -04:00
Andrew Chow
f1ca5feb4a Implement GetKeypoolOldestTime and only display it if greater than 0 2020-04-23 13:59:48 -04:00
Andrew Chow
586b57a9a6 Implement ReturnDestination in DescriptorScriptPubKeyMan 2020-04-23 13:59:48 -04:00
Andrew Chow
f866957979 Implement GetReservedDestination in DescriptorScriptPubKeyMan 2020-04-23 13:59:48 -04:00
Andrew Chow
a775f7c7fd Implement Unlock and Encrypt in DescriptorScriptPubKeyMan 2020-04-23 13:59:48 -04:00
Andrew Chow
bfdd073486 Implement GetNewDestination for DescriptorScriptPubKeyMan 2020-04-23 13:59:48 -04:00
Andrew Chow
58c7651821 Implement TopUp in DescriptorScriptPubKeyMan 2020-04-23 13:59:48 -04:00
Andrew Chow
e014886a34 Implement SetupGeneration for DescriptorScriptPubKeyMan 2020-04-23 13:59:48 -04:00
Andrew Chow
46dfb99768 Implement writing descriptorkeys, descriptorckeys, and descriptors to wallet file 2020-04-23 13:59:48 -04:00
Andrew Chow
4cb9b69be0 Implement several simple functions in DescriptorScriptPubKeyMan
Implements a bunch of one liners: UpgradeKeyMetadata, IsFirstRun, HavePrivateKeys,
KeypoolCountExternalKeys, GetKeypoolSize, GetTimeFirstKey, CanGetAddresses,
RewriteDB
2020-04-23 13:59:48 -04:00
Andrew Chow
d1ec3e4f19 Add IsSingleType to Descriptors
IsSingleType will return whether the descriptor will give one or multiple scriptPubKeys
2020-04-23 13:59:48 -04:00
Andrew Chow
953feb3d27 Implement loading of keys for DescriptorScriptPubKeyMan 2020-04-23 13:59:48 -04:00
Andrew Chow
2363e9fcaa Load the descriptor cache from the wallet file 2020-04-23 13:59:48 -04:00
Andrew Chow
46c46aebb7 Implement GetID for DescriptorScriptPubKeyMan 2020-04-23 13:59:48 -04:00
Andrew Chow
ec2f9e1178 Implement IsHDEnabled in DescriptorScriptPubKeyMan 2020-04-23 13:59:48 -04:00
Andrew Chow
741122d4c1 Implement MarkUnusedAddresses in DescriptorScriptPubKeyMan 2020-04-23 13:59:48 -04:00
Andrew Chow
2db7ca765c Implement IsMine for DescriptorScriptPubKeyMan
Adds a set of scriptPubKeys that DescriptorScriptPubKeyMan tracks.
If the given script is in that set, it is considered ISMINE_SPENDABLE
2020-04-23 13:59:48 -04:00
Andrew Chow
db7177af8c Add LoadDescriptorScriptPubKeyMan and SetActiveScriptPubKeyMan to CWallet 2020-04-23 13:59:42 -04:00
Andrew Chow
78f8a92910 Implement SetType in DescriptorScriptPubKeyMan 2020-04-23 13:25:50 -04:00
Andrew Chow
834de0300c Store WalletDescriptor in DescriptorScriptPubKeyMan 2020-04-23 13:25:50 -04:00
Andrew Chow
d8132669e1 Add a lock cs_desc_man for DescriptorScriptPubKeyMan 2020-04-23 13:25:50 -04:00
Andrew Chow
3194a7f88a Introduce WalletDescriptor class
WalletDescriptor is a Descriptor with other wallet metadata
2020-04-23 13:25:50 -04:00
Andrew Chow
6b13cd3fa8 Create LegacyScriptPubKeyMan when not a descriptor wallet 2020-04-23 13:25:50 -04:00
Andrew Chow
aeac157c9d Return nullptr from GetLegacyScriptPubKeyMan if descriptor wallet 2020-04-23 13:25:50 -04:00
Andrew Chow
96accc73f0 Add WALLET_FLAG_DESCRIPTORS 2020-04-23 13:25:50 -04:00
Andrew Chow
6b8119af53 Introduce DescriptorScriptPubKeyMan as a dummy class 2020-04-23 13:25:50 -04:00
Andrew Chow
06620302c7 Introduce SetType function to tell ScriptPubKeyMans the type and internal-ness of it 2020-04-23 13:25:50 -04:00