lbrycrd/src
Glenn Willen 2ff659ac91 Refactor PSBTInput signing to enforce invariant
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
2020-03-26 15:39:50 +02:00
..
bench scripted-diff: Use ArgsManager::DEBUG_ONLY flag 2019-07-27 15:05:14 +03:00
compat Include cstring for sanity_test_fdelt if required 2019-04-13 20:21:02 -07:00
config
consensus Merge #16713: Ignore old versionbit activations to avoid 'unknown softforks' warning 2019-09-27 15:25:53 -04:00
crypto Add ChaCha20Poly1305@Bitcoin AEAD implementation 2019-06-25 15:13:02 +02:00
index scripted-diff: Make translation bilingual 2019-07-24 16:33:20 +03:00
interfaces Drop signal CClientUIInterface::LoadWallet 2020-01-14 09:34:35 +00:00
leveldb Pull leveldb subtree 2019-01-26 12:45:48 -05:00
node psbt: check output index is within bounds before accessing 2020-02-06 23:22:30 +00:00
policy [wallet] abort when attempting to fund a transaction above maxtxfee 2019-06-28 22:44:38 -04:00
primitives Make reasoning about dependencies easier by not including unused dependencies 2019-06-02 17:15:23 +02:00
qt qt: Pre-rc1 translations update 2020-03-26 15:39:50 +02:00
rpc Simplify arguments to SignPSBTInput 2020-03-26 15:39:50 +02:00
script Refactor PSBTInput signing to enforce invariant 2020-03-26 15:39:50 +02:00
secp256k1 Update the secp256k1 subtree to the latest upstream version 2019-03-31 11:41:05 -07:00
support Improve documentation of memory_cleanse() 2019-07-01 12:59:44 +02:00
test test: add missing #include to fix compiler errors 2020-01-23 09:41:09 +08:00
univalue Update univalue subtree 2020-02-09 07:50:08 -08:00
util bug-fix macos: give free bytes to F_PREALLOCATE 2020-01-23 08:11:10 +08:00
wallet Refactor PSBTInput signing to enforce invariant 2020-03-26 15:39:50 +02:00
zmq zmq: Fix due to invalid argument and multiple notifiers 2020-01-14 09:34:35 +00:00
.clang-format Fix inconsistent namespace formatting guidelines 2018-04-13 15:37:20 -04:00
addrdb.cpp addrdb: Remove temporary files created in SerializeFileDB. Fixes non-determinism in unit tests. 2019-06-14 08:30:43 +02:00
addrdb.h banman: Add, use CBanEntry ctor that takes ban reason 2019-01-16 13:54:18 -05:00
addrman.cpp Make reasoning about dependencies easier by not including unused dependencies 2019-06-02 17:15:23 +02:00
addrman.h [addrman] Ensure collisions eventually get resolved 2019-02-27 16:53:44 -05:00
amount.h Update copyright headers to 2018 2018-12-29 10:15:01 +01:00
arith_uint256.cpp Make reasoning about dependencies easier by not including unused dependencies 2019-06-02 17:15:23 +02:00
arith_uint256.h Use std::numeric_limits<UNSIGNED>::max()) instead of (UNSIGNED)-1 2018-12-04 19:55:04 +02:00
attributes.h Add NODISCARD to all {Decode,Parse}[...](...) functions returning bool. Sort includes. 2018-11-05 17:03:11 +01:00
banman.cpp scripted-diff: Make translation bilingual 2019-07-24 16:33:20 +03:00
banman.h Allow connections from misbehavior banned peers. 2019-01-22 21:10:48 +00:00
base58.cpp scripted-diff: Move util files to separate directory. 2018-11-04 22:46:07 -08:00
base58.h Add NODISCARD to all {Decode,Parse}[...](...) functions returning bool. Sort includes. 2018-11-05 17:03:11 +01:00
bech32.cpp Assert that the HRP is lowercase in Bech32::Encode 2019-09-05 13:25:11 +12:00
bech32.h Assert that the HRP is lowercase in Bech32::Encode 2019-09-05 13:25:11 +12:00
bitcoin-cli-res.rc
bitcoin-cli.cpp cli: fix -getinfo output when compiled with no wallet 2019-11-08 09:09:45 -05:00
bitcoin-tx-res.rc
bitcoin-tx.cpp Testchains: Generic selection with -chain=<str> in addition of -testnet and -regtest 2019-09-06 22:05:33 +02:00
bitcoin-wallet-res.rc [tools] Add wallet inspection and modification tool 2019-01-30 16:26:52 -05:00
bitcoin-wallet.cpp bitcoin-wallet: Add a missing closing parenthesis in the help 2019-09-13 16:59:06 +02:00
bitcoind-res.rc
bitcoind.cpp Don't rename main thread at process level 2019-10-03 20:51:25 +02:00
blockencodings.cpp CorruptionPossible -> BLOCK_MUTATED 2019-05-02 15:14:12 -04:00
blockencodings.h disallow oversized CBlockHeaderAndShortTxIDs 2018-11-13 12:41:41 -08:00
blockfilter.cpp cli: fix Fatal LevelDB error when specifying -blockfilterindex=basic twice 2020-01-03 18:36:57 +08:00
blockfilter.h cli: fix Fatal LevelDB error when specifying -blockfilterindex=basic twice 2020-01-03 18:36:57 +08:00
bloom.cpp refactor: Improve CRollingBloomFilter::reset by using std::fill 2019-05-22 15:55:50 +01:00
bloom.h Removes unsed CBloomFilter constructor. 2018-08-13 01:24:55 +02:00
chain.cpp refactor: combine Chain::findFirstBlockWithTime/findFirstBlockWithTimeAndHeight 2019-03-27 18:29:48 -04:00
chain.h [doc] chain: Declare BLOCK_VALID_HEADER reserved 2019-08-05 07:58:58 -04:00
chainparams.cpp fix uninitialized variable nMinerConfirmationWindow 2019-11-14 20:36:44 +01:00
chainparams.h Remove wallet settings from chainparams 2019-07-16 16:22:14 -04:00
chainparamsbase.cpp Testchains: Generic selection with -chain=<str> in addition of -testnet and -regtest 2019-09-06 22:05:33 +02:00
chainparamsbase.h Remove wallet settings from chainparams 2019-07-16 16:22:14 -04:00
chainparamsseeds.h contrib: Remove invalid nodes from seeds list 2019-10-02 08:51:12 +02:00
checkqueue.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
clientversion.cpp Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
clientversion.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
coins.cpp move-onlyish: move CCoinsViewErrorCatcher out of init.cpp 2019-07-21 21:00:31 -04:00
coins.h make SaltedOutpointHasher noexcept 2019-09-25 20:56:38 +02:00
compat.h windows: Set _WIN32_WINNT to 0x0601 (Windows 7) 2019-01-23 16:28:27 +08:00
compressor.cpp Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
compressor.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
core_io.h Move PSBT decoding functions from core_io to psbt.cpp 2019-03-26 17:38:00 -07:00
core_memusage.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
core_read.cpp Include core_io.h from core_read.cpp 2019-06-06 08:00:33 +02:00
core_write.cpp Don't show addresses or P2PK in decoderawtransaction 2019-08-30 11:29:21 +09:00
cuckoocache.h Use correct C++11 header for std::swap() 2020-01-15 12:13:02 +00:00
dbwrapper.cpp Replace deprecated Boost Filesystem function 2019-04-30 10:05:54 +03:00
dbwrapper.h scripted-diff: Move util files to separate directory. 2018-11-04 22:46:07 -08:00
dummywallet.cpp Drop signal CClientUIInterface::LoadWallet 2020-01-14 09:34:35 +00:00
flatfile.cpp Style cleanup. 2019-02-22 17:38:45 -08:00
flatfile.h Style cleanup. 2019-02-22 17:38:45 -08:00
fs.cpp Avoid redefine warning 2019-04-10 12:16:52 +01:00
fs.h wallet: unbreak with boost 1.72 2020-01-03 18:33:08 +08:00
hash.cpp Extract CSipHasher to it's own file in crypto/ directory. 2018-11-05 09:25:15 -08:00
hash.h Squashed 'src/secp256k1/' changes from 0b70241850..b19c000063 2019-03-31 11:41:05 -07:00
httprpc.cpp scripted-diff: Make translation bilingual 2019-07-24 16:33:20 +03:00
httprpc.h Cleanup StartRest() 2018-08-11 09:34:47 +03:00
httpserver.cpp http: add missing header bootlegged by boost < 1.72 2019-10-26 13:02:46 +02:00
httpserver.h [build] Add several util units 2019-04-09 17:53:08 -04:00
indirectmap.h
init.cpp init: Stop indexes on shutdown after ChainStateFlushed callback. 2020-01-22 17:51:23 +08:00
init.h Pass chain and client variables where needed 2018-11-06 11:44:40 -04:00
key.cpp Make reasoning about dependencies easier by not including unused dependencies 2019-06-02 17:15:23 +02:00
key.h CKey: add method to negate the key 2019-03-27 13:59:50 +01:00
key_io.cpp Replace CScriptID and CKeyID in CTxDestination with dedicated types 2019-04-29 10:15:23 -04:00
key_io.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
limitedmap.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
logging.cpp util: Filter control characters out of log messages 2019-10-19 13:58:18 -04:00
logging.h test: Log to debug.log in all tests 2019-06-20 12:12:24 -04:00
Makefile.am scripts: fix check-symbols & check-security argument passing 2020-01-06 15:50:30 +08:00
Makefile.bench.include Merge #15649: Add ChaCha20Poly1305@Bitcoin AEAD 2019-07-11 22:00:16 +02:00
Makefile.leveldb.include build: Remove WINVER pre define in Makefile.leveldb.inlcude 2019-01-26 09:28:48 +08:00
Makefile.qt.include build: Factor out qt translations from build system 2019-09-29 14:24:54 +02:00
Makefile.qt_locale.include qt: Periodic translations update for 0.19 branch 2020-01-08 13:47:27 +01:00
Makefile.qttest.include scripted-diff: Rename test_bitcoin to test/setup_common 2019-04-11 10:12:36 -04:00
Makefile.test.include Move ismine to wallet module 2019-06-19 18:06:30 -04:00
memusage.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
merkleblock.cpp Make reasoning about dependencies easier by not including unused dependencies 2019-06-02 17:15:23 +02:00
merkleblock.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
miner.cpp Make reasoning about dependencies easier by not including unused dependencies 2019-06-02 17:15:23 +02:00
miner.h [rpc] mining: Omit uninitialized currentblockweight, currentblocktx 2019-02-12 11:34:57 -05:00
net.cpp Merge #15558: Don't query all DNS seeds at once 2019-09-23 12:53:50 +08:00
net.h doc: add comments clarifying how local services are advertised 2019-09-11 10:24:44 -04:00
net_permissions.cpp util: Move ResolveErrMsg to util/error 2019-08-15 10:05:32 -04:00
net_permissions.h Make whitebind/whitelist permissions more flexible 2019-08-11 11:33:27 +09:00
net_processing.cpp Add missing typeinfo includes 2020-01-05 07:30:49 +08:00
net_processing.h refactor : use RelayTransaction in BroadcastTransaction utility 2019-07-24 19:47:56 -04:00
netaddress.cpp Fix spelling errors identified by codespell 1.15.0 2019-06-11 17:18:16 +02:00
netaddress.h netaddress: Update CNetAddr for ORCHIDv2 2019-05-15 14:21:48 -04:00
netbase.cpp util: refactor upper/lowercase functions 2019-08-08 11:35:14 +09:00
netbase.h util: refactor upper/lowercase functions 2019-08-08 11:35:14 +09:00
netmessagemaker.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
noui.cpp Merge #16277: [Tests] Suppress output in test_bitcoin for expected errors 2019-08-01 15:17:10 +02:00
noui.h Suppress output in test_bitcoin for expected errors 2019-07-03 14:03:21 +02:00
optional.h Remove 'boost::optional'-related gcc warnings 2019-01-30 22:44:28 +02:00
outputtype.cpp Move various SigningProviders to signingprovider.{cpp,h} 2019-07-09 16:20:18 -04:00
outputtype.h Move various SigningProviders to signingprovider.{cpp,h} 2019-07-09 16:20:18 -04:00
pow.cpp Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
pow.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
prevector.h Use correct C++11 header for std::swap() 2020-01-15 12:13:02 +00:00
protocol.cpp scripted-diff: Move util files to separate directory. 2018-11-04 22:46:07 -08:00
protocol.h Remove unused bits from the service flags enum 2019-07-12 14:14:54 -04:00
psbt.cpp psbt: check output index is within bounds before accessing 2020-02-06 23:22:30 +00:00
psbt.h Have a PSBTAnalysis state that indicates invalid PSBT 2020-01-03 04:04:38 +00:00
pubkey.cpp Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
pubkey.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
random.cpp net: Use mockable time for tx download 2019-06-17 14:12:32 -04:00
random.h net: Use mockable time for tx download 2019-06-17 14:12:32 -04:00
rest.cpp refactor: pcoinsTip -> CChainState::CoinsTip() 2019-08-06 13:13:06 -04:00
reverse_iterator.h scripted-diff: Remove trailing whitespaces 2018-07-24 20:46:23 +01:00
reverselock.h
scheduler.cpp Switch all RNG code to the built-in PRNG. 2019-01-16 16:34:56 -08:00
scheduler.h trivial: correct parameter name in comments 2019-02-10 17:17:32 -05:00
serialize.h Support serialization of std::vector<bool> 2019-08-26 11:36:33 -07:00
shutdown.cpp Break circular dependency: init -> * -> init by extracting shutdown.h 2018-06-25 00:08:49 -04:00
shutdown.h Break circular dependency: init -> * -> init by extracting shutdown.h 2018-06-25 00:08:49 -04:00
span.h Add more methods to Span class 2018-07-27 11:52:18 -07:00
streams.h util: CBufferedFile fixes 2019-09-10 07:53:09 -06:00
sync.cpp Replace remaining fprintf with tfm::format manually 2019-06-13 11:46:38 -04:00
sync.h scripted-diff: Rename LockAnnotation to LockAssertion 2019-05-17 13:29:04 +02:00
threadinterrupt.cpp Merge #11640: Make LOCK, LOCK2, TRY_LOCK work with CWaitableCriticalSection 2018-08-31 16:00:38 +02:00
threadinterrupt.h Update copyright headers to 2018 2018-12-29 10:15:01 +01:00
threadsafety.h Move LockAnnotation from threadsafety.h (imported code) to sync.h (our code) 2019-05-17 13:29:04 +02:00
timedata.cpp scripted-diff: Make translation bilingual 2019-07-24 16:33:20 +03:00
timedata.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
tinyformat.h tinyformat: Add doc to Bitcoin Core specific strprintf 2019-06-13 09:30:40 -04:00
torcontrol.cpp fix: tor: Call event_base_loopbreak from the event's callback 2019-07-17 15:32:38 +01:00
torcontrol.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
txdb.cpp refactor: have CCoins* data managed under CChainState 2019-08-15 11:04:10 -04:00
txdb.h refactor: have CCoins* data managed under CChainState 2019-08-15 11:04:10 -04:00
txmempool.cpp validation: Add missing mempool locks 2019-06-07 11:07:09 +02:00
txmempool.h refactor: pcoinsTip -> CChainState::CoinsTip() 2019-08-06 13:13:06 -04:00
ui_interface.cpp Drop signal CClientUIInterface::LoadWallet 2020-01-14 09:34:35 +00:00
ui_interface.h Drop signal CClientUIInterface::LoadWallet 2020-01-14 09:34:35 +00:00
uint256.cpp Merge #14734: fix an undefined behavior in uint::SetHex 2019-07-03 14:18:29 +02:00
uint256.h uint256: Remove unnecessary crypto/common.h use 2018-09-18 14:27:05 +09:00
undo.h Extract CSipHasher to it's own file in crypto/ directory. 2018-11-05 09:25:15 -08:00
validation.cpp Merge #16849: Fix block index inconsistency in InvalidateBlock() 2019-10-02 13:40:39 +02:00
validation.h Use correct C++11 header for std::swap() 2020-01-15 12:13:02 +00:00
validationinterface.cpp Make reasoning about dependencies easier by not including unused dependencies 2019-06-02 17:15:23 +02:00
validationinterface.h Remove extra CBlockIndex declaration 2019-06-25 15:02:34 -04:00
version.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
versionbits.cpp doc: Improve versionbits.h documentation 2019-08-15 11:02:55 -04:00
versionbits.h doc: Improve versionbits.h documentation 2019-08-15 11:02:55 -04:00
versionbitsinfo.cpp [Consensus] Bury segwit deployment 2019-08-14 15:52:52 -04:00
versionbitsinfo.h MOVEONLY: Move versionbits info out of versionbits.o 2018-09-23 22:55:11 +02:00
walletinitinterface.h refactor: Cleanup walletinitinterface.h 2019-09-08 17:29:30 +03:00
warnings.cpp scripted-diff: Make translation bilingual 2019-07-24 16:33:20 +03:00
warnings.h Merge #13780: 0.17: Pre-branch maintenance 2018-08-08 13:55:27 +02:00