aboutsummaryrefslogtreecommitdiff
path: root/src/qt/paymentserver.cpp
AgeCommit message (Collapse)Author
2018-01-23[wallet] use P2WPKH change output if any destination is P2WPKH or P2WSHSjors Provoost
Only if -changetype is not set and -addresstype is not "legacy".
2018-01-10Merge #11403: SegWit wallet supportJonas Schnelli
b224a47a1 Add address_types test (Pieter Wuille) 7ee54fd7c Support downgrading after recovered keypool witness keys (Pieter Wuille) 940a21932 SegWit wallet support (Pieter Wuille) f37c64e47 Implicitly know about P2WPKH redeemscripts (Pieter Wuille) 57273f2b3 [test] Serialize CTransaction with witness by default (Pieter Wuille) cf2c0b6f5 Support P2WPKH and P2SH-P2WPKH in dumpprivkey (Pieter Wuille) 37c03d3e0 Support P2WPKH addresses in create/addmultisig (Pieter Wuille) 3eaa003c8 Extend validateaddress information for P2SH-embedded witness (Pieter Wuille) 30a27dc5b Expose method to find key for a single-key destination (Pieter Wuille) 985c79552 Improve witness destination types and use them more (Pieter Wuille) cbe197470 [refactor] GetAccount{PubKey,Address} -> GetAccountDestination (Pieter Wuille) 0c8ea6380 Abstract out IsSolvable from Witnessifier (Pieter Wuille) Pull request description: This implements a minimum viable implementation of SegWit wallet support, based on top of #11389, and includes part of the functionality from #11089. Two new configuration options are added: * `-addresstype`, with options `legacy`, `p2sh`, and `bech32`. It controls what kind of addresses are produced by `getnewaddress`, `getaccountaddress`, and `createmultisigaddress`. * `-changetype`, with the same options, and by default equal to `-addresstype`, that controls what kind of change is used. All wallet private and public keys can be used for any type of address. Support for address types dependent on different derivation paths will need a major overhaul of how our internal detection of outputs work. I expect that that will happen for a next major version. The above also applies to imported keys, as having a distinction there but not for normal operations is a disaster for testing, and probably for comprehension of users. This has some ugly effects, like needing to associate the provided label to `importprivkey` with each style address for the corresponding key. To deal with witness outputs requiring a corresponding redeemscript in wallet, three approaches are used: * All SegWit addresses created through `getnewaddress` or multisig RPCs explicitly get their redeemscripts added to the wallet file. This means that downgrading after creating a witness address will work, as long as the wallet file is up to date. * All SegWit keys in the wallet get an _implicit_ redeemscript added, without it being written to the file. This means recovery of an old backup will work, as long as you use new software. * All keypool keys that are seen used in transactions explicitly get their redeemscripts added to the wallet files. This means that downgrading after recovering from a backup that includes a witness address will work. These approaches correspond to solutions 3a, 1a, and 5a respectively from https://gist.github.com/sipa/125cfa1615946d0c3f3eec2ad7f250a2. As argued there, there is no full solution for dealing with the case where you both downgrade and restore a backup, so that's also not implemented. `dumpwallet`, `importwallet`, `importmulti`, `signmessage` and `verifymessage` don't work with SegWit addresses yet. They're remaining TODOs, for this PR or a follow-up. Because of that, several tests unexpectedly run with `-addresstype=legacy` for now. Tree-SHA512: d425dbe517c0422061ab8dacdc3a6ae47da071450932ed992c79559d922dff7b2574a31a8c94feccd3761c1dffb6422c50055e6dca8e3cf94a169bc95e39e959
2018-01-09SegWit wallet supportPieter Wuille
This introduces two command line flags (-addresstype and -changetype) which control the type of addresses/outputs created by the GUI and RPCs. Certain RPCs allow overriding these (`getnewaddress` and `getrawchangeaddress`). Supported types are "legacy" (P2PKH and P2SH-multisig), "p2sh-segwit" (P2SH-P2WPKH and P2SH-P2WSH-multisig), and "bech32" (P2WPKH and P2WSH-multisig). A few utility functions are added to the wallet to construct different address type and to add the necessary entries to the wallet file to be compatible with earlier versions (see `CWallet::LearnRelatedScripts`, `GetDestinationForKey`, `GetAllDestinationsForKey`, `CWallet::AddAndGetDestinationForScript`).
2018-01-03Increment MIT Licence copyright header year on files modified in 2017Akira Takizawa
2017-11-16scripted-diff: Replace #include "" with #include <> (ryanofsky)MeshCollider
-BEGIN VERIFY SCRIPT- for f in \ src/*.cpp \ src/*.h \ src/bench/*.cpp \ src/bench/*.h \ src/compat/*.cpp \ src/compat/*.h \ src/consensus/*.cpp \ src/consensus/*.h \ src/crypto/*.cpp \ src/crypto/*.h \ src/crypto/ctaes/*.h \ src/policy/*.cpp \ src/policy/*.h \ src/primitives/*.cpp \ src/primitives/*.h \ src/qt/*.cpp \ src/qt/*.h \ src/qt/test/*.cpp \ src/qt/test/*.h \ src/rpc/*.cpp \ src/rpc/*.h \ src/script/*.cpp \ src/script/*.h \ src/support/*.cpp \ src/support/*.h \ src/support/allocators/*.h \ src/test/*.cpp \ src/test/*.h \ src/wallet/*.cpp \ src/wallet/*.h \ src/wallet/test/*.cpp \ src/wallet/test/*.h \ src/zmq/*.cpp \ src/zmq/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT-
2017-11-09Merge #10696: Remove redundant nullptr checks before deallocationWladimir J. van der Laan
b109a1c Remove redundant nullptr checks before deallocation (practicalswift) Pull request description: Rationale: * `delete ptr` is a no-op if `ptr` is `nullptr` Tree-SHA512: c98ce769125c4912186a8403cc08a59cfba85b7141af645c709b4c4eb90dd9cbdd6ed8076d50099d1e4ec2bf75917d1af6844082ec42bbb4d94d229a710e051c
2017-09-06Introduce wrappers around CBitcoinAddressPieter Wuille
This patch removes the need for the intermediary Base58 type CBitcoinAddress, by providing {Encode,Decode,IsValid}Destination function that directly operate on the conversion between strings and CTxDestination.
2017-08-15Merge #10964: Pass SendCoinsRecipient (208 bytes) by referenceJonas Schnelli
d3d946a29 Pass SendCoinsRecipient (208 bytes) by const reference (practicalswift) Pull request description: Pass `SendCoinsRecipient` (208 bytes) by reference. Avoid passing big parameters by value. Tree-SHA512: 504791f1b1c73badbc276db13b83e39695298d7d82a9db0e48d54e7ef02f1a8d276b0adfdece1ba1130cc214e2f0fa9a3100b5359d0ca0fe96558d3c9a786e6e
2017-08-14Remove redundant nullptr checks before deallocationpracticalswift
Rationale: * delete ptr is a no-op if ptr is nullptr
2017-08-14scripted-diff: stop using the gArgs wrappersMarko Bencun
They were temporary additions to ease the transition. -BEGIN VERIFY SCRIPT- find src/ -name "*.cpp" ! -wholename "src/util.h" ! -wholename "src/util.cpp" | xargs perl -i -pe 's/(?<!\.)(ParseParameters|ReadConfigFile|IsArgSet|(Soft|Force)?(Get|Set)(|Bool|)Arg(s)?)\(/gArgs.\1(/g' -END VERIFY SCRIPT-
2017-08-07scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal ↵practicalswift
instead of the macro NULL -BEGIN VERIFY SCRIPT- sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp -END VERIFY SCRIPT-
2017-08-02Pass SendCoinsRecipient (208 bytes) by const referencepracticalswift
2017-06-05scripted-diff: Remove PAIRTYPEJorge Timón
-BEGIN VERIFY SCRIPT- sed -i 's/PAIRTYPE(\([^,]*\), \([^\)]*\))/std::pair<\1, \2>/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ; sed -i ':a;N;$!ba;s/#define std::pair<t1, t2> std::pair<t1, t2>\n//' ./src/utilstrencodings.h ; -END VERIFY SCRIPT-
2017-06-05scripted-diff: Remove Q_FOREACHJorge Timón
-BEGIN VERIFY SCRIPT- sed -i 's/Q_FOREACH *(\(.*\),/for (\1 :/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ; -END VERIFY SCRIPT-
2017-05-09Merge #8855: Use a proper factory for creating chainparamsWladimir J. van der Laan
c1082a7 Chainparams: Use the factory for pow tests (Jorge Timón) 2351a06 Chainparams: Get rid of CChainParams& Params(std::string) (Jorge Timón) f87f362 Chainparams: Use a regular factory for creating chainparams (Jorge Timón) Tree-SHA512: 359c8a2a1bc9d02db7856d02810240ada28048ac088f878b575597a7255cdb0ffdd1a647085ee67a34c6a7e7ed9e6cfdb61240cf6e75139619b640dbb096072c
2017-05-03Chainparams: Get rid of CChainParams& Params(std::string)Jorge Timón
2017-05-03Consensus: Minimal way to move dust out of consensusJorge Timón
2017-02-17Move BIP70_MAX_PAYMENTREQUEST_SIZE to headerPieter Wuille
2017-01-16Introduce -dustrelayfeeAlex Morcos
2016-12-31Increment MIT Licence copyright header year on files modified in 2016isle2983
Edited via: $ contrib/devtools/copyright_header.py update .
2016-12-02Rename the remaining main.{h,cpp} to validation.{h,cpp}Matt Corallo
2016-11-23qt: Avoid OpenSSL certstore-related memory leakWladimir J. van der Laan
- Correctly manage the X509 and X509_STORE objects lifetime.
2016-11-07qt: Use correct conversion function for boost::path datadirWladimir J. van der Laan
Fixes #9089.
2016-09-23Do not shadow in src/qtPavel Janík
2015-12-13Bump copyright headers to 2015MarcoFalke
2015-09-15Merge pull request #5665Jeff Garzik
2015-08-10typofixes (found by misspell_fixer)Veres Lajos
2015-08-10[Qt] add verifySize() function to PaymentServerPhilip Kaufmann
- add static verifySize() function to PaymentServer and move the logging on error into the function - also use the new function in the unit test - the function checks if the size is allowed as per BIP70
2015-07-23Includes: Cleanup around net main and walletJorge Timón
-Move from .h to .cpp: in main, net and wallet -Remove unnecessary #include "main.h" -Cleanup some wallet files includes
2015-07-16[Qt] remove std namespace polution from codePhilip Kaufmann
2015-07-15qt: define QT_NO_KEYWORDSWladimir J. van der Laan
QT_NO_KEYWORDS prevents Qt from defining the `foreach`, `signals`, `slots` and `emit` macros. Avoid overlap between Qt macros and boost - for example #undef hackiness in #6421.
2015-04-15[Qt] minor comment updates in PaymentServerPhilip Kaufmann
2015-04-15[Qt] constify first parameter of processPaymentRequest()Philip Kaufmann
2015-04-15[Qt] paymentserver: better logging of invalid certsPhilip Kaufmann
Before and after was tested in Windows: before: GUI: ReportInvalidCertificate : Payment server found an invalid certificate: ("Microsoft Authenticode(tm) Root Authority") GUI: ReportInvalidCertificate : Payment server found an invalid certificate: () GUI: ReportInvalidCertificate : Payment server found an invalid certificate: () GUI: ReportInvalidCertificate : Payment server found an invalid certificate: () after: GUI: ReportInvalidCertificate: Payment server found an invalid certificate: "01" ("Microsoft Authenticode(tm) Root Authority") () () GUI: ReportInvalidCertificate: Payment server found an invalid certificate: "01" () () ("Copyright (c) 1997 Microsoft Corp.", "Microsoft Time Stamping Service Root", "Microsoft Corporation") GUI: ReportInvalidCertificate: Payment server found an invalid certificate: "4a:19:d2:38:8c:82:59:1c:a5:5d:73:5f:15:5d:dc:a3" () () ("NO LIABILITY ACCEPTED, (c)97 VeriSign, Inc.", "VeriSign Time Stamping Service Root", "VeriSign, Inc.") GUI: ReportInvalidCertificate: Payment server found an invalid certificate: "e4:9e:fd:f3:3a:e8:0e:cf:a5:11:3e:19:a4:24:02:32" () () ("Class 3 Public Primary Certification Authority")
2015-04-15[Qt] paymentserver: do not log NULL certificatesPhilip Kaufmann
- also add a few more comments in PaymentServer::LoadRootCAs
2015-03-24Includes: Do not include main.h from any other headerJorge Timón
2015-03-12[Move Only] Move wallet related things to src/wallet/Jonas Schnelli
could once be renamed from /src/wallet to /src/legacywallet.
2015-02-15openssl: abstract out OPENSSL_cleanseCory Fields
This makes it easier for us to replace it if desired, since it's now only in one spot. Also, it avoids the openssl include from allocators.h, which essentially forced openssl to be included from every compilation unit.
2015-02-04[Qt] prevent amount overflow problem with payment requestsPhilip Kaufmann
Bitcoin amounts are stored as uint64 in the protobuf messages (see paymentrequest.proto), but CAmount is defined as int64_t. Because of that we need to verify that single and accumulated amounts are in a valid range and no variable overflow has happened. - fixes #5624 (#5622) Thanks @SergioDemianLerner for reporting that issue and also supplying us with a possible solution. - add static verifyAmount() function to PaymentServer and move the logging on error into the function - also add a unit test to paymentservertests.cpp
2015-01-31Remove whitespaces before double colon in errors and logsPavel Janík
2015-01-29Merge pull request #5620Wladimir J. van der Laan
6715efb [Qt] Payment request expiration bug fix (re-done) (Philip Kaufmann)
2015-01-15[Qt] add debug logging for -rootcertificates optionPhilip Kaufmann
- now logs if -rootcertificates="" was used to disable payment request authentication via X.509 certificates - also logs which file is used as trusted root cert, if -rootcertificates is set
2015-01-15[Qt] Payment request expiration bug fix (re-done)Philip Kaufmann
- this is based on #4122 (which can be closed) Currently a payment request is only checked for expiration upon receipt. It should be checked again immediately before sending coins to prevent the user from paying to an expired invoice which would then require a customer service interaction. - add static verifyExpired() function to PaymentServer to be able to use the same validation code in GUI and unit-testing code - extend unit tests to use that function and also add an unit test which overflows, because payment requests allow expires as uint64, whereas we use int64_t for verification of expired payment requests
2015-01-14[Qt] add payment request unit test for non matching networksPhilip Kaufmann
- verify that payment request network matches client network - add static verifyNetwork() function to PaymentServer to be able to use the same validation code in GUI and unit-testing code
2015-01-02namespace: remove boost namespace pollutionCory Fields
2014-12-31[Qt] update a translation string and argument countsPhilip Kaufmann
2014-12-19Added "Core" to copyright headerssandakersmann
Github-Pull: #5494 Rebased-From: 15de949bb9277e442302bdd8dee299a8d6deee60
2014-12-08[Qt] update paymentserver license and cleanup orderingPhilip Kaufmann
2014-12-08[Qt] add BIP70 payment request size DoS protection for URIsPhilip Kaufmann
- current code only does this for payment request files, which are used on Mac - also rename readPaymentRequest to readPaymentRequestFromFile, so it's obvious that function only handles payment request files and not URIs - small logging changes in readPaymentRequestFromFile
2014-12-08[Qt] remove dup lock that is done in SetAddressBook()Philip Kaufmann