aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
AgeCommit message (Collapse)Author
2022-02-15the result of CWallet::IsHDEnabled() was initialized with true.Saibato
But in case of no keys or a blank hd wallet the iterator would be skipped and not set to false but true, since the loop would be not entered. That had resulted in a wrong return and subsequent false HD and watch-only icon display in gui when reloading a wallet after closing. Update src/wallet/wallet.cpp Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Github-Pull: #22781 Rebased-From: 8733a8e84c4b2e484f6ed6159fcf5f29a360d42e
2021-08-26Fix build with Boost 1.77.0Rafael Sadowski
BOOST_FILESYSTEM_C_STR changed to accept the path as an argument Github-Pull: bitcoin/bitcoin#22713 Rebased-From: acb7aad27ec8a184808aa7905887e3b2c5d54e9c
2021-08-20wallet: Assert that enough was selected to cover the feesAndrew Chow
When the fee is not subtracted from the outputs, the amount that has been reserved for the fee (change_and_fee - change_amount) must be enough to cover the fee that is needed. It would be a bug to not do so, so use an assert to make this obvious if such a situation were to occur. Github-Pull: bitcoin/bitcoin#22686 Rebased-From: d9262324e80da32725e21d4e0fbfee56f25490b1
2021-08-20wallet: Use GetSelectionAmount for target value calculationsAndrew Chow
For target value calculations, GetSelectionAmount should be used, not m_effective_value or m_value. Specifically, ApproximateBestSubset mistakenly uses m_value when calculating whether the target value has been met. This has been changed to use GetSelectionAmount. Github-Pull: bitcoin/bitcoin#22686 Rebased-From: 2de222c40198d3d528668d78cc52e2ce3fa96765
2021-07-19Reorder dumpwallet so that cs_main functions go firstAndrew Chow
DEBUG_LOCKORDER expects cs_wallet, cs_main, and cs_KeyStore to be acquired in that order. However dumpwallet would take these in the order cs_wallet, cs_KeyStore, cs_main. So when configured with `--enable-debug`, it is possible to hit the lock order assertion when using dumpwallet. To fix this, cs_wallet and cs_KeyStore are no longer locked at the same time. Instead cs_wallet will be locked first. Then the functions which lock cs_main will be run. Lastly cs_KeyStore will be locked afterwards. This avoids the lock order issue. Furthermore, since GetKeyBirthTimes (only used by dumpwallet) also uses a function that locks cs_main, and itself also locks cs_KeyStore, the same reordering is done here.
2021-07-15Change ScriptPubKeyMan::Upgrade to default to return trueAndrew Chow
If a ScriptPubKeyMan does not implement Upgrade, then using upgraewallet will fail unexpectedly. By changing the default to return true, then this error can be avoided. This is still correct because a successful upgrade can be that nothing happened.
2021-07-01Merge bitcoin/bitcoin#22334: wallet: do not spam about non-existent spk managersfanquake
6084d2caed9b2c70c0f19898c33ecb141fe603c8 wallet: do not spam about non-existent spk managers (S3RK) Pull request description: Avoid spam in logs during `loadwallet`, `listdescriptors` and probably other commands as well. **`loadwallet` Before:** ``` 2021-06-24T06:31:45Z init message: Loading wallet… 2021-06-24T06:31:45Z [desc] Wallet File Version = 169900 2021-06-24T06:31:45Z [desc] Keys: 0 plaintext, 0 encrypted, 0 w/ metadata, 0 total. Unknown wallet records: 0 2021-06-24T06:31:45Z [desc] External scriptPubKey Manager for output type 0 does not exist 2021-06-24T06:31:45Z [desc] External scriptPubKey Manager for output type 1 does not exist 2021-06-24T06:31:45Z [desc] External scriptPubKey Manager for output type 2 does not exist 2021-06-24T06:31:45Z [desc] Internal scriptPubKey Manager for output type 0 does not exist 2021-06-24T06:31:45Z [desc] Internal scriptPubKey Manager for output type 1 does not exist 2021-06-24T06:31:45Z [desc] Internal scriptPubKey Manager for output type 2 does not exist 2021-06-24T06:31:45Z [desc] Wallet completed loading in 197ms 2021-06-24T06:31:45Z [desc] External scriptPubKey Manager for output type 0 does not exist 2021-06-24T06:31:45Z [desc] External scriptPubKey Manager for output type 1 does not exist 2021-06-24T06:31:45Z [desc] External scriptPubKey Manager for output type 2 does not exist 2021-06-24T06:31:45Z [desc] Internal scriptPubKey Manager for output type 0 does not exist 2021-06-24T06:31:45Z [desc] Internal scriptPubKey Manager for output type 1 does not exist 2021-06-24T06:31:45Z [desc] Internal scriptPubKey Manager for output type 2 does not exist 2021-06-24T06:31:45Z [desc] External scriptPubKey Manager for output type 0 does not exist 2021-06-24T06:31:45Z [desc] External scriptPubKey Manager for output type 1 does not exist 2021-06-24T06:31:45Z [desc] External scriptPubKey Manager for output type 2 does not exist 2021-06-24T06:31:45Z [desc] Internal scriptPubKey Manager for output type 0 does not exist 2021-06-24T06:31:45Z [desc] Internal scriptPubKey Manager for output type 1 does not exist 2021-06-24T06:31:45Z [desc] Internal scriptPubKey Manager for output type 2 does not exist 2021-06-24T06:31:45Z [desc] setKeyPool.size() = 0 2021-06-24T06:31:45Z [desc] mapWallet.size() = 0 2021-06-24T06:31:45Z [desc] m_address_book.size() = 0 2021-06-24T06:31:45Z [desc] External scriptPubKey Manager for output type 0 does not exist 2021-06-24T06:31:45Z [desc] External scriptPubKey Manager for output type 1 does not exist 2021-06-24T06:31:45Z [desc] External scriptPubKey Manager for output type 2 does not exist 2021-06-24T06:31:45Z [desc] Internal scriptPubKey Manager for output type 0 does not exist 2021-06-24T06:31:45Z [desc] Internal scriptPubKey Manager for output type 1 does not exist 2021-06-24T06:31:45Z [desc] Internal scriptPubKey Manager for output type 2 does not exist { "name": "desc", "warning": "" } ``` **After:** ``` 2021-06-24T06:26:58Z init message: Loading wallet… 2021-06-24T06:26:58Z [desc] Wallet File Version = 169900 2021-06-24T06:26:58Z [desc] Keys: 0 plaintext, 0 encrypted, 0 w/ metadata, 0 total. Unknown wallet records: 0 2021-06-24T06:26:58Z [desc] Wallet completed loading in 158ms 2021-06-24T06:26:58Z [desc] setKeyPool.size() = 0 2021-06-24T06:26:58Z [desc] mapWallet.size() = 0 2021-06-24T06:26:58Z [desc] m_address_book.size() = 0 { "name": "desc", "warning": "" } ``` ACKs for top commit: achow101: ACK 6084d2caed9b2c70c0f19898c33ecb141fe603c8 Tree-SHA512: c7d7345c3182a575db088fd731b7f6e428c42e4f3f2e10d5adb50bf74a2defe88768e65ebb91a08590be48cf766a5697e36fafa73f68ffe45e76a60600f072e2
2021-07-01wallet: erase spkmans rather than setting to nullptrAndrew Chow
In many places in ScriptPubKeyMan managing code, we assume that the ScriptPubKeyMan being retrieved actually exists and is not a nullptr. Thus removing a ScriptPubKeyMan requires erasing the object from the map rather than setting it to a nullptr.
2021-07-01Merge bitcoin/bitcoin#20191: wallet, refactor: make ↵fanquake
DescriptorScriptPubKeyMan agnostic of internal flag 181181019c5baa3e2d5b675d1843a45aa028781c refactor: remove m_internal from DescriptorSPKman (S3RK) Pull request description: Rationale: improve consistency between `CWallet` and `DescriptorScriptPubKeyMan`; simplify `ScriptPubKeyMan` interface. Descriptor in itself is neither internal or external. It's responsibility of a wallet to assign and manage descriptors for a specific purpose. Duplicating information about internalness of a descriptor could lead to inconsistencies and unexpected behaviour (for example misreporting keypool size). ACKs for top commit: instagibbs: reACK https://github.com/bitcoin/bitcoin/pull/20191/commits/181181019c5baa3e2d5b675d1843a45aa028781c achow101: reACK 181181019c5baa3e2d5b675d1843a45aa028781c Tree-SHA512: d5613b7f6795b290bfa0fd8cb0536de1714d0cf72cba402266bd06d550758ebad690b54fc0a336a1c7414b5814aa4a37c90a6ae89926474a97d30956d7e034ff
2021-07-01Merge bitcoin/bitcoin#19651: wallet: importdescriptors update existingfanquake
3efaf83c75cd8dc2fa084537b8ed6715fb58c04d wallet: deactivate descriptor (S3RK) 6737d9655bcf527afbd85d610d805a2d0fd28c4f test: wallet importdescriptors update existing (S3RK) 586f1d53d60880ea2873d860f95e3390016620d1 wallet: maintain SPK consistency on internal flag change (S3RK) f1b7db14748d9ee04735b4968366d33bc89aea23 wallet: don't mute exceptions in importdescriptors (S3RK) bf68ebc1cd555f791103f81adc9111e0e55c8003 wallet: allow to import same descriptor twice (S3RK) Pull request description: Rationale: allow updating existing descriptors with `importdescriptors` command. Currently if you run same `importdescriptors` command twice with a descriptor containing private key you will get very confusing error — `Missing required fields`. What happens is that Wallet tries to write imported private key to the disk, but it exists already so we get `DB_KEYEXIST (-30995)` from BerkelyDB. Please note, that we set `DB_NOOVERWRITE` (I guess not to lose some keys accidentally). The exception is caught in `catch (...)` in rpcdump.cpp with a generic error. With this PR if a descriptor is already present than we will update its activeness, internalness, label, range and next_index. For the range only expansion is allowed (range start can only decrease, range end increase). ACKs for top commit: achow101: re-ACK 3efaf83c75cd8dc2fa084537b8ed6715fb58c04d meshcollider: Code review ACK 3efaf83c75cd8dc2fa084537b8ed6715fb58c04d jonatack: Light ACK 3efaf83c75cd8dc2fa084537b8ed6715fb58c04d per `git range-diff a000cb0 5d96704 3efaf83` and as a sanity check, re-debug-built on debian with gcc 10.2.1 and clang 11, ran wallet_importdescriptors.py Tree-SHA512: 122c4b621d64ec8a3b625f3aed9f01a2b5cbaf2029ad0325b5ff38d67fff5cd35324335fabe2dd5169548b01b267c81be6ae0f5c834342f3d5f6eeed515c4843
2021-07-01Merge bitcoin/bitcoin#21329: descriptor wallet: Cache last hardened xpub and ↵Samuel Dobson
use in normalized descriptors e6cf0ed92de31a5ac35a271b0da8f0a8364d1175 wallet, rpc: listdescriptors does not need unlocked (Andrew Chow) 3280704886b60644d103a5eb310691c003a39328 Pass in DescriptorCache to ToNormalizedString (Andrew Chow) 7a26ff10c2f2e139fbc63e2f37fb33ea4efae088 Change DescriptorImpl::ToStringHelper to use an enum (Andrew Chow) 75530c93a83f3e94bcb78b6aa463c5570c1e737e Remove priv option for ToNormalizedString (Andrew Chow) 74fede3b8ba69e2cc82c617cdf406ab79df58825 wallet: Upgrade existing descriptor caches (Andrew Chow) 432ba9e5434da90d2cf680f23e8c7b7164c9f945 wallet: Store last hardened xpub cache (Andrew Chow) d87b544b834077f102724415e0fada6ee8b2def2 descriptors: Cache last hardened xpub (Andrew Chow) cacc3910989c4f3d7afa530dbab042461426abce Move DescriptorCache writing to WalletBatch (Andrew Chow) 0b4c8ef75cd03c8f0a8cfadb47e0fbcabe3c5e59 Refactor Cache merging and writing (Andrew Chow) 976b53b085d681645fd3a008fe382de85647e29f Revert "Cache parent xpub inside of BIP32PubkeyProvider" (Andrew Chow) Pull request description: Currently fetching a normalized descriptor requires the wallet to be unlocked as it needs the private keys to derive the last hardened xpub. This is not very user friendly as normalized descriptors shouldn't require and don't involve the private keys except for derivation. We solve this problem by caching the last hardened xpub (which has to be derived at some point when generating the address pool). However the last hardened xpub was not already being cached. We only cached the immediate parent xpub and derived child keys. For example, with a descriptor derivation path of `/84'/0'/0'/0/*`, the parent xpub that is cached is `m/84'/0'/0'/0`, and the child keys of `m/84'/0'/0'/0/i` (note that child keys would not be cached in this case). This parent xpub is not suitable for the normalized descriptor form as we want the key at `m/84'/0'/0'`. So this PR adds another field to `DescriptorCache` to cache the last hardened xpub so that we can use them for normalized descriptors. Since `DescriptorCache` is changing, existing descriptor wallets need to be upgraded to use this new cache. The upgrade will occur in the background either at loading time (if the wallet is not encrypted) or at unlocking time in the same manner that `UpgradeKeyMetadata` operates. It will use a new wallet flag `WALLET_FLAG_LAST_HARDENED_XPUB_CACHED` to indicate whether the descriptor wallet has the last hardened xpub cache. Lastly `listdescriptors` will not require the wallet to be locked and `getaddressinfo`'s `parent_desc` will always be output (assuming the upgrade has occurred). ACKs for top commit: fjahr: tACK e6cf0ed92de31a5ac35a271b0da8f0a8364d1175 S3RK: reACK e6cf0ed jonatack: Semi ACK e6cf0ed92de31a5ac35a271b0da8f0a8364d1175 reviewed, debug-built and ran unit tests and some of the descriptor functional tests at each commit. I'm not very familiar with this code and it could be clearer to the uninitiated IMHO, so I'm not confident enough to give a full ACK. Various minor suggestions follow, most of them for readability, feel free to pick and choose. meshcollider: Code review + functional test run ACK e6cf0ed92de31a5ac35a271b0da8f0a8364d1175 Tree-SHA512: ac27aade8644525cd65bfcaf27ff32afb974085b1451faf4ff68c6671a690bd6a41d4f39a33cbf461ae0fbe85995c0a4c08dbd36171da1c1d2a1d00053ad298d
2021-06-30refactor: remove m_internal from DescriptorSPKmanS3RK
Descriptor in itself is neither internal or external. It's responsibility of a wallet to assign and manage descriptors for a specific purpose. Duplicating such information could lead to inconsistencies and unexpected behaviour.
2021-06-29wallet: do not spam about non-existent spk managersS3RK
2021-06-28wallet: deactivate descriptorS3RK
2021-06-28wallet: maintain SPK consistency on internal flag changeS3RK
2021-06-28wallet: don't mute exceptions in importdescriptorsS3RK
2021-06-28wallet: allow to import same descriptor twiceS3RK
2021-06-28Remove unused wallet pointer from NotifyAddressBookChangedMarcoFalke
2021-06-28Remove unused wallet pointer from NotifyTransactionChanged signalMarcoFalke
2021-06-24wallet, rpc: listdescriptors does not need unlockedAndrew Chow
With the last hardened xpub cache, we don't neeed to have the wallet be unlocked for listdescriptors.
2021-06-24Pass in DescriptorCache to ToNormalizedStringAndrew Chow
Use the descriptor xpub cache in ToNormalizedString so that the wallet does not need to be unlocked in order to get the normalized descriptor.
2021-06-24Remove priv option for ToNormalizedStringAndrew Chow
2021-06-24wallet: Upgrade existing descriptor cachesAndrew Chow
Add functions to upgrade existing descriptor caches to support the use of last hardened xpub caching.
2021-06-24wallet: Store last hardened xpub cacheAndrew Chow
2021-06-24Move DescriptorCache writing to WalletBatchAndrew Chow
Instead of adhoc writing of the items in DescriptorCache, move it all into WalletBatch.
2021-06-24Refactor Cache merging and writingAndrew Chow
Instead of having a large blob of cache merging code in TopUp, refactor this into DescriptorCache so that it can merge and provide a diff (another DescriptorCache containing just the items that were added). Then TopUp can just write everything that was in the diff.
2021-06-24Merge bitcoin/bitcoin#22154: Add OutputType::BECH32M and related wallet ↵W. J. van der Laan
support for fetching bech32m addresses 754f134a50cc56cdf0baf996d909c992770fcc97 wallet: Add error message to GetReservedDestination (Andrew Chow) 87a0e7a3b7c0ffd545e537bd497cdc3e67d045f6 Disallow bech32m addresses for legacy wallet things (Andrew Chow) 6dbe4d10728f882986ed0d9ed77bc736f051c662 Use BECH32M for tr() desc, WitV1Taproot, and WitUnknown CTxDests (Andrew Chow) 699dfcd8ad9487a4e04c1ffc68211e84e126b3d2 Opportunistically use bech32m change addresses if available (Andrew Chow) 0262536c34567743e527dad46912c9ba493252cd Add OutputType::BECH32M (Andrew Chow) 177c15d2f7cd5406ddbce8217fc023057539b828 Limit LegacyScriptPubKeyMan address types (Andrew Chow) Pull request description: Currently bech32m addresses are classfied as bech32. Because bech32m is incompatible with bech32, we need to define a new `OutputType` for it so that it can be handled correctly. This PR adds `OutputType::BECH32M`, updates all of the relevant `OutputType` classifications, and handle requests for bech32m addresses. There is now a `bech32m` address type string that can be used. * `tr()` descriptors now report their output type as `OutputType::BECH32M`. `WtinessV1Taproot` and `WitnessUnknown` are also classified as `OutputType::BECH32M`. * Bech32m addresses are completely disabled for legacy wallets. They cannot be imported (explicitly disallowed in `importaddress` and `importmulti`), will not be created when getting all destinations for a pubkey, and will not be added with `addmultisigaddress`. Additional protections have been added to `LegacyScriptPubKeyMan` to disallow attempting to retrieve bech32m addresses. * Since Taproot multisigs are not implemented yet, `createmultisig` will also disallow the bech32m address type. * As Taproot is not yet active, `DescriptorScriptPubKeyMan` cannot and will not create a `tr()` descriptor. Protections have been added to make sure this cannot occur. * The change address type detection algorithm has been updated to return `bech32m` when there is a segwit v1+ output script and the wallet has a bech32m `ScriptPubKeyMan`, falling back to bech32 if one is not available. ACKs for top commit: laanwj: re-review ACK 754f134a50cc56cdf0baf996d909c992770fcc97 Sjors: re-utACK 754f134: only change is switching to `bech32m` in two `wallet_taproot.py` test cases. fjahr: re-ACK 754f134a50cc56cdf0baf996d909c992770fcc97 jonatack: ACK 754f134a50cc56cdf0baf996d909c992770fcc97 Tree-SHA512: 6ea90867d3631d0d438e2b08ce6ed930f37d01323224661e8e38f183ea5ee2ab65b5891394a3612c7382a1aff907b457616c6725665a10c320174017b998ca9f
2021-06-23Merge bitcoin/bitcoin#22166: Add support for inferring tr() descriptorsSamuel Dobson
d637a9b397816e34652d0c4d383308e39770737a Taproot descriptor inference (Pieter Wuille) c7388e5ada394b7fe94d6263fb02e9dd28ab367e Report address as solvable based on inferred descriptor (Pieter Wuille) 29e5dd1a5b9a1879e6c3c7e153b2e6f33a79e905 consensus refactor: extract ComputeTapleafHash, ComputeTaprootMerkleRoot (Pieter Wuille) Pull request description: Includes: * First commit from #21365, adding TaprootSpendData in SigningProvider * A refactor to expose ComputeTapleafHash and ComputeTaprootMerkleRoot from script/interpreter * A tiny change to make `getaddressinfo` report tr() descriptors as solvable (so that inferred descriptors are shown), despite not having signing code for them. * Logic to infer the script tree back from TaprootSpendData, and then use that to infer descriptors. ACKs for top commit: achow101: re-ACK d637a9b397816e34652d0c4d383308e39770737a Sjors: re-utACK d637a9b meshcollider: Code review ACK d637a9b397816e34652d0c4d383308e39770737a Tree-SHA512: 5ab9b95da662382d8549004be4a1297a577d7caca6b068f875c7c9343723931d03fa9cbf133de11f83b74e4851490ce820fb80413c77b9e8495a5f812e505d86
2021-06-22wallet: Add error message to GetReservedDestinationAndrew Chow
Adds an error output parameter to all GetReservedDestination functions so that callers can get the actual reason that a change address could not be fetched. This more closely matches GetNewDestination. This allows for more granular error messages, such as one that indicates that bech32m addresses cannot be generated yet.
2021-06-22Disallow bech32m addresses for legacy wallet thingsAndrew Chow
We don't want the legacy wallet to ever have bech32m addresses so don't allow importing them. This includes addmultisigaddress as that is a legacy wallet only RPC Additionally, bech32m multisigs are not available yet, so disallow them in createmultisig.
2021-06-22Opportunistically use bech32m change addresses if availableAndrew Chow
If a transaction as a segwit output, use a bech32m change address if they are available. If not, fallback to bech32. If bech32 change addresses are unavailable, fallback to the default address type.
2021-06-22Add OutputType::BECH32MAndrew Chow
Bech32m addresses need their own OutputType We are not ready to create DescriptorScriptPubKeyMans which produce bech32m addresses. So don't allow generating them.
2021-06-22Limit LegacyScriptPubKeyMan address typesAndrew Chow
Make sure that LegacyScriptPubKeyMan can only be used for legacy, p2sh-segwit, and bech32 address types.
2021-06-22wallet: Add missing BlockUntilSyncedToCurrentChainMarcoFalke
2021-06-18Report address as solvable based on inferred descriptorPieter Wuille
2021-06-18Merge bitcoin/bitcoin#21365: Basic Taproot signing support for descriptor ↵Samuel Dobson
wallets 458a345b0590fd2fa04c7d8d70beb8d57e34bbc8 Add support for SIGHASH_DEFAULT in RPCs, and make it default (Pieter Wuille) c0f0c8eccb04f90940007e0c6aaff56bf2ab35b5 tests: check spending of P2TR (Pieter Wuille) a2380127e905e5849f90acc7c69832859d8336aa Basic Taproot signing logic in script/sign.cpp (Pieter Wuille) 49487bc3b6038393c1b9c2dbdc04a78ae1178f1a Make GetInputUTXO safer: verify non-witness UTXO match (Pieter Wuille) fd3f6890f3dfd683f6f13db912caf5c4288adf08 Construct and use PrecomputedTransactionData in PSBT signing (Pieter Wuille) 5cb6502ac5730ea453edbec4c46027ac2ada97e0 Construct and use PrecomputedTransactionData in SignTransaction (Pieter Wuille) 5d2e22437b22e7465ae4be64069443bcc1769dc9 Don't nuke witness data when signing fails (Pieter Wuille) ce9353164bdb6215a62b2b6dcb2121d331796f60 Permit full precomputation in PrecomputedTransactionData (Pieter Wuille) e841fb503d7a662bde01ec2e4794faa989265950 Add precomputed txdata support to MutableTransactionSignatureCreator (Pieter Wuille) a91d532338ecb66ec5bed164929d878dd55d63a4 Add CKey::SignSchnorr function for BIP 340/341 signing (Pieter Wuille) e77a2839b54fa2039bba468e8c09dbbbf19b150a Use HandleMissingData also in CheckSchnorrSignature (Pieter Wuille) dbb0ce9fbff01ffe4dd29da465f43ecaddc2854c Add TaprootSpendData data structure, equivalent to script map for P2[W]SH (Pieter Wuille) Pull request description: Builds on top of #22051, adding signing support after derivation support. Nothing is changed in descriptor features. Signing works for key path and script path spending, through the normal sending functions, and PSBT-based RPCs. However, PSBT usability is rather low as no extensions have been defined to convey Taproot-specific information, so all script information must be known to the signing wallet. ACKs for top commit: achow101: re-ACK 458a345b0590fd2fa04c7d8d70beb8d57e34bbc8 fjahr: Code review ACK 458a345b0590fd2fa04c7d8d70beb8d57e34bbc8 Sjors: ACK 458a345b0590fd2fa04c7d8d70beb8d57e34bbc8 Tree-SHA512: 30ed212cf7754763a4a81624ebc084c51727b8322711ac0b390369213c1a891d367ed8b123882ac08c99595320c11ec57ee42304ff22a69afdc3d1a0d55cc711
2021-06-16refactor: reduce #ifdef ENABLE_EXTERNAL_SIGNER usageSjors Provoost
In particular this make the node interface independent on whether external signer support is compiled.
2021-06-16refactor: clean up external_signer.h includesSjors Provoost
Co-Authored-By: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
2021-06-12Add support for SIGHASH_DEFAULT in RPCs, and make it defaultPieter Wuille
For non-Taproot signatures, this is interpreted as SIGHASH_ALL.
2021-06-12Construct and use PrecomputedTransactionData in PSBT signingPieter Wuille
2021-06-12Merge bitcoin/bitcoin#22156: Allow tr() import only when Taproot is activeW. J. van der Laan
fbf485c9b2bf1d056bfea77345a15cf56a9cd786 Allow tr() import only when Taproot is active (Andrew Chow) Pull request description: To avoid issues around fund loss, only allow descriptor wallets to import `tr()` descriptors after taproot has activated. ACKs for top commit: sipa: utACK fbf485c9b2bf1d056bfea77345a15cf56a9cd786 fjahr: Code review ACK fbf485c9b2bf1d056bfea77345a15cf56a9cd786 laanwj: Code review ACK fbf485c9b2bf1d056bfea77345a15cf56a9cd786 prayank23: utACK https://github.com/bitcoin/bitcoin/pull/22156/commits/fbf485c9b2bf1d056bfea77345a15cf56a9cd786 Tree-SHA512: 83c43376515eea523dbc89bc5a0fde53e54aec492e49a40c2a33d80fc94aac459e232ae07b024b4bd75b58078c8d090bc7a2d69541c5d3d4834d2f4cfc9c8208
2021-06-12Merge bitcoin/bitcoin#22214: refactor: Rearrange fillPSBT argumentsfanquake
f47e8028391fbcf44fe1dbf3539f42e4185590fd Rearrange fillPSBT arguments (Russell Yanofsky) Pull request description: Move fillPSBT inout argument before output-only arguments. This is a nice thing to do to keep the interface style [consistent](https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs). But motivation is to work around a current limitation of the libmultiprocess code generator (which figures out order of inout parameters by looking at input list, but more ideally would use the output list). --- This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). The commit was first part of larger PR #10102. ACKs for top commit: achow101: ACK f47e8028391fbcf44fe1dbf3539f42e4185590fd theStack: Code-review ACK f47e8028391fbcf44fe1dbf3539f42e4185590fd Tree-SHA512: 1787af3031ff7ed6b519f3b93054d8b257af96a3380a476a6dab0f759329039ecc5d624b785c5c2d14d594fc852dd81c626880c775c691ec9c79b7b3dbcfb257
2021-06-10Allow tr() import only when Taproot is activeAndrew Chow
To avoid issues around fund loss, only allow descriptor wallets to import tr() descriptors after taproot has activated.
2021-06-10scripted-diff: wallet/test: Use existing chainmanCarl Dong
-BEGIN VERIFY SCRIPT- git ls-files -- src/wallet/test \ | xargs sed -i -E \ -e 's@g_chainman\.m_blockman@m_node.chainman->m_blockman@g' \ -e 's@([^:])(Chain(state|)Active)@\1::\2@g' \ -e 's@::Chain(state|)Active\(\)@m_node.chainman->ActiveChain\1()@g' -END VERIFY SCRIPT-
2021-06-10Rearrange fillPSBT argumentsRussell Yanofsky
Move fillPSBT input-output argument before output-only arguments. This is a temporary workaround which can go away with improvements to libmultiprocess code generator. Currently code generator figures out order of input-output parameters by looking at input list, but it would make more sense for it to take order from output list, so input-only parameters still have to be first but there is more flexibility for the other parameters.
2021-06-09Merge bitcoin/bitcoin#22173: wallet: Do not load external signers wallets ↵Samuel Dobson
when unsupported e60cd26ad46559770ad84d2959c9a1742ae8b7a6 Do not load external signers wallets when unsupported (Andrew Chow) Pull request description: When external signer support is not compiled, do not load external signer wallets. Alternative to #22168. ACKs for top commit: promag: Tested ACK e60cd26ad46559770ad84d2959c9a1742ae8b7a6. meshcollider: Code review ACK e60cd26ad46559770ad84d2959c9a1742ae8b7a6 Tree-SHA512: aed2d0038f448c2f89c6b48f412b106e63c9ed20e748e69aae21fb58c33fc7e4fa73375a52372c73788669eb2b968a8da6b022c65658fa4484f5bbcf205b1b15
2021-06-09Merge bitcoin/bitcoin#21944: wallet: Fix issues when `walletdir` is root ↵Samuel Dobson
directory d44a261acff40c1c8727d3cc0106bde65a6416d0 Fix issues when `walletdir` is root directory (unknown) Pull request description: + Remove one character less from wallet path + After testing lot of random strings with special chars in `wallet_name`, I found that the issue was not related to special characters in the name. Reviewing PR https://github.com/bitcoin/bitcoin/pull/21907 helped me resolve the issue. **Real issue**: If the path mentioned in `walletdir` is a root directory, first character of the wallet name or path is removed **Solution**: `if` statement to check `walletdir` is a root directory Fixes: https://github.com/bitcoin/bitcoin/issues/21510 https://github.com/bitcoin/bitcoin/issues/21501 Related PR: https://github.com/bitcoin/bitcoin/pull/20080 Consider the wallet directories `w1` and `w2` saved in `D:\`. Run `bitcoind.exe -walletdir=D:\`, Results for `bitcoin-cli.exe listwalletdir`: Before this PR: ``` { "wallets": [ { "name": "1" }, { "name": "2" } ] } ``` After this PR: ``` "wallets": [ { "name": "w1" }, { "name": "w2" } ] } ``` ACKs for top commit: ryanofsky: Code review ACK d44a261acff40c1c8727d3cc0106bde65a6416d0 meshcollider: utACK d44a261acff40c1c8727d3cc0106bde65a6416d0 Tree-SHA512: b09b00f727407e3771c8694861dae1bfd29d97a0d51ddcb5d9c0111dc618b3fff2f75829cbb4361c54457ee564e94fcefd9e2928262a1c918a2b6bbad724eb55
2021-06-09Merge bitcoin/bitcoin#22008: wallet: Cleanup and refactor ↵Samuel Dobson
CreateTransactionInternal 96c2c9520e80ee4fed92f0e1ab859d59fcbdb110 scripted-diff: Rename SelectCoinsMinConf to AttemptSelection (Andrew Chow) b583f73354c617ede9145f9738f13cedf1c13e08 Move vin filling to before final fee setting (Andrew Chow) d39cac0547c960df0a890e89f43b458147b4b07a Set m_subtract_fee_outputs during recipients vector loop (Andrew Chow) 364e0698a543a19e81ae407cc523970e6ed924e8 Move variable initializations to where they are used (Andrew Chow) 32ab430651594ed3d10a6ed75f19de5197f0e9b0 Move recipients vector checks to beginning of CreateTransaction (Andrew Chow) cd1d6d3324a841087f6d5da723394e8d7df07ec7 Rename nSubtractFeeFromAmount in CreateTransaction (Andrew Chow) dac21c793f8fbb4d5debc55ac97c406c7c93ff48 Rename nValue and nValueToSelect (Andrew Chow) d2aee3bbc765a1f02e4ceadb2fa5928ac524f1a7 Remove extraneous scope in CreateTransactionInternal (Andrew Chow) b2995963b5d0b9bca503b0cc69c747f4cedec1e4 Move cs_wallet lock in CreateTransactionInternal to top of function (Andrew Chow) Pull request description: #17331 did some refactors and cleanup of `CreateTransactionInternal` to make it easier to understand, however it is still a bit convoluted even though it doesn't have to be. This PR does additional cleanup and refactoring to `CreateTransactionInternal` so that it is easier to understand. Some unnecessary code was removed, some variables moved around to where they matter, and several indents removed. ACKs for top commit: glozow: reACK 96c2c95 ryanofsky: Code review ACK 96c2c9520e80ee4fed92f0e1ab859d59fcbdb110 also acked previously (was reverted). meshcollider: re-utACK 96c2c9520e80ee4fed92f0e1ab859d59fcbdb110 Tree-SHA512: 3dba67ed436968a07bfd82d435d566ad74e116c6e50ac9baed7144a46ad5c0f630b1ba59d91e8e8972ac2af559d7c0576f0560f09684d2ab20fad6689902866f
2021-06-09Merge bitcoin-core/gui#4: UI external signer support (e.g. hardware wallet)Samuel Dobson
1c4b456e1a0ccf0397d652f8c18201c3224c5c21 gui: send using external signer (Sjors Provoost) 24815c6309431cb0797defaf7add1150bcf4b567 gui: wallet creation detects external signer (Sjors Provoost) 3f845ea2994f53e29abeb3fa158c35f1ee56e7e8 node: add externalSigners to interface (Sjors Provoost) 62ac119f919ae1160ed67af796f24b78025fa8e3 gui: display address on external signer (Sjors Provoost) 450cb40a344605dda3bcc39495c35869580b9fc2 wallet: add displayAddress to interface (Sjors Provoost) eef8d6452962cd4a8956d9ad268164715365b9ab gui: create wallet with external signer (Sjors Provoost) 6cdbc83e9341d1552faee4ccd8c190babc63e8d1 gui: add external signer path to options dialog (Sjors Provoost) Pull request description: Big picture overview in [this gist](https://gist.github.com/Sjors/29d06728c685e6182828c1ce9b74483d). This PR adds GUI support for external signers, based on the since merged bitcoin/bitcoin#16546 (RPC). The UX isn't amazing - especially the blocking calls - but it works. First we adds a GUI setting for the signer script (e.g. path to HWI): <img width="625" alt="Schermafbeelding 2019-08-05 om 19 32 59" src="https://user-images.githubusercontent.com/10217/62483415-e1ff1680-b7b7-11e9-97ca-8d2ce54ca1cb.png"> Then we add an external signer checkbox to the wallet creation dialog: <img width="374" alt="Schermafbeelding 2019-11-07 om 19 17 23" src="https://user-images.githubusercontent.com/10217/68416387-b57ee000-0194-11ea-9730-127d60273008.png"> It's checked by default if HWI detects a device. It also grabs the name. It then creates a fresh wallet and imports the keys. You can verify an address on the device (blocking...): <img width="673" alt="Schermafbeelding 2019-08-05 om 19 29 22" src="https://user-images.githubusercontent.com/10217/62483560-43bf8080-b7b8-11e9-9902-8a036116dc4b.png"> Sending, including coin selection, Just Works(tm) as long the device is present. ~External signer support is enabled by default when the GUI is configured and Boost::Process is present.~ External signer support remains disabled by default, see https://github.com/bitcoin/bitcoin/pull/21935. ACKs for top commit: achow101: Code Review ACK 1c4b456e1a0ccf0397d652f8c18201c3224c5c21 hebasto: ACK 1c4b456e1a0ccf0397d652f8c18201c3224c5c21, tested on Linux Mint 20.1 (Qt 5.12.8) with HWW `2.0.2-rc.1`. promag: Tested ACK 1c4b456e1a0ccf0397d652f8c18201c3224c5c21 but rebased with e033ca1379, with HWI 2.0.2, with Nano S and Nano X. meshcollider: re-code-review ACK 1c4b456e1a0ccf0397d652f8c18201c3224c5c21 Tree-SHA512: 3503113c5c69d40adb6ce364d8e7cae23ce82d032a00474ba9aeb6202eb70f496ef4a6bf2e623e5171e524ad31ade7941a4e0e89539c64518aaec74f4562d86b
2021-06-06Do not load external signers wallets when unsupportedAndrew Chow
When external signer support is not compiled, do not load external signer wallets.