aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/rpcwallet.cpp
AgeCommit message (Collapse)Author
2018-12-07rpc: Avoid creating non-standard raw transactionsMarcoFalke
Github-Pull: #14890 Rebased-From: fa4c8679ed94f215ce895938f7c3c169a2ce101e
2018-12-05rpc: Fix wallet unload during walletpassphrase timeoutJoão Barbosa
Github-Pull: #14453 Rebased-From: 321decf
2018-12-03Refactor PSBTInput signing to enforce invariantGlenn Willen
Refactor the process of PSBTInput signing to enforce the invariant that a PSBTInput always has _either_ a witness_utxo or a non_witness_utxo, never both. This simplifies the logic of SignPSBTInput slightly, since it no longer has to deal with the "both" case. When calling it, we now give it, in order of preference: (1) whichever of the utxo fields was already present in the PSBT we received, or (2) if neither, the non_witness_utxo field, which is just a copy of the input transaction, which we get from the wallet. SignPSBTInput no longer has to remove one of the two fields; instead, it will check if we have a witness signature, and if so, it will replace the non_witness_utxo with the witness_utxo (which is smaller, as it is just a copy of the output being spent.) Add PSBTInput::IsSane checks in two more places, which checks for both utxo fields being present; we will now give an RPC error early on if we are supplied such a malformed PSBT to fill in. Also add a check to FillPSBT, to avoid touching any input that is already signed. (This is now redundant, since we should no longer potentially harm an already-signed input, but it's harmless.) fixes #14473 Github-Pull: #14588
2018-12-03Simplify arguments to SignPSBTInputGlenn Willen
Remove redundant arguments to SignPSBTInput -- since it needs several bits of the PartiallySignedTransaction, pass in a reference instead of doing it piecemeal. This saves us having to pass in both a PSBTInput and its index, as well as having to pass in the CTransaction. Also avoid redundantly passing the sighash_type, which is contained in the PSBTInput already. Github-Pull: #14588 Rebased-From: 0f5bda2bd941686620ef0eb90bd7ed973cc7ef73
2018-12-03New PartiallySignedTransaction constructor from CTransctionGlenn Willen
New constructor that creates a PartiallySignedTransaction from a CTransaction, automatically sizing the inputs and outputs vectors for convenience. Github-Pull: #14588 Rebased-From: 65166d4cf828909dc4bc49dd68a58103d015f1fd
2018-12-03Remove redundant txConst parameter to FillPSBTGlenn Willen
Github-Pull: #14588 Rebased-From: 4f3f5cb4b142f0fcb36241fa33b52a257901dbee
2018-12-03More concise conversion of CDataStream to stringGlenn Willen
Use .str() instead of .data() and .size() when converting CDataStream to a string. Uses std::string, avoiding conversion to a C string. Github-Pull: #14588 Rebased-From: fe5d22bc676f158e8d567d71edb3451118759d62
2018-12-01Merge #14196: [0.17][psbt] always drop the unnecessary utxo and convert ↵MarcoFalke
non-witness utxo to witness when necessary fcefc6851a Convert non-witness UTXOs to witness if witness sig created (Andrew Chow) fcdea8ad2a Drop the unnecessary UTXO based on the UTXOs present, not on earlier wallet things (Andrew Chow) Pull request description: When we sign an input in a psbt that has a non-witness utxo but a witness signature is produced, we will now replace the non-witness utxo with the corresponding witness utxo. Furthermore, we should make sure that the correct UTXO type is used based on what UTXOs are there, not based on earlier wallet behavior. Note that this is PR'd to the 0.17 branch because the code here no longer exists in master. Tree-SHA512: 882e9e4e9b77d6ac1743c35c0d59023aad6f4f19193398f97f2c6b81f6627d74e5220b1d674a0edba1ff2fc2a7f61afbf838d3faf0a964fccd3dee97c631aa47
2018-11-28[wallet] Ensure wallet is unlocked before signinggustavonalle
Github-Pull: #14310 Rebased-From: db15805668e923c3493d77122d20926496cf6a1a
2018-10-10[wallet] Restore ability to list incoming transactions by labelRussell Yanofsky
Backport of PR 14411 to v0.17. This change partially reverts #13075 and #14023. Fixes #14382
2018-09-11Convert non-witness UTXOs to witness if witness sig createdAndrew Chow
If a witness signature was created when a non-witness UTXO is used, convert the non-witness UTXO to a witness one.
2018-09-11Drop the unnecessary UTXO based on the UTXOs present, not on earlier wallet ↵Andrew Chow
things Instead of dropping the unnecessary UTXO based on whether the wallet did something, do it based on whether two UTXOs are there.
2018-08-28fix walletcreatefundedpsbt deriv paths, add testGregory Sanders
Github-Pull: #14055 Rebased-From: 61fe653bd919cb0533b2b9d6259bc86a4b2975c0 Tree-SHA512: 2f3edf62318fab4b405b47788096005f59cbe6ba4723fe51ce3b386539a58b7ea7369c31c3840c6baa76cdf6ba8f8440f977c36e2ee2916e711d7872bd1eadad
2018-08-27Docs: Fix help message typo optiona -> optionalBen Woosley
Github-Pull: #14056 Rebased-From: 7d0a8ad3103200145ab2e73368c3b8345a66c15d
2018-08-21RPCTypeCheck bip32derivs arg in walletcreatefundedGregory Sanders
Github-Pull: #13968 Rebased-From: faaac5caaab4d5131040292f4ef2404074ad268b Tree-SHA512: 758c0c3e4435897d1a9b03ea93f1b2a1a1b64071eda9450f968acf537c172ee61acf9d962bc22ddb6de26e0ad39d9165cdee6f260bb5a95bf97b4003853f0874
2018-08-21walletcreatefundedpsbt: remove duplicate replaceable argGregory Sanders
Github-Pull: #13968 Rebased-From: 1f18d7b591ffcc8bb9422a9b728bd9a0d8da6a2a Tree-SHA512: 90391703181db6880a135c60aca792a9e92c4abcad26907cd6cb0a0378593fe45cf995a22ae142ea7de2767c72a9df444e918ff15e460ce19c0435163917d812
2018-08-15Only wipe wrong UTXO type data if overwritten by walletPieter Wuille
GitHub-Pull: #13917 Rebased-From: c05712c
2018-08-09Use pushKV in some new PSBT RPCs.Daniel Kraft
Most of the code uses UniValue::pushKV where appropriate, but some new RPC code related to PSBTs did not.
2018-07-20Merge #9662: Add createwallet "disableprivatekeys" option: a sane mode for ↵Wladimir J. van der Laan
watchonly-wallets a3fa4d6a6acf19d640a1d5879a00aa1f059e2380 QA: Fix bug in -usecli logic that converts booleans to non-lowercase strings (Jonas Schnelli) 4704e5f074e57782d058404a594a7313cf170cf0 [QA] add createwallet disableprivatekey test (Jonas Schnelli) c7b8f343e99d9d53ea353ddce9a977f1886caf30 [Qt] Disable creating receive addresses when private keys are disabled (Jonas Schnelli) 2f15c2bc20d583b4c1788da78c9c635c36e03ed0 Add disable privatekeys option to createwallet (Jonas Schnelli) cebefba0855cee7fbcb9474b34e6779369e8e9ce Add option to disable private keys during internal wallet creation (Jonas Schnelli) 9995a602a639b64a749545b7c3bafbf67f97324f Add facility to store wallet flags (64 bits) (Jonas Schnelli) Pull request description: This mode ('createwallet {"disableprivatekeys": true}') is intended for a sane pure watch-only mode, ideal for a use-case where one likes to use Bitcoin-Core in conjunction with a hardware-wallet or another solutions for cold-storage. Since we have support for custom change addresses in `fundrawtransaction`, pure watch-only wallets including coin-selection are possible and do make sense for some use cases. This new mode disables all forms of private key generation and ensure that no mix between hot and cold keys are possible. Tree-SHA512: 3ebe7e8d54c4d4e5f790c348d4c292d456f573960a5b04d69ca5ef43a9217c7e7671761c6968cdc56f9a8bc235f3badd358576651af9f10855a0eb731f3fc508
2018-07-19wallet: Add error handling. Check return value of ParseUInt32(...) in ↵practicalswift
ParseHDKeypath(...).
2018-07-18Merge #13557: BIP 174 PSBT Serializations and RPCsWladimir J. van der Laan
020628e3a4e88e36647eaf92bac4b3552796ac6a Tests for PSBT (Andrew Chow) a4b06fb42eb0ad94e562ca839391b57e69285136 Create wallet RPCs for PSBT (Andrew Chow) c27fe419efb3b6588c400d764122ffb33375e028 Create utility RPCs for PSBT (Andrew Chow) 8b5ef2793748065727a9a2498805ae5b269dcb4f SignPSBTInput wrapper function (Andrew Chow) 58a8e28918025c28f19ba19cbaa4a72374162942 Refactor transaction creation and transaction funding logic (Andrew Chow) e9d86a43ad8b1ab83b324e9a7a64c43a61337501 Methods for interacting with PSBT structs (Andrew Chow) 12bcc64f277f642ece03c25653e726f2276f0d51 Add pubkeys and whether input was witness to SignatureData (Andrew Chow) 41c607f09badb2c3ed58ff6fb17a8ebbef2cdabd Implement PSBT Structures and un/serialization methods per BIP 174 (Andrew Chow) Pull request description: This Pull Request fully implements the [updated](https://github.com/bitcoin/bips/pull/694) BIP 174 specification. It is based upon #13425 which implements the majority of the signing logic. BIP 174 specifies a binary transaction format which contains the information necessary for a signer to produce signatures for the transaction and holds the signatures for an input while the input does not have a complete set of signatures. This PR contains structs for PSBT, serialization, and deserialzation code. Some changes to `SignatureData` have been made to support detection of UTXO type and storing public keys. *** Many RPCs have been added to handle PSBTs. `walletprocesspsbt` takes a PSBT format transaction, updates the PSBT with any inputs related to this wallet, signs, and finalizes the transaction. There is also an option to not sign and just update. `walletcreatefundedpsbt` creates a PSBT from user provided data in the same form as createrawtransaction. It also funds the transaction and takes an options argument in the same form as `fundrawtransaction`. The resulting PSBT is blank with no input or output data filled in. It is analogous to a combination of `createrawtransaction` and `fundrawtransaction` `decodepsbt` takes a PSBT and decodes it to JSON. It is analogous to `decoderawtransaction` `combinepsbt` takes multiple PSBTs for the same tx and combines them. It is analogous to `combinerawtransaction` `finalizepsbt` takes a PSBT and finalizes the inputs. If all inputs are final, it extracts the network serialized transaction and returns that instead of a PSBT unless instructed otherwise. `createpsbt` is like `createrawtransaction` but for PSBTs instead of raw transactions. `convertpsbt` takes a network serialized transaction and converts it into a psbt. The resulting psbt will lose all signature data and an explicit flag must be set to allow transactions with signature data to be converted. *** This supersedes #12136 Tree-SHA512: 1ac7a79e5bc669933f0a6fcc93ded55263fdde9e8c144a30266b13ef9f62aacf43edd4cbca1ffbe003090b067e9643c9298c79be69d7c1b10231b32acafb6338
2018-07-16Create wallet RPCs for PSBTAndrew Chow
walletprocesspsbt takes a PSBT format transaction, updates the PSBT with any inputs related to this wallet, signs, and finalizes the transaction. There is also an option to not sign and just update. walletcreatefundedpsbt creates a PSBT from user provided data in the same form as createrawtransaction. It also funds the transaction and takes an options argument in the same form as fundrawtransaction. The resulting PSBT is blank with no input or output data filled in.
2018-07-13Merge #13072: Update createmultisig RPC to support segwitPieter Wuille
f40b3b82df [tests] functional test for createmultisig RPC (Anthony Towns) b9024fdda3 segwit support for createmultisig RPC (Anthony Towns) d58055d25f Move AddAndGetDestinationForScript from wallet to outputype module (Anthony Towns) 9a44db2e46 Add outputtype module (Anthony Towns) Pull request description: Adds an "address_type" parameter that accepts "legacy", "p2sh-segwit", and "bech32" to choose the type of address created. Defaults to "legacy" rather than the value of the `-address-type` option for backwards compatibility. As part of implementing this, OutputType is moved from wallet into its own module, and `AddAndGetDestinationForScript` is changed to apply to a `CKeyStore` rather than a wallet, and to invoke `keystore.AddCScript(script)` itself rather than expecting the caller to have done that. Fixes #12502 Tree-SHA512: a08c1cfa89976e4fd7d29caa90919ebd34a446354d17abb862e99f2ee60ed9bc19d8a21a18547c51dc3812cb9fbed86af0bef2f1e971f62bf95cade4a7d86237
2018-07-13Merge #13566: Fix get balancePieter Wuille
702ae1e21a [RPC] [wallet] allow getbalance to use min_conf and watch_only without accounts. (John Newbery) cf15761f6d [wallet] GetBalance can take a min_depth argument. (John Newbery) 0f3d6e9ab7 [wallet] factor out GetAvailableWatchOnlyBalance() (John Newbery) 7110c830f8 [wallet] deduplicate GetAvailableCredit logic (John Newbery) ef7bc8893c [wallet] Factor out GetWatchOnlyBalance() (John Newbery) 4279da4785 [wallet] GetBalance can take an isminefilter filter. (John Newbery) Pull request description: #12953 inadvertently removed the functionality to call `getbalance "*" <int> <bool>` to get the wallet's balance with either minconfs or include_watchonly. This restores that functionality (when `-deprecatedrpc=accounts`), and also makes it possible to call ``getbalance minconf=<int> include_watchonly=<bool>` when accounts are not being used. Tree-SHA512: 67e84de9291ed6d34b23c626f4dc5988ba0ae6c99708d02b87dd3aaad3f4b6baa6202a66cc2dadd30dd993a39de8036ee920fcaa8cbb1c5dfe606e6fac183344
2018-07-13Refactor transaction creation and transaction funding logicAndrew Chow
In preparation for more create transaction and fund transcation RPCs, refactor the transaction creation and funding logic into separate functions.
2018-07-12Add disable privatekeys option to createwalletJonas Schnelli
2018-07-12Add option to disable private keys during internal wallet creationJonas Schnelli
2018-07-10Move AddAndGetDestinationForScript from wallet to outputype moduleAnthony Towns
Makes AddAndGetDestinationForScript use a generic CKeyStore rather than the wallet, and makes it always add the script to the keystore, rather than only adding related (redeem) scripts.
2018-07-09Add outputtype moduleAnthony Towns
Moves OutputType into its own module
2018-07-07Merge #13564: [wallet] loadwallet shouldn't create new wallets.MarcoFalke
ea65182f03 [wallet] loadwallet shouldn't create new wallets. (John Newbery) Pull request description: A bug in the initial implementation of loadwallet meant that if the arguement was a directory that didn't contain a wallet.dat file, a new wallet would be created in that directory. Fix that so that if a directory is passed in, it must contain a wallet.dat file. Bug reported by promag (João Barbosa). Tree-SHA512: 0a59fa8a33fde51a88544ad288b00e4995284fe16424f643076aaba42b8244fff362145217650ee53d518dfab7efbed4237632c34cdd3dcbbecaa9ecaab5fd7b
2018-07-04Merge #13235: Break circular dependency: init -> * -> init by extracting ↵Wladimir J. van der Laan
shutdown.h 1fabd59e7 Break circular dependency: init -> * -> init by extracting shutdown.h (Ben Woosley) e62fdfeea Drop unused init.h includes (Ben Woosley) Pull request description: Most includers just wanted to react to pending shutdown. This isolates access to `fRequestShutdown` and limits access to the shutdown api functions, including the new `CancelShutdown` for setting it to `false`. Tree-SHA512: df42f75dfbba163576710e9a67cf1228531fd99d70a2f187bfba0bcc476d6749cf88180a97e66a81bb5b6c3c7f0917de7402d26039ba7b644cb7509b02f7e267
2018-06-29[RPC] [wallet] allow getbalance to use min_conf and watch_only without accounts.John Newbery
2018-06-28[wallet] loadwallet shouldn't create new wallets.John Newbery
A bug in the initial implementation of loadwallet meant that if the arguement was a directory that didn't contain a wallet.dat file, a new wallet would be created in that directory. Fix that so that if a directory is passed in, it must contain a wallet.dat file. Bug reported by promag (João Barbosa).
2018-06-26Merge #13498: [wallet] Fixups from account API deprecationPieter Wuille
df10f07db1 [wallet] Don't use accounts when checking balance in sendmany (John Newbery) e209184101 [wallet] deprecate sendfrom RPC method. (John Newbery) Pull request description: A couple of fixups from the accounts API deprecation PR (#12953): - properly deprecate `sendfrom` - don't use accounts when calculating balance in `sendmany` (unless the `-deprecatedrpc=accounts` flag is being used) Tree-SHA512: 1befde055067438c4c3391bbff1aaed0e6249efd708c567db3f1faad40a0f28e64f95e5bad0679ae826d24a0239e4bc8a1c392dc93e2e7502343a7f6b1d1845c
2018-06-25Break circular dependency: init -> * -> init by extracting shutdown.hBen Woosley
Most includers just wanted to react to pending shutdown. This isolates access to `fRequestShutdown` and limits access to the shutdown api functions, including the new `AbortShutdown` for setting it to `false`. Note I originally called `AbortShutdown` `CancelShutdown` but that name was already taken by winuser.h https://travis-ci.org/bitcoin/bitcoin/jobs/386913329 This change also triggered a build error in bench. Fixing it required moving LIBBITCOIN_SERVER after LIBBITCOIN_WALLET in bench_bench_bitcoin_LDADD To make server definitions in src/net.cpp available to wallet methods in src/wallet/wallet.cpp. Specifically, solving: libbitcoin_wallet.a(libbitcoin_wallet_a-wallet.o): In function `CWalletTx::RelayWalletTransaction(CConnman*)': wallet.cpp:(.text+0x3f0e): undefined reference to `CConnman::NodeFullyConnected(CNode const*)' collect2: error: ld returned 1 exit status https://travis-ci.org/bitcoin/bitcoin/jobs/392133581 Need for remaining init.h includes confirmed via a thorough search with a more specific regex: \bInterrupt\(\)|\bShutdown\(\)|\bInitLogging\(\)|\bInitParameterInteraction\(\)|\bAppInitBasicSetup\(\)|\bAppInitParameterInteraction\(\)|\bAppInitSanityChecks\(\)|\bAppInitLockDataDirectory\(\)|\bAppInitMain\(\)|\bSetupServerArgs\(\)|\bLicenseInfo\(\)|g_wallet_init_interface|init.h
2018-06-21Merge #13111: Add unloadwallet RPCJonas Schnelli
fe65bdec2 bugfix: Delete walletView in WalletFrame::removeWallet (João Barbosa) 0b82bac76 bugfix: Remove dangling wallet env instance (João Barbosa) 0ee77b207 ui: Support wallets unloaded dynamically (João Barbosa) 9f9b50d5f doc: Add release notes for unloadwallet RPC (João Barbosa) ccbf7ae74 test: Wallet methods are disabled when no wallet is loaded (João Barbosa) 4940a20a4 test: Add functional tests for unloadwallet RPC (João Barbosa) 6608c369b rpc: Add unloadwallet RPC (João Barbosa) 537efe19e rpc: Extract GetWalletNameFromJSONRPCRequest from GetWalletForJSONRPCRequest (João Barbosa) Pull request description: This patch adds wallet unload feature via RPC. It also adds UI support for unloaded wallets. Tree-SHA512: 7c7f9f32f7a2266d2df574aa6b95f993c3dc82736f93304562122beb8756fb28cd22d03866b48f493c747441f22d30e196b098dec435cc25e035633f090351ea
2018-06-18[wallet] Don't use accounts when checking balance in sendmanyJohn Newbery
2018-06-18[wallet] deprecate sendfrom RPC method.John Newbery
2018-06-18test: Wallet methods are disabled when no wallet is loadedJoão Barbosa
2018-06-18rpc: Add unloadwallet RPCJoão Barbosa
2018-06-15Merge #13241: scripted-diff: Avoid temporary copies when looping over std::mapMarcoFalke
9b72c988a0 scripted-diff: Avoid temporary copies when looping over std::map (Ben Woosley) Pull request description: The ::value_type of the std::map/std::multimap/std::unordered_map containers is std::pair<const Key, T>. Dropping the const results in an unnecessary copy, for example in C++11 range-based loops. For this I started with a more general scripted diff, then narrowed it down based on the inspection showing that all actual map/multimap/unordered_map variables used in loops start with m or have map in the name. Tree-SHA512: b656d66b69ffa1eb954124aa8ae2bc5436ca50262abefa93bdda55cfcdaffc5ff90cd40539051a2bd06355ba69ddf245265cc8764eebff66d761b3aec06155a9
2018-06-12Merge #13120: policy: Treat segwit as always activeWladimir J. van der Laan
fa7a6cf1b36284db70e941bd2915fd6edbb0f9d6 policy: Treat segwit as always active (MarcoFalke) Pull request description: Now that segwit is active for a long time, there is no need to reject transactions with the reason that segwit hasn't activated. Strictly speaking, this is a bug fix, because with the release of 0.16, we create segwit transactions in our wallet by default without checking if they are allowed by local policy. More broadly, this simplifies the code as if "premature witness" was always set to true with the corresponding command line args. Tree-SHA512: 484c26aa3a66faba6b41e8554a91a29bfc15fbf6caae3d5363a3966283143189c4bd5333a610b0669c1238f75620691264e73f6b9f1161cdacf7574d946436da
2018-06-12rpc: Extract GetWalletNameFromJSONRPCRequest from GetWalletForJSONRPCRequestJoão Barbosa
2018-06-11scripted-diff: Avoid temporary copies when looping over std::mapBen Woosley
The ::value_type of the std::map/std::multimap/std::unordered_map containers is std::pair<const Key, T>. Dropping the const results in an unnecessary copy, for example in C++11 range-based loops. For this I started with a more general scripted diff, then narrowed it down based on the inspection showing that all actual map/multimap/unordered_map variables used in loops start with m or have map in the name. -BEGIN VERIFY SCRIPT- sed -i -E 's/for \(([^<]*)std::pair<([^c])(.+) : m/for (\1std::pair<const \2\3 : m/' src/*.cpp src/**/*.cpp sed -i -E 's/for \(([^<]*)std::pair<([^c])(.+) : (.*)map/for (\1std::pair<const \2\3 : \4map/' src/*.cpp src/**/*.cpp -END VERIFY SCRIPT-
2018-06-11Merge #13060: [wallet] [rpc] Remove getlabeladdress RPCWladimir J. van der Laan
67e0e04140b3dfac12d628cee391d40b5fac5cfa [wallet] [docs] Update release notes for removing `getlabeladdress` (John Newbery) 81608178cff793ee205a4f70481c76d34c5448a4 [wallet] [rpc] Remove getlabeladdress RPC (John Newbery) Pull request description: labels are associated with addresses (rather than addresses being associated with labels, as was the case with accounts). The getlabeladdress does not make sense in this model, so remove it. getaccountaddress is still supported for one release as the accounts API is deprecated. Tree-SHA512: 7f45d0456248ebcc4e54dd34e2578a09a8ea8e4fceda75238ccea9d731dc99a3f3c0519b18a9739de17d2e6e59c9c2259ba67c9ae2e3cb2a40ddb14b9193fe29
2018-05-31[wallets] [docs] Add release notes for createwallet RPC.John Newbery
2018-05-29policy: Treat segwit as always activeMarcoFalke
2018-05-25[wallet] [rpc] Add `createwallet` RPCJohn Newbery
Add a `createwallet` RPC to allow wallets to be created dynamically at runtime. This functionality is currently only available through RPC and newly created wallets will not be displayed in the GUI.
2018-05-22wallet: Use shared pointer to retain wallet instanceJoão Barbosa
2018-05-19[rpc] [wallet] Add 'hdmasterkeyid' alias return values.John Newbery
Restores the return value in getwalletinfo() and getaddressinfo() RPC methods for backwards compatibility