diff options
69 files changed, 2767 insertions, 760 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f5d63517b1..4e67af6278 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -170,13 +170,13 @@ judge the general consensus of contributors. In general, all pull requests must: - - have a clear use case, fix a demonstrable bug or serve the greater good of + - Have a clear use case, fix a demonstrable bug or serve the greater good of the project (for example refactoring for modularisation); - - be well peer reviewed; - - have unit tests and functional tests where appropriate; - - follow code style guidelines; - - not break the existing test suite; - - where bugs are fixed, where possible, there should be unit tests + - Be well peer reviewed; + - Have unit tests and functional tests where appropriate; + - Follow code style guidelines; + - Not break the existing test suite; + - Where bugs are fixed, where possible, there should be unit tests demonstrating the bug and also proving the fix. This helps prevent regression. Patches that change Bitcoin consensus rules are considerably more involved than diff --git a/configure.ac b/configure.ac index ba523d3762..fd1396fc9e 100644 --- a/configure.ac +++ b/configure.ac @@ -674,6 +674,14 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [ AC_MSG_RESULT(no)] ) +AC_MSG_CHECKING(for getentropy via random.h) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h> + #include <sys/random.h>]], + [[ getentropy(nullptr, 32) ]])], + [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_GETENTROPY_RAND, 1,[Define this symbol if the BSD getentropy system call is available with sys/random.h]) ], + [ AC_MSG_RESULT(no)] +) + AC_MSG_CHECKING(for sysctl KERN_ARND) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> #include <sys/sysctl.h>]], diff --git a/doc/developer-notes.md b/doc/developer-notes.md index 458e7bcbff..d783a7a8ae 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -561,10 +561,10 @@ A few guidelines for introducing and reviewing new RPC interfaces: which is error prone, and it is easy to get things such as escaping wrong. JSON already supports nested data structures, no need to re-invent the wheel. - - *Exception*: AmountToValue can parse amounts as string. This was introduced because many JSON + - *Exception*: AmountFromValue can parse amounts as string. This was introduced because many JSON parsers and formatters hard-code handling decimal numbers as floating point values, resulting in potential loss of precision. This is unacceptable for - monetary values. **Always** use `AmountToValue` and `ValueToAmount` when + monetary values. **Always** use `AmountFromValue` and `ValueFromAmount` when inputting or outputting monetary values. The only exceptions to this are `prioritisetransaction` and `getblocktemplate` because their interface is specified as-is in BIP22. diff --git a/doc/gitian-building.md b/doc/gitian-building.md index 9f9afaf04f..636686b391 100644 --- a/doc/gitian-building.md +++ b/doc/gitian-building.md @@ -76,7 +76,11 @@ In the VirtualBox GUI click "New" and choose the following parameters in the wiz After creating the VM, we need to configure it. -- Click the `Settings` button, then go to the `Network` tab. Adapter 1 should be attached to `NAT`. +- Click the `Settings` button, then go to `System` tab and `Processor` sub-tab. Increase the number of processors to the number of cores on your machine if you want builds to be faster. + +![](gitian-building/system_settings.png) + +- Go to the `Network` tab. Adapter 1 should be attached to `NAT`. ![](gitian-building/network_settings.png) diff --git a/doc/gitian-building/system_settings.png b/doc/gitian-building/system_settings.png Binary files differnew file mode 100644 index 0000000000..a5720ef3a3 --- /dev/null +++ b/doc/gitian-building/system_settings.png diff --git a/doc/release-process.md b/doc/release-process.md index 5a99b726f1..f429b4bbdb 100644 --- a/doc/release-process.md +++ b/doc/release-process.md @@ -111,16 +111,16 @@ The gbuild invocations below <b>DO NOT DO THIS</b> by default. ### Build and sign Bitcoin Core for Linux, Windows, and OS X: pushd ./gitian-builder - ./bin/gbuild --memory 3000 --commit bitcoin=v${VERSION} ../bitcoin/contrib/gitian-descriptors/gitian-linux.yml + ./bin/gbuild --num-make 2 --memory 3000 --commit bitcoin=v${VERSION} ../bitcoin/contrib/gitian-descriptors/gitian-linux.yml ./bin/gsign --signer $SIGNER --release ${VERSION}-linux --destination ../gitian.sigs/ ../bitcoin/contrib/gitian-descriptors/gitian-linux.yml mv build/out/bitcoin-*.tar.gz build/out/src/bitcoin-*.tar.gz ../ - ./bin/gbuild --memory 3000 --commit bitcoin=v${VERSION} ../bitcoin/contrib/gitian-descriptors/gitian-win.yml + ./bin/gbuild --num-make 2 --memory 3000 --commit bitcoin=v${VERSION} ../bitcoin/contrib/gitian-descriptors/gitian-win.yml ./bin/gsign --signer $SIGNER --release ${VERSION}-win-unsigned --destination ../gitian.sigs/ ../bitcoin/contrib/gitian-descriptors/gitian-win.yml mv build/out/bitcoin-*-win-unsigned.tar.gz inputs/bitcoin-win-unsigned.tar.gz mv build/out/bitcoin-*.zip build/out/bitcoin-*.exe ../ - ./bin/gbuild --memory 3000 --commit bitcoin=v${VERSION} ../bitcoin/contrib/gitian-descriptors/gitian-osx.yml + ./bin/gbuild --num-make 2 --memory 3000 --commit bitcoin=v${VERSION} ../bitcoin/contrib/gitian-descriptors/gitian-osx.yml ./bin/gsign --signer $SIGNER --release ${VERSION}-osx-unsigned --destination ../gitian.sigs/ ../bitcoin/contrib/gitian-descriptors/gitian-osx.yml mv build/out/bitcoin-*-osx-unsigned.tar.gz inputs/bitcoin-osx-unsigned.tar.gz mv build/out/bitcoin-*.tar.gz build/out/bitcoin-*.dmg ../ diff --git a/src/bench/bench.cpp b/src/bench/bench.cpp index ac14444eef..849d924af2 100644 --- a/src/bench/bench.cpp +++ b/src/bench/bench.cpp @@ -100,6 +100,7 @@ bool benchmark::State::KeepRunning() int64_t averageCycles = (nowCycles-beginCycles)/count; std::cout << std::fixed << std::setprecision(15) << name << "," << count << "," << minTime << "," << maxTime << "," << average << "," << minCycles << "," << maxCycles << "," << averageCycles << "\n"; + std::cout.copyfmt(std::ios(nullptr)); return false; } diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index a36944952e..eaef7a903b 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -176,9 +176,7 @@ bool AppInit(int argc, char* argv[]) if (!fRet) { Interrupt(threadGroup); - // threadGroup.join_all(); was left out intentionally here, because we didn't re-test all of - // the startup-failure cases to make sure they don't result in a hang due to some - // thread-blocking-waiting-for-another-thread-during-startup case + threadGroup.join_all(); } else { WaitForShutdown(&threadGroup); } diff --git a/src/core_io.h b/src/core_io.h index 2d63be5fc4..3f25faf0ec 100644 --- a/src/core_io.h +++ b/src/core_io.h @@ -5,6 +5,8 @@ #ifndef BITCOIN_CORE_IO_H #define BITCOIN_CORE_IO_H +#include "amount.h" + #include <string> #include <vector> @@ -25,6 +27,7 @@ uint256 ParseHashStr(const std::string&, const std::string& strName); std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName); // core_write.cpp +UniValue ValueFromAmount(const CAmount& amount); std::string FormatScript(const CScript& script); std::string EncodeHexTx(const CTransaction& tx, const int serializeFlags = 0); void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex); diff --git a/src/core_write.cpp b/src/core_write.cpp index 0a7b1694ce..0eae4703ab 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -16,6 +16,16 @@ #include "utilmoneystr.h" #include "utilstrencodings.h" +UniValue ValueFromAmount(const CAmount& amount) +{ + bool sign = amount < 0; + int64_t n_abs = (sign ? -amount : amount); + int64_t quotient = n_abs / COIN; + int64_t remainder = n_abs % COIN; + return UniValue(UniValue::VNUM, + strprintf("%s%d.%08d", sign ? "-" : "", quotient, remainder)); +} + std::string FormatScript(const CScript& script) { std::string ret; @@ -184,8 +194,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry) UniValue out(UniValue::VOBJ); - UniValue outValue(UniValue::VNUM, FormatMoney(txout.nValue)); - out.pushKV("value", outValue); + out.pushKV("value", ValueFromAmount(txout.nValue)); out.pushKV("n", (int64_t)i); UniValue o(UniValue::VOBJ); diff --git a/src/init.cpp b/src/init.cpp index 7a37b8d800..cddb42c0ee 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1400,9 +1400,9 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) delete pcoinscatcher; delete pblocktree; - pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReindex); + pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReset); - if (fReindex) { + if (fReset) { pblocktree->WriteReindexing(true); //If we're reindexing in prune mode, wipe away unusable block files and all undo data files if (fPruneMode) @@ -1414,6 +1414,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) // LoadBlockIndex will load fTxIndex from the db, or set it if // we're reindexing. It will also load fHavePruned if we've // ever removed a block file from disk. + // Note that it also sets fReindex based on the disk flag! + // From here on out fReindex and fReset mean something different! if (!LoadBlockIndex(chainparams)) { strLoadError = _("Error loading block database"); break; @@ -1438,8 +1440,9 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) } // At this point blocktree args are consistent with what's on disk. - // If we're not mid-reindex (based on disk + args), add a genesis block on disk. - // This is called again in ThreadImport in the reindex completes. + // If we're not mid-reindex (based on disk + args), add a genesis block on disk + // (otherwise we use the one already on disk). + // This is called again in ThreadImport after the reindex completes. if (!fReindex && !LoadGenesisBlock(chainparams)) { strLoadError = _("Error initializing block database"); break; @@ -1448,7 +1451,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) // At this point we're either in reindex or we've loaded a useful // block tree into mapBlockIndex! - pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReindex || fReindexChainState); + pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReset || fReindexChainState); pcoinscatcher = new CCoinsViewErrorCatcher(pcoinsdbview); // If necessary, upgrade from older database format. @@ -1467,7 +1470,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) // The on-disk coinsdb is now in a good state, create the cache pcoinsTip = new CCoinsViewCache(pcoinscatcher); - if (!fReindex && !fReindexChainState) { + bool is_coinsview_empty = fReset || fReindexChainState || pcoinsTip->GetBestBlock().IsNull(); + if (!is_coinsview_empty) { // LoadChainTip sets chainActive based on pcoinsTip's best block if (!LoadChainTip(chainparams)) { strLoadError = _("Error initializing block database"); @@ -1476,7 +1480,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) assert(chainActive.Tip() != nullptr); } - if (!fReindex) { + if (!fReset) { // Note that RewindBlockIndex MUST run even if we're about to -reindex-chainstate. // It both disconnects blocks based on chainActive, and drops block data in // mapBlockIndex based on lack of available witness data. @@ -1487,7 +1491,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) } } - if (!fReindex && !fReindexChainState) { + if (!is_coinsview_empty) { uiInterface.InitMessage(_("Verifying blocks...")); if (fHavePruned && GetArg("-checkblocks", DEFAULT_CHECKBLOCKS) > MIN_BLOCKS_TO_KEEP) { LogPrintf("Prune: pruned datadir may not have more than %d blocks; only checking available blocks", diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 2e14d01f08..766618130c 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1260,6 +1260,17 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr return false; } + if (nServices & ((1 << 7) | (1 << 5))) { + if (GetTime() < 1533096000) { + // Immediately disconnect peers that use service bits 6 or 8 until August 1st, 2018 + // These bits have been used as a flag to indicate that a node is running incompatible + // consensus rules instead of changing the network magic, so we're stuck disconnecting + // based on these service bits, at least for a while. + pfrom->fDisconnect = true; + return false; + } + } + if (nVersion < MIN_PEER_PROTO_VERSION) { // disconnect from peers older than this proto version @@ -2134,9 +2145,12 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr } bool fNewBlock = false; ProcessNewBlock(chainparams, pblock, true, &fNewBlock); - if (fNewBlock) + if (fNewBlock) { pfrom->nLastBlockTime = GetTime(); - + } else { + LOCK(cs_main); + mapBlockSource.erase(pblock->GetHash()); + } LOCK(cs_main); // hold cs_main for CBlockIndex::IsValid() if (pindex->IsValid(BLOCK_VALID_TRANSACTIONS)) { // Clear download state for this block, which is in @@ -2211,8 +2225,12 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr // Since we requested this block (it was in mapBlocksInFlight), force it to be processed, // even if it would not be a candidate for new tip (missing previous block, chain not long enough, etc) ProcessNewBlock(chainparams, pblock, true, &fNewBlock); - if (fNewBlock) + if (fNewBlock) { pfrom->nLastBlockTime = GetTime(); + } else { + LOCK(cs_main); + mapBlockSource.erase(pblock->GetHash()); + } } } @@ -2390,8 +2408,12 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr } bool fNewBlock = false; ProcessNewBlock(chainparams, pblock, forceProcessing, &fNewBlock); - if (fNewBlock) + if (fNewBlock) { pfrom->nLastBlockTime = GetTime(); + } else { + LOCK(cs_main); + mapBlockSource.erase(pblock->GetHash()); + } } diff --git a/src/qt/locale/bitcoin_es_MX.ts b/src/qt/locale/bitcoin_es_MX.ts index bf8f0ceb88..ffa80a10bd 100644 --- a/src/qt/locale/bitcoin_es_MX.ts +++ b/src/qt/locale/bitcoin_es_MX.ts @@ -3,7 +3,7 @@ <name>AddressBookPage</name> <message> <source>Right-click to edit address or label</source> - <translation>Click derecho para editar tu dirección o etiqueta</translation> + <translation>Click derecho para editar dirección o etiqueta</translation> </message> <message> <source>Create a new address</source> @@ -31,7 +31,7 @@ </message> <message> <source>Export the data in the current tab to a file</source> - <translation>Exportar la información en la tabla actual a un archivo</translation> + <translation>Exportar la información en la pestaña actual a un archivo</translation> </message> <message> <source>&Export</source> @@ -596,6 +596,10 @@ </context> <context> <name>WalletView</name> + <message> + <source>Export the data in the current tab to a file</source> + <translation>Exportar la información en la pestaña actual a un archivo</translation> + </message> </context> <context> <name>bitcoin-core</name> diff --git a/src/qt/locale/bitcoin_fi.ts b/src/qt/locale/bitcoin_fi.ts index 38f0e1444c..d13a5639e5 100644 --- a/src/qt/locale/bitcoin_fi.ts +++ b/src/qt/locale/bitcoin_fi.ts @@ -66,6 +66,10 @@ <translation>Nämä ovat Bitcoin-osoitteesi maksujen lähettämistä varten. Tarkista aina määrä ja vastaanotto-osoite ennen kolikoiden lähettämistä.</translation> </message> <message> + <source>These are your Bitcoin addresses for receiving payments. It is recommended to use a new receiving address for each transaction.</source> + <translation>Tässä ovat Bitcoin vastaanotto-osoitteesi. On suositeltavaa käyttää uutta vastaanotto-osoitetta jokaista lähetystä varten.</translation> + </message> + <message> <source>&Copy Address</source> <translation>&Kopioi osoite</translation> </message> @@ -82,10 +86,18 @@ <translation>Vie osoitelista</translation> </message> <message> + <source>Comma separated file (*.csv)</source> + <translation>Pilkuilla erotettu tiedosto (*.csv)</translation> + </message> + <message> <source>Exporting Failed</source> <translation>Vienti epäonnistui</translation> </message> - </context> + <message> + <source>There was an error trying to save the address list to %1. Please try again.</source> + <translation>Virhe tallentaessa osoitelistaa kohteeseen %1. Yritä uudelleen.</translation> + </message> +</context> <context> <name>AddressTableModel</name> <message> @@ -120,14 +132,26 @@ <translation>Toista uusi tunnuslause</translation> </message> <message> + <source>Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>ten or more random characters</b>, or <b>eight or more words</b>.</source> + <translation>Kirjoita uusi salauslause lompakolle.<br/>Käytä salauslausetta jossa on joko<b>kymmenen tai useampi satunnainen merkki</b>, tai<b>vähintään kahdeksan sanaa</b></translation> + </message> + <message> <source>Encrypt wallet</source> <translation>Salaa lompakko</translation> </message> <message> + <source>This operation needs your wallet passphrase to unlock the wallet.</source> + <translation>Tämä toiminto vaatii lompakkosi tunnuslauseen sen avaamiseksi</translation> + </message> + <message> <source>Unlock wallet</source> <translation>Avaa lompakko</translation> </message> <message> + <source>This operation needs your wallet passphrase to decrypt the wallet.</source> + <translation>Tämä toiminto vaatii lompakkosia tunnuslauseen salauksen purkuun</translation> + </message> + <message> <source>Decrypt wallet</source> <translation>Pura lompakon salaus</translation> </message> @@ -136,10 +160,18 @@ <translation>Vaihda salasana</translation> </message> <message> + <source>Enter the old passphrase and new passphrase to the wallet.</source> + <translation>Syötä vanha ja uusi tunnuslause lompakolle.</translation> + </message> + <message> <source>Confirm wallet encryption</source> <translation>Vahvista lompakon salaaminen</translation> </message> <message> + <source>Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR BITCOINS</b>!</source> + <translation>Varoitus: Jos salaat lompakkosi ja menetät tunnuslauseesi, <b>MENETÄT KAIKKI BITCOINISI</b>!</translation> + </message> + <message> <source>Are you sure you wish to encrypt your wallet?</source> <translation>Oletko varma, että haluat salata lompakkosi?</translation> </message> @@ -148,14 +180,34 @@ <translation>Lompakko salattiin</translation> </message> <message> + <source>%1 will close now to finish the encryption process. Remember that encrypting your wallet cannot fully protect your bitcoins from being stolen by malware infecting your computer.</source> + <translation>%1 sulkeutuu lopettaakseen salausprosessin. Muista, että salattukaan lompakko ei täysin suojaa sitä haittaohjelmien aiheuttamilta varkauksilta.</translation> + </message> + <message> + <source>IMPORTANT: Any previous backups you have made of your wallet file should be replaced with the newly generated, encrypted wallet file. For security reasons, previous backups of the unencrypted wallet file will become useless as soon as you start using the new, encrypted wallet.</source> + <translation>TÄRKEÄÄ: Kaikki tekemäsi vanhan lompakon varmuuskopiot pitäisi korvata uusilla suojatuilla varmuuskopioilla. Turvallisuussyistä edelliset varmuuskopiot muuttuvat turhiksi, kun aloitat uuden suojatun lompakon käytön.</translation> + </message> + <message> <source>Wallet encryption failed</source> <translation>Lompakon salaus epäonnistui</translation> </message> <message> + <source>Wallet encryption failed due to an internal error. Your wallet was not encrypted.</source> + <translation>Lompakon salaaminen epäonnistui sisäisen virheen vuoksi. Lompakkoasi ei salattu.</translation> + </message> + <message> + <source>The supplied passphrases do not match.</source> + <translation>Annetut salauslauseet eivät täsmää.</translation> + </message> + <message> <source>Wallet unlock failed</source> <translation>Lompakon lukituksen avaaminen epäonnistui</translation> </message> <message> + <source>The passphrase entered for the wallet decryption was incorrect.</source> + <translation>Annettu salauslause lompakon avaamiseksi oli väärä.</translation> + </message> + <message> <source>Wallet decryption failed</source> <translation>Lompakon salauksen purkaminen epäonnistui</translation> </message> @@ -278,6 +330,10 @@ <translation>Paina ottaaksesi verkkoyhteysilmaisin uudelleen käyttöön.</translation> </message> <message> + <source>Syncing Headers (%1%)...</source> + <translation>Synkronoidaan Tunnisteita (%1%)...</translation> + </message> + <message> <source>Reindexing blocks on disk...</source> <translation>Ladataan lohkoindeksiä...</translation> </message> @@ -476,6 +532,14 @@ <translation>Saapuva rahansiirto</translation> </message> <message> + <source>HD key generation is <b>enabled</b></source> + <translation>HD avaimen generointi on <b>päällä</b></translation> + </message> + <message> + <source>HD key generation is <b>disabled</b></source> + <translation>HD avaimen generointi on </b>pois päältä</b></translation> + </message> + <message> <source>Wallet is <b>encrypted</b> and currently <b>unlocked</b></source> <translation>Lompakko on <b>salattu</b> ja tällä hetkellä <b>avoinna</b></translation> </message> @@ -483,7 +547,11 @@ <source>Wallet is <b>encrypted</b> and currently <b>locked</b></source> <translation>Lompakko on <b>salattu</b> ja tällä hetkellä <b>lukittuna</b></translation> </message> - </context> + <message> + <source>A fatal error occurred. Bitcoin can no longer continue safely and will quit.</source> + <translation>Peruuttamaton virhe on tapahtunut. Bitcoin ei voi enää jatkaa turvallisesti ja sammutetaan.</translation> + </message> +</context> <context> <name>CoinControlDialog</name> <message> @@ -615,6 +683,10 @@ <translation>ei</translation> </message> <message> + <source>Can vary +/- %1 satoshi(s) per input.</source> + <translation>Saattaa vaihdella +/- %1 satoshia per syöte.</translation> + </message> + <message> <source>(no label)</source> <translation>(ei nimikettä)</translation> </message> @@ -654,6 +726,26 @@ <translation>Uusi lähetysosoite</translation> </message> <message> + <source>Edit receiving address</source> + <translation>Muokkaa vastaanottavaa osoitetta</translation> + </message> + <message> + <source>Edit sending address</source> + <translation>Muokkaa lähettävää osoitetta</translation> + </message> + <message> + <source>The entered address "%1" is not a valid Bitcoin address.</source> + <translation>Antamasi osoite "%1" ei ole kelvollinen Bitcoin-osoite.</translation> + </message> + <message> + <source>The entered address "%1" is already in the address book.</source> + <translation>Antamasi osoite "%1" on jo osoitekirjassa</translation> + </message> + <message> + <source>Could not unlock wallet.</source> + <translation>Lompakkoa ei voitu avata.</translation> + </message> + <message> <source>New key generation failed.</source> <translation>Uuden avaimen luonti epäonnistui.</translation> </message> @@ -1206,10 +1298,22 @@ <context> <name>QRImageWidget</name> <message> + <source>&Save Image...</source> + <translation>&Tallenna kuva</translation> + </message> + <message> + <source>&Copy Image</source> + <translation>&Kopioi kuva</translation> + </message> + <message> <source>Save QR Code</source> <translation>Tallenna QR-koodi</translation> </message> - </context> + <message> + <source>PNG Image (*.png)</source> + <translation>PNG kuva (*.png)</translation> + </message> +</context> <context> <name>RPCConsole</name> <message> @@ -1568,6 +1672,10 @@ <translation>Kopioi nimike</translation> </message> <message> + <source>Copy message</source> + <translation>Kopioi viesti</translation> + </message> + <message> <source>Copy amount</source> <translation>Kopioi määrä</translation> </message> @@ -1591,6 +1699,10 @@ <translation>&Tallenna kuva</translation> </message> <message> + <source>Payment information</source> + <translation>Maksutiedot</translation> + </message> + <message> <source>Address</source> <translation>Osoite</translation> </message> @@ -1793,6 +1905,10 @@ <translation>Kopioi vaihtorahat</translation> </message> <message> + <source>Total Amount %1</source> + <translation>Kokonaismäärä %1</translation> + </message> + <message> <source>or</source> <translation>tai</translation> </message> @@ -1882,7 +1998,11 @@ </context> <context> <name>SendConfirmationDialog</name> - </context> + <message> + <source>Yes</source> + <translation>Kyllä</translation> + </message> +</context> <context> <name>ShutdownWindow</name> <message> @@ -1972,7 +2092,11 @@ <source>Reset all verify message fields</source> <translation>Tyhjennä kaikki varmista-viesti-kentät</translation> </message> - </context> + <message> + <source>Message verified.</source> + <translation>Viesti varmistettu.</translation> + </message> +</context> <context> <name>SplashScreen</name> <message> @@ -1990,14 +2114,50 @@ <context> <name>TransactionDesc</name> <message> + <source>%1/unconfirmed</source> + <translation>%1/vahvistamaton</translation> + </message> + <message> + <source>%1 confirmations</source> + <translation>%1 vahvistusta</translation> + </message> + <message> <source>Date</source> <translation>Aika</translation> </message> <message> + <source>Source</source> + <translation>Lähde</translation> + </message> + <message> + <source>Generated</source> + <translation>Generoitu</translation> + </message> + <message> + <source>From</source> + <translation>Lähettäjä</translation> + </message> + <message> + <source>unknown</source> + <translation>tuntematon</translation> + </message> + <message> + <source>To</source> + <translation>Saaja</translation> + </message> + <message> + <source>own address</source> + <translation>oma osoite</translation> + </message> + <message> <source>Message</source> <translation>Viesti</translation> </message> <message> + <source>Comment</source> + <translation>Kommentti</translation> + </message> + <message> <source>Amount</source> <translation>Määrä</translation> </message> @@ -2016,10 +2176,30 @@ <translation>Aika</translation> </message> <message> + <source>Type</source> + <translation>Tyyppi</translation> + </message> + <message> <source>Label</source> <translation>Nimike</translation> </message> <message> + <source>Received with</source> + <translation>Vastaanotettu osoitteella</translation> + </message> + <message> + <source>Sent to</source> + <translation>Lähetetty vastaanottajalle</translation> + </message> + <message> + <source>Payment to yourself</source> + <translation>Maksu itsellesi</translation> + </message> + <message> + <source>Mined</source> + <translation>Louhittu</translation> + </message> + <message> <source>(no label)</source> <translation>(ei nimikettä)</translation> </message> @@ -2027,6 +2207,50 @@ <context> <name>TransactionView</name> <message> + <source>All</source> + <translation>Kaikki</translation> + </message> + <message> + <source>Today</source> + <translation>Tänään</translation> + </message> + <message> + <source>This week</source> + <translation>Tällä viikolla</translation> + </message> + <message> + <source>This month</source> + <translation>Tässä kuussa</translation> + </message> + <message> + <source>Last month</source> + <translation>Viime kuussa</translation> + </message> + <message> + <source>This year</source> + <translation>Tänä vuonna</translation> + </message> + <message> + <source>Received with</source> + <translation>Vastaanotettu osoitteella</translation> + </message> + <message> + <source>Sent to</source> + <translation>Lähetetty vastaanottajalle</translation> + </message> + <message> + <source>To yourself</source> + <translation>Itsellesi</translation> + </message> + <message> + <source>Mined</source> + <translation>Louhittu</translation> + </message> + <message> + <source>Min amount</source> + <translation>Minimimäärä</translation> + </message> + <message> <source>Copy address</source> <translation>Kopioi osoite</translation> </message> @@ -2043,10 +2267,34 @@ <translation>Kopioi transaktion ID</translation> </message> <message> + <source>Edit label</source> + <translation>Muokkaa nimeä</translation> + </message> + <message> + <source>Show transaction details</source> + <translation>Näytä rahansiirron yksityiskohdat</translation> + </message> + <message> + <source>Export Transaction History</source> + <translation>Vie rahansiirtohistoria</translation> + </message> + <message> + <source>Comma separated file (*.csv)</source> + <translation>Pilkuilla erotettu tiedosto (*.csv)</translation> + </message> + <message> + <source>Confirmed</source> + <translation>Vahvistettu</translation> + </message> + <message> <source>Date</source> <translation>Aika</translation> </message> <message> + <source>Type</source> + <translation>Tyyppi</translation> + </message> + <message> <source>Label</source> <translation>Nimike</translation> </message> @@ -2055,10 +2303,26 @@ <translation>Osoite</translation> </message> <message> + <source>ID</source> + <translation>ID</translation> + </message> + <message> <source>Exporting Failed</source> <translation>Vienti epäonnistui</translation> </message> - </context> + <message> + <source>There was an error trying to save the transaction history to %1.</source> + <translation>Rahansiirron historian tallentamisessa tapahtui virhe paikkaan %1.</translation> + </message> + <message> + <source>Exporting Successful</source> + <translation>Vienti onnistui</translation> + </message> + <message> + <source>to</source> + <translation>vastaanottaja</translation> + </message> +</context> <context> <name>UnitDisplayStatusBarControl</name> <message> @@ -2068,16 +2332,44 @@ </context> <context> <name>WalletFrame</name> - </context> + <message> + <source>No wallet has been loaded.</source> + <translation>Lomakkoa ei ole ladattu.</translation> + </message> +</context> <context> <name>WalletModel</name> - </context> + <message> + <source>Send Coins</source> + <translation>Lähetä kolikoita</translation> + </message> +</context> <context> <name>WalletView</name> <message> <source>&Export</source> <translation>&Vie</translation> </message> + <message> + <source>Export the data in the current tab to a file</source> + <translation>Vie auki olevan välilehden tiedot tiedostoon</translation> + </message> + <message> + <source>Backup Wallet</source> + <translation>Varmuuskopioi lompakko</translation> + </message> + <message> + <source>Wallet Data (*.dat)</source> + <translation>Lompakkodata (*.dat)</translation> + </message> + <message> + <source>Backup Failed</source> + <translation>Varmuuskopio epäonnistui</translation> + </message> + <message> + <source>Backup Successful</source> + <translation>Varmuuskopio Onnistui</translation> + </message> </context> <context> <name>bitcoin-core</name> @@ -2318,6 +2610,10 @@ <translation>Karsittu tila ei ole yhteensopiva -txindex:n kanssa.</translation> </message> <message> + <source>Rewinding blocks...</source> + <translation>Varmistetaan lohkoja...</translation> + </message> + <message> <source>Set database cache size in megabytes (%d to %d, default: %d)</source> <translation>Aseta tietokannan välimuistin koko megatavuissa (%d - %d, oletus: %d</translation> </message> @@ -2554,6 +2850,10 @@ <translation>Käytä erillistä SOCKS5-proxyä tavoittaaksesi vertaisia Tor-piilopalveluiden kautta (oletus: %s)</translation> </message> <message> + <source>%s is set very high!</source> + <translation>%s on asetettu todella korkeaksi!</translation> + </message> + <message> <source>(default: %s)</source> <translation>(oletus: %s)</translation> </message> @@ -2638,10 +2938,26 @@ <translation>Käytä vahvistamattomia vaihtorahoja lähetettäessä rahansiirtoja (oletus: %u)</translation> </message> <message> + <source>Starting network threads...</source> + <translation>Käynnistetään verkkoa...</translation> + </message> + <message> + <source>This is the transaction fee you will pay if you send a transaction.</source> + <translation>Tämä on lähetyksestä maksettava maksu jonka maksat</translation> + </message> + <message> <source>Threshold for disconnecting misbehaving peers (default: %u)</source> <translation>Aikaväli sopimattomien vertaisten yhteyksien katkaisuun (oletus: %u)</translation> </message> <message> + <source>Transaction amounts must not be negative</source> + <translation>Lähetyksen siirtosumman tulee olla positiivinen</translation> + </message> + <message> + <source>Transaction must have at least one recipient</source> + <translation>Lähetyksessä tulee olla ainakin yksi vastaanottaja</translation> + </message> + <message> <source>Unknown network specified in -onlynet: '%s'</source> <translation>Tuntematon verkko -onlynet parametrina: '%s'</translation> </message> diff --git a/src/qt/locale/bitcoin_ka.ts b/src/qt/locale/bitcoin_ka.ts index 5aa9137753..c51a611b3c 100644 --- a/src/qt/locale/bitcoin_ka.ts +++ b/src/qt/locale/bitcoin_ka.ts @@ -2,6 +2,10 @@ <context> <name>AddressBookPage</name> <message> + <source>Right-click to edit address or label</source> + <translation>დააჭირეთ მარჯვენა ღილაკს მისამართის ან იარლიყის ჩასასწორებლად</translation> + </message> + <message> <source>Create a new address</source> <translation>ახალი მისამართის შექმნა</translation> </message> @@ -38,6 +42,10 @@ <translation>&წაშლა</translation> </message> <message> + <source>C&hoose</source> + <translation>&არჩევა</translation> + </message> + <message> <source>Sending addresses</source> <translation>გამმგზავნი მისამართ</translation> </message> @@ -45,9 +53,17 @@ <source>Receiving addresses</source> <translation>მიმღები მისამართი</translation> </message> + <message> + <source>&Edit</source> + <translation>&რედაქტირება</translation> + </message> </context> <context> <name>AddressTableModel</name> + <message> + <source>Address</source> + <translation>მისამართი</translation> + </message> </context> <context> <name>AskPassphraseDialog</name> @@ -67,6 +83,22 @@ <source>Repeat new passphrase</source> <translation>გაიმეორეთ ახალი ფრაზა-პაროლი</translation> </message> + <message> + <source>Encrypt wallet</source> + <translation>საფულის დაშიფრვა</translation> + </message> + <message> + <source>Unlock wallet</source> + <translation>საფულის განბლოკვა</translation> + </message> + <message> + <source>Decrypt wallet</source> + <translation>საფულის განბლოკვა</translation> + </message> + <message> + <source>Change passphrase</source> + <translation>პაროლის შეცვლა</translation> + </message> </context> <context> <name>BanTableModel</name> @@ -110,6 +142,14 @@ <translation>გასვლა</translation> </message> <message> + <source>&About %1</source> + <translation>%1-ის &შესახებ</translation> + </message> + <message> + <source>Show information about %1</source> + <translation>%1-ის შესახებ ინფორმაციის ჩვენება</translation> + </message> + <message> <source>About &Qt</source> <translation>&Qt-ს შესახებ</translation> </message> @@ -274,8 +314,36 @@ <translation>განახლებულია</translation> </message> <message> + <source>%1 client</source> + <translation>%1 კლიენტი</translation> + </message> + <message> <source>Catching up...</source> - <translation>ჩართვა...</translation> + <translation>მიმდინარეობს განახლება...</translation> + </message> + <message> + <source>Date: %1 +</source> + <translation>თარიღი: %1 +</translation> + </message> + <message> + <source>Amount: %1 +</source> + <translation>რაოდენობა: %1 +</translation> + </message> + <message> + <source>Type: %1 +</source> + <translation>ტიპი: %1 +</translation> + </message> + <message> + <source>Address: %1 +</source> + <translation>მისამართი: %1 +</translation> </message> <message> <source>Sent transaction</source> @@ -313,6 +381,10 @@ <translation>საკომისიო:</translation> </message> <message> + <source>Dust:</source> + <translation>მტვერი:</translation> + </message> + <message> <source>After Fee:</source> <translation>დამატებითი საკომისიო:</translation> </message> @@ -348,7 +420,19 @@ <source>Confirmed</source> <translation>დადასტურებულია</translation> </message> - </context> + <message> + <source>yes</source> + <translation>დიახ</translation> + </message> + <message> + <source>no</source> + <translation>არა</translation> + </message> + <message> + <source>(change)</source> + <translation>(ხურდა)</translation> + </message> +</context> <context> <name>EditAddressDialog</name> <message> @@ -402,6 +486,14 @@ <translation>ვერსია</translation> </message> <message> + <source>(%1-bit)</source> + <translation>(%1-ბიტი)</translation> + </message> + <message> + <source>About %1</source> + <translation>%1-ის შესახებ</translation> + </message> + <message> <source>Command-line options</source> <translation>კომანდების ზოლის ოპციები</translation> </message> @@ -413,6 +505,10 @@ <source>command-line options</source> <translation>კომანდების ზოლის ოპციები</translation> </message> + <message> + <source>UI Options:</source> + <translation>მომხმარებლის ინტერფეისის ოპციები:</translation> + </message> </context> <context> <name>Intro</name> @@ -421,6 +517,10 @@ <translation>მოგესალმებით</translation> </message> <message> + <source>Welcome to %1.</source> + <translation>კეთილი იყოს თქვენი მობრძანება %1-ში.</translation> + </message> + <message> <source>Use the default data directory</source> <translation>ნაგულისხმევი კატალოგის გამოყენება</translation> </message> @@ -432,7 +532,15 @@ <source>Error</source> <translation>შეცდომა</translation> </message> - </context> + <message numerus="yes"> + <source>%n GB of free space available</source> + <translation><numerusform>ხელმისაწვდომია თავისუფალი სივრცის %n გბ</numerusform></translation> + </message> + <message numerus="yes"> + <source>(of %n GB needed)</source> + <translation><numerusform>(საჭირო %n გბ-დან)</numerusform></translation> + </message> +</context> <context> <name>ModalOverlay</name> <message> @@ -440,9 +548,25 @@ <translation>ფორმა</translation> </message> <message> + <source>Unknown...</source> + <translation>უცნობი...</translation> + </message> + <message> <source>Last block time</source> <translation>ბოლო ბლოკის დრო</translation> </message> + <message> + <source>Progress</source> + <translation>პროგრესი</translation> + </message> + <message> + <source>calculating...</source> + <translation>მიმდინარეობს გამოთვლა...</translation> + </message> + <message> + <source>Hide</source> + <translation>დამალვა</translation> + </message> </context> <context> <name>OpenURIDialog</name> @@ -510,6 +634,10 @@ <translation>ს&აფულე</translation> </message> <message> + <source>Expert</source> + <translation>ექსპერტი</translation> + </message> + <message> <source>If you disable the spending of unconfirmed change, the change from a transaction cannot be used until that transaction has at least one confirmation. This also affects how your balance is computed.</source> <translation>დაუდასტურებელი ხურდის გამოყენების აკრძალვის შემდეგ მათი გამოყენება შეუძლებელი იქნება, სანამ ტრანსაქციას არ ექნება ერთი დასტური მაინც. ეს აისახება თქვენი ნაშთის დათვლაზეც.</translation> </message> @@ -534,6 +662,18 @@ <translation>პროქსის პორტი (მაგ.: 9050)</translation> </message> <message> + <source>IPv4</source> + <translation>IPv4</translation> + </message> + <message> + <source>IPv6</source> + <translation>IPv6</translation> + </message> + <message> + <source>Tor</source> + <translation>Tor</translation> + </message> + <message> <source>&Window</source> <translation>&ფანჯარა</translation> </message> @@ -880,6 +1020,10 @@ <source>&Save Image...</source> <translation>გამო&სახულების შენახვა...</translation> </message> + <message> + <source>Address</source> + <translation>მისამართი</translation> + </message> </context> <context> <name>RecentRequestsTableModel</name> @@ -943,6 +1087,10 @@ <translation>ტრანსაქციის საფასური - საკომისიო:</translation> </message> <message> + <source>Hide</source> + <translation>დამალვა</translation> + </message> + <message> <source>Send to multiple recipients at once</source> <translation>გაგზავნა რამდენიმე რეციპიენტთან ერთდროულად</translation> </message> @@ -955,6 +1103,10 @@ <translation>ფორმის ყველა ველის წაშლა</translation> </message> <message> + <source>Dust:</source> + <translation>მტვერი:</translation> + </message> + <message> <source>Clear &All</source> <translation>გ&ასუფთავება</translation> </message> @@ -1140,6 +1292,10 @@ </context> <context> <name>TransactionView</name> + <message> + <source>Address</source> + <translation>მისამართი</translation> + </message> </context> <context> <name>UnitDisplayStatusBarControl</name> diff --git a/src/qt/locale/bitcoin_ru_RU.ts b/src/qt/locale/bitcoin_ru_RU.ts index 66ab7c81f4..0cb0e7f6e4 100644 --- a/src/qt/locale/bitcoin_ru_RU.ts +++ b/src/qt/locale/bitcoin_ru_RU.ts @@ -49,16 +49,104 @@ <source>Choose the address to receive coins with</source> <translation>Выбрать адрес для получения монет</translation> </message> + <message> + <source>C&hoose</source> + <translation>В&ыбрать</translation> + </message> + <message> + <source>Sending addresses</source> + <translation>Адреса отправки</translation> + </message> + <message> + <source>Receiving addresses</source> + <translation>Адреса получения</translation> + </message> + <message> + <source>&Copy Address</source> + <translation>&Копировать адрес</translation> + </message> + <message> + <source>Copy &Label</source> + <translation>Копировать &метку</translation> + </message> + <message> + <source>&Edit</source> + <translation>&Редактировать</translation> + </message> + <message> + <source>Export Address List</source> + <translation>Экспортировать список адресов</translation> + </message> + <message> + <source>Exporting Failed</source> + <translation>Экспорт не удался</translation> + </message> </context> <context> <name>AddressTableModel</name> - </context> + <message> + <source>Label</source> + <translation>Метка</translation> + </message> + <message> + <source>Address</source> + <translation>Адрес</translation> + </message> + <message> + <source>(no label)</source> + <translation>(нет метки)</translation> + </message> +</context> <context> <name>AskPassphraseDialog</name> <message> + <source>Passphrase Dialog</source> + <translation>Ввод пароля</translation> + </message> + <message> + <source>Enter passphrase</source> + <translation>Введите пароль</translation> + </message> + <message> + <source>New passphrase</source> + <translation>Новый пароль</translation> + </message> + <message> <source>Repeat new passphrase</source> <translation>Повторите новый пароль</translation> </message> + <message> + <source>Encrypt wallet</source> + <translation>Зашифровать бумажник</translation> + </message> + <message> + <source>This operation needs your wallet passphrase to unlock the wallet.</source> + <translation>Эта операция требует вашего пароля для разблокировки бумажника</translation> + </message> + <message> + <source>Unlock wallet</source> + <translation>Разблокировать бумажник</translation> + </message> + <message> + <source>Decrypt wallet</source> + <translation>Расшифровать бумажник</translation> + </message> + <message> + <source>Change passphrase</source> + <translation>Изменить пароль</translation> + </message> + <message> + <source>Confirm wallet encryption</source> + <translation>Подтвердите шифрование бумажника</translation> + </message> + <message> + <source>Wallet encrypted</source> + <translation>Бумажник зашифрован</translation> + </message> + <message> + <source>Wallet unlock failed</source> + <translation>Ошибка разблокировки кошелька</translation> + </message> </context> <context> <name>BanTableModel</name> @@ -66,10 +154,114 @@ <context> <name>BitcoinGUI</name> <message> + <source>Sign &message...</source> + <translation>Подписать &сообщение...</translation> + </message> + <message> + <source>&Transactions</source> + <translation>&Транзакции</translation> + </message> + <message> + <source>Browse transaction history</source> + <translation>Просмотр истории транзакций</translation> + </message> + <message> + <source>E&xit</source> + <translation>В&ыход</translation> + </message> + <message> + <source>Quit application</source> + <translation>Выйти</translation> + </message> + <message> + <source>&About %1</source> + <translation>&О программе %1</translation> + </message> + <message> + <source>Show information about %1</source> + <translation>Показать информацию о %1</translation> + </message> + <message> + <source>About &Qt</source> + <translation>О библиотеке &Qt</translation> + </message> + <message> + <source>Show information about Qt</source> + <translation>Показать информацию о библиотеке Qt</translation> + </message> + <message> + <source>&Options...</source> + <translation>&Опции...</translation> + </message> + <message> + <source>&Encrypt Wallet...</source> + <translation>&Зашифровать кошелёк</translation> + </message> + <message> + <source>&Backup Wallet...</source> + <translation>&Создать резервную копию бумажника</translation> + </message> + <message> + <source>&Change Passphrase...</source> + <translation>&Изменить пароль...</translation> + </message> + <message> + <source>&Sending addresses...</source> + <translation>&Адреса для отправки...</translation> + </message> + <message> + <source>&Receiving addresses...</source> + <translation>&Адреса для получения...</translation> + </message> + <message> + <source>Open &URI...</source> + <translation>Открыть &URI...</translation> + </message> + <message> + <source>Syncing Headers (%1%)...</source> + <translation>Синхронизация заголовков (%1%)...</translation> + </message> + <message> + <source>&Debug window</source> + <translation>&Окно отладки</translation> + </message> + <message> + <source>&Verify message...</source> + <translation>&Проверить сообщение...</translation> + </message> + <message> <source>Bitcoin</source> <translation>Bitcoin Core</translation> </message> <message> + <source>Wallet</source> + <translation>Кошелек</translation> + </message> + <message> + <source>&Send</source> + <translation>&Отправить</translation> + </message> + <message> + <source>&Receive</source> + <translation>&Получить</translation> + </message> + <message> + <source>&Show / Hide</source> + <translation>&Показать / Спрятать</translation> + </message> + <message> + <source>&File</source> + <translation>&Файл</translation> + </message> + <message> + <source>&Settings</source> + <translation>&Настройки</translation> + </message> + <message> + <source>&Help</source> + <translation>&Помощь</translation> + </message> + <message> <source>&Command-line options</source> <translation>Опции командной строки</translation> </message> @@ -85,10 +277,30 @@ <source>Information</source> <translation>Информация</translation> </message> + <message> + <source>Up to date</source> + <translation>Готов</translation> + </message> + <message> + <source>Connecting to peers...</source> + <translation>Подключение к пирам...</translation> + </message> </context> <context> <name>CoinControlDialog</name> <message> + <source>Bytes:</source> + <translation>Байтов:</translation> + </message> + <message> + <source>Amount:</source> + <translation>Количество:</translation> + </message> + <message> + <source>Fee:</source> + <translation>Комиссия:</translation> + </message> + <message> <source>Date</source> <translation>Дата</translation> </message> @@ -100,6 +312,34 @@ <source>Confirmed</source> <translation>Подтвержденные</translation> </message> + <message> + <source>Copy address</source> + <translation>Копировать адрес</translation> + </message> + <message> + <source>Copy label</source> + <translation>Копировать метку</translation> + </message> + <message> + <source>Copy amount</source> + <translation>Копировать сумму</translation> + </message> + <message> + <source>Copy transaction ID</source> + <translation>Копировать ID транзакции</translation> + </message> + <message> + <source>yes</source> + <translation>да</translation> + </message> + <message> + <source>no</source> + <translation>нет</translation> + </message> + <message> + <source>(no label)</source> + <translation>(нет метки)</translation> + </message> </context> <context> <name>EditAddressDialog</name> @@ -125,16 +365,36 @@ <source>command-line options</source> <translation>Опции командной строки</translation> </message> + <message> + <source>Start minimized</source> + <translation>Запускать свернутым</translation> + </message> </context> <context> <name>Intro</name> <message> + <source>Welcome</source> + <translation>Добро пожаловать</translation> + </message> + <message> + <source>Welcome to %1.</source> + <translation>Добро пожаловать в %1.</translation> + </message> + <message> <source>Error</source> <translation>Ошибка</translation> </message> </context> <context> <name>ModalOverlay</name> + <message> + <source>Progress</source> + <translation>Прогресс</translation> + </message> + <message> + <source>Hide</source> + <translation>Спрятать</translation> + </message> </context> <context> <name>OpenURIDialog</name> @@ -149,9 +409,109 @@ </context> <context> <name>OptionsDialog</name> + <message> + <source>Options</source> + <translation>Опции</translation> + </message> + <message> + <source>MB</source> + <translation>МБ</translation> + </message> + <message> + <source>Allow incoming connections</source> + <translation>Разрешить входящие соеденения</translation> + </message> + <message> + <source>&Reset Options</source> + <translation>&Сбросить опции</translation> + </message> + <message> + <source>&Network</source> + <translation>&Сеть</translation> + </message> + <message> + <source>W&allet</source> + <translation>К&ошелёк</translation> + </message> + <message> + <source>Expert</source> + <translation>Эксперт</translation> + </message> + <message> + <source>Map port using &UPnP</source> + <translation>Пробросить порт через &UPnP</translation> + </message> + <message> + <source>Connect to the Bitcoin network through a SOCKS5 proxy.</source> + <translation>Подключится к сети Bitcoin через SOCKS5 прокси.</translation> + </message> + <message> + <source>Proxy &IP:</source> + <translation>IP прокси:</translation> + </message> + <message> + <source>&Port:</source> + <translation>&Порт:</translation> + </message> + <message> + <source>Port of the proxy (e.g. 9050)</source> + <translation>Порт прокси: (напр. 9050)</translation> + </message> + <message> + <source>IPv4</source> + <translation>IPv4</translation> + </message> + <message> + <source>IPv6</source> + <translation>IPv6</translation> + </message> + <message> + <source>Tor</source> + <translation>Tor</translation> + </message> + <message> + <source>&Window</source> + <translation>&Окно</translation> + </message> + <message> + <source>Hide tray icon</source> + <translation>Спрятать иконку в трее</translation> + </message> + <message> + <source>&OK</source> + <translation>&ОК</translation> + </message> + <message> + <source>&Cancel</source> + <translation>&Отмена</translation> + </message> </context> <context> <name>OverviewPage</name> + <message> + <source>Immature:</source> + <translation>Незрелые:</translation> + </message> + <message> + <source>Balances</source> + <translation>Балансы</translation> + </message> + <message> + <source>Total:</source> + <translation>Всего:</translation> + </message> + <message> + <source>Your current total balance</source> + <translation>Ваш текущий баланс:</translation> + </message> + <message> + <source>Your current balance in watch-only addresses</source> + <translation>Ваш текущий баланс на адресах только для чтения:</translation> + </message> + <message> + <source>Recent transactions</source> + <translation>Последние транзакции</translation> + </message> </context> <context> <name>PaymentServer</name> @@ -161,43 +521,243 @@ </context> <context> <name>QObject</name> + <message> + <source>Enter a Bitcoin address (e.g. %1)</source> + <translation>Введите биткоин-адрес (напр. %1)</translation> + </message> + <message numerus="yes"> + <source>%n hour(s)</source> + <translation><numerusform>%n час</numerusform><numerusform>%n часа</numerusform><numerusform>%n часов</numerusform><numerusform>%n часов</numerusform></translation> + </message> + <message numerus="yes"> + <source>%n day(s)</source> + <translation><numerusform>%n день</numerusform><numerusform>%n дней</numerusform><numerusform>%n дней</numerusform><numerusform>%n дней</numerusform></translation> + </message> + <message numerus="yes"> + <source>%n week(s)</source> + <translation><numerusform>%n неделя</numerusform><numerusform>%n недель</numerusform><numerusform>%n недель</numerusform><numerusform>%n недель</numerusform></translation> + </message> + <message> + <source>%1 and %2</source> + <translation>%1 и %2</translation> + </message> + <message numerus="yes"> + <source>%n year(s)</source> + <translation><numerusform>%n год</numerusform><numerusform>%n лет</numerusform><numerusform>%n лет</numerusform><numerusform>%n лет</numerusform></translation> + </message> </context> <context> <name>QObject::QObject</name> - </context> + <message> + <source>Error: %1</source> + <translation>Ошибка: %1</translation> + </message> +</context> <context> <name>QRImageWidget</name> - </context> + <message> + <source>Save QR Code</source> + <translation>Сохранить QR-код</translation> + </message> + <message> + <source>PNG Image (*.png)</source> + <translation>PNG Картинка (*.png)</translation> + </message> +</context> <context> <name>RPCConsole</name> <message> <source>&Information</source> <translation>Информация</translation> </message> - </context> + <message> + <source>Debug window</source> + <translation>Окно отладки</translation> + </message> + <message> + <source>Received</source> + <translation>Получено</translation> + </message> + <message> + <source>Sent</source> + <translation>Отправлено</translation> + </message> + <message> + <source>&Peers</source> + <translation>&Пиры</translation> + </message> + <message> + <source>Banned peers</source> + <translation>Заблокированные пиры</translation> + </message> + <message> + <source>Version</source> + <translation>Версия</translation> + </message> + <message> + <source>&Open</source> + <translation>&Открыть</translation> + </message> + <message> + <source>&Console</source> + <translation>&Консоль</translation> + </message> + <message> + <source>1 &hour</source> + <translation>1 &час</translation> + </message> + <message> + <source>1 &day</source> + <translation>1 &день</translation> + </message> + <message> + <source>1 &week</source> + <translation>1 &неделя</translation> + </message> + <message> + <source>1 &year</source> + <translation>1 &год</translation> + </message> + <message> + <source>%1 B</source> + <translation>%1 Б</translation> + </message> + <message> + <source>%1 KB</source> + <translation>%1 КБ</translation> + </message> + <message> + <source>%1 MB</source> + <translation>%1 МБ</translation> + </message> + <message> + <source>%1 GB</source> + <translation>%1 ГБ</translation> + </message> + <message> + <source>never</source> + <translation>никогда</translation> + </message> + <message> + <source>Yes</source> + <translation>Да</translation> + </message> + <message> + <source>No</source> + <translation>Нет</translation> + </message> + <message> + <source>Unknown</source> + <translation>Неизвестно</translation> + </message> +</context> <context> <name>ReceiveCoinsDialog</name> - </context> + <message> + <source>Clear</source> + <translation>Отчистить</translation> + </message> + <message> + <source>Show</source> + <translation>Показать</translation> + </message> + <message> + <source>Remove</source> + <translation>Удалить</translation> + </message> + <message> + <source>Copy URI</source> + <translation>Копировать URI</translation> + </message> + <message> + <source>Copy label</source> + <translation>Копировать метку</translation> + </message> + <message> + <source>Copy message</source> + <translation>Копировать сообщение</translation> + </message> + <message> + <source>Copy amount</source> + <translation>Копировать сумму</translation> + </message> +</context> <context> <name>ReceiveRequestDialog</name> + <message> + <source>Address</source> + <translation>Адрес</translation> + </message> + <message> + <source>Label</source> + <translation>Метка</translation> + </message> </context> <context> <name>RecentRequestsTableModel</name> + <message> + <source>Label</source> + <translation>Метка</translation> + </message> + <message> + <source>(no label)</source> + <translation>(нет метки)</translation> + </message> </context> <context> <name>SendCoinsDialog</name> - </context> + <message> + <source>Bytes:</source> + <translation>Байтов:</translation> + </message> + <message> + <source>Amount:</source> + <translation>Количество:</translation> + </message> + <message> + <source>Fee:</source> + <translation>Комиссия:</translation> + </message> + <message> + <source>Choose...</source> + <translation>Выбрать...</translation> + </message> + <message> + <source>Hide</source> + <translation>Спрятать</translation> + </message> + <message> + <source>Balance:</source> + <translation>Баланс:</translation> + </message> + <message> + <source>Copy amount</source> + <translation>Копировать сумму</translation> + </message> + <message> + <source>(no label)</source> + <translation>(нет метки)</translation> + </message> +</context> <context> <name>SendCoinsEntry</name> </context> <context> <name>SendConfirmationDialog</name> - </context> + <message> + <source>Yes</source> + <translation>Да</translation> + </message> +</context> <context> <name>ShutdownWindow</name> </context> <context> <name>SignVerifyMessageDialog</name> + <message> + <source>Signature</source> + <translation>Подпись</translation> + </message> </context> <context> <name>SplashScreen</name> @@ -213,9 +773,45 @@ </context> <context> <name>TransactionTableModel</name> + <message> + <source>Label</source> + <translation>Метка</translation> + </message> + <message> + <source>(no label)</source> + <translation>(нет метки)</translation> + </message> </context> <context> <name>TransactionView</name> + <message> + <source>Copy address</source> + <translation>Копировать адрес</translation> + </message> + <message> + <source>Copy label</source> + <translation>Копировать метку</translation> + </message> + <message> + <source>Copy amount</source> + <translation>Копировать сумму</translation> + </message> + <message> + <source>Copy transaction ID</source> + <translation>Копировать ID транзакции</translation> + </message> + <message> + <source>Label</source> + <translation>Метка</translation> + </message> + <message> + <source>Address</source> + <translation>Адрес</translation> + </message> + <message> + <source>Exporting Failed</source> + <translation>Экспорт не удался</translation> + </message> </context> <context> <name>UnitDisplayStatusBarControl</name> diff --git a/src/qt/locale/bitcoin_uk.ts b/src/qt/locale/bitcoin_uk.ts index 7126b2e5c1..4cff6bf370 100644 --- a/src/qt/locale/bitcoin_uk.ts +++ b/src/qt/locale/bitcoin_uk.ts @@ -62,6 +62,18 @@ <translation>Адреса отримання</translation> </message> <message> + <source>These are your Bitcoin addresses for sending payments. Always check the amount and the receiving address before sending coins.</source> + <translation>Це ваші адреси Bitcoin для надсилання платежів. Завжди перевіряйте суму та адресу одержувача перед відправленням монет.</translation> + </message> + <message> + <source>These are your Bitcoin addresses for receiving payments. It is recommended to use a new receiving address for each transaction.</source> + <translation>Це ваші адреси Bitcoin для отримання платежів. Для кожної транзакції рекомендується використовувати нову адресу одержувача.</translation> + </message> + <message> + <source>&Copy Address</source> + <translation>&Скопіювати адресу</translation> + </message> + <message> <source>Copy &Label</source> <translation>Зкопіювати&Створити мітку</translation> </message> @@ -93,6 +105,10 @@ <translation>Мітка</translation> </message> <message> + <source>Address</source> + <translation>Адреса</translation> + </message> + <message> <source>(no label)</source> <translation>(немає мітки)</translation> </message> @@ -115,7 +131,95 @@ <source>Repeat new passphrase</source> <translation>Повторіть пароль</translation> </message> - </context> + <message> + <source>Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>ten or more random characters</b>, or <b>eight or more words</b>.</source> + <translation>Введіть нову кодову фразу для гаманця.<br/>Будь ласка, використовуйте кодові фрази що містять <b> щонайменше десять випадкових символів </b> або <b> щонайменше вісім слів </b>.</translation> + </message> + <message> + <source>Encrypt wallet</source> + <translation>Зашифрувати гаманець</translation> + </message> + <message> + <source>This operation needs your wallet passphrase to unlock the wallet.</source> + <translation>Ця операція потребує пароль для розблокування гаманця.</translation> + </message> + <message> + <source>Unlock wallet</source> + <translation>Розблокувати гаманець</translation> + </message> + <message> + <source>This operation needs your wallet passphrase to decrypt the wallet.</source> + <translation>Ця операція потребує пароль для розшифрування гаманця.</translation> + </message> + <message> + <source>Decrypt wallet</source> + <translation>Дешифрувати гаманець</translation> + </message> + <message> + <source>Change passphrase</source> + <translation>Змінити пароль</translation> + </message> + <message> + <source>Enter the old passphrase and new passphrase to the wallet.</source> + <translation>Введіть старий пароль та новий пароль до гаманця.</translation> + </message> + <message> + <source>Confirm wallet encryption</source> + <translation>Підтвердіть шифрування гаманця</translation> + </message> + <message> + <source>Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR BITCOINS</b>!</source> + <translation>УВАГА: Якщо ви зашифруєте гаманець і забудете пароль, ви <b>ВТРАТИТЕ ВСІ СВОЇ БІТКОІНИ</b>!</translation> + </message> + <message> + <source>Are you sure you wish to encrypt your wallet?</source> + <translation>Ви дійсно хочете зашифрувати свій гаманець?</translation> + </message> + <message> + <source>Wallet encrypted</source> + <translation>Гаманець зашифровано</translation> + </message> + <message> + <source>%1 will close now to finish the encryption process. Remember that encrypting your wallet cannot fully protect your bitcoins from being stolen by malware infecting your computer.</source> + <translation>%1 буде закрито зараз, щоб завершити процес шифрування. Пам'ятайте, що шифрування гаманця не може повністю захистити ваші біткойни від крадіжки шкідливими програмами, у випадку якщо ваш комп'ютер буде інфіковано.</translation> + </message> + <message> + <source>IMPORTANT: Any previous backups you have made of your wallet file should be replaced with the newly generated, encrypted wallet file. For security reasons, previous backups of the unencrypted wallet file will become useless as soon as you start using the new, encrypted wallet.</source> + <translation>ВАЖЛИВО: Всі попередні резервні копії, які ви зробили з вашого файлу гаманця повинні бути замінені новоствореним, зашифрованим файлом гаманця. З міркувань безпеки, попередні резервні копії незашифрованого файла гаманця стануть непридатними одразу ж, як тільки ви почнете використовувати новий, зашифрований гаманець.</translation> + </message> + <message> + <source>Wallet encryption failed</source> + <translation>Не вдалося зашифрувати гаманець</translation> + </message> + <message> + <source>Wallet encryption failed due to an internal error. Your wallet was not encrypted.</source> + <translation>Виникла помилка під час шифрування гаманця. Ваш гаманець не було зашифровано.</translation> + </message> + <message> + <source>The supplied passphrases do not match.</source> + <translation>Введені паролі не співпадають.</translation> + </message> + <message> + <source>Wallet unlock failed</source> + <translation>Не вдалося розблокувати гаманець</translation> + </message> + <message> + <source>The passphrase entered for the wallet decryption was incorrect.</source> + <translation>Введений пароль є невірним.</translation> + </message> + <message> + <source>Wallet decryption failed</source> + <translation>Не вдалося розшифрувати гаманець</translation> + </message> + <message> + <source>Wallet passphrase was successfully changed.</source> + <translation>Пароль було успішно змінено.</translation> + </message> + <message> + <source>Warning: The Caps Lock key is on!</source> + <translation>Увага: Ввімкнено Caps Lock!</translation> + </message> +</context> <context> <name>BanTableModel</name> <message> @@ -170,6 +274,10 @@ <translation>П&ро %1</translation> </message> <message> + <source>Show information about %1</source> + <translation>Показати інформацію про %1</translation> + </message> + <message> <source>About &Qt</source> <translation>&Про Qt</translation> </message> @@ -182,6 +290,10 @@ <translation>&Параметри...</translation> </message> <message> + <source>Modify configuration options for %1</source> + <translation>Редагувати параметри для %1</translation> + </message> + <message> <source>&Encrypt Wallet...</source> <translation>&Шифрування гаманця...</translation> </message> @@ -206,6 +318,22 @@ <translation>Відкрити &URI</translation> </message> <message> + <source>Click to disable network activity.</source> + <translation>Натисніть, щоб вимкнути активність мережі.</translation> + </message> + <message> + <source>Network activity disabled.</source> + <translation>Мережева активність вимкнена.</translation> + </message> + <message> + <source>Click to enable network activity again.</source> + <translation>Натисніть, щоб знову активувати мережеву активність.</translation> + </message> + <message> + <source>Syncing Headers (%1%)...</source> + <translation>Синхронізація заголовків (%1%)...</translation> + </message> + <message> <source>Reindexing blocks on disk...</source> <translation>Переіндексація блоків на диску ...</translation> </message> @@ -309,6 +437,14 @@ <source>%n active connection(s) to Bitcoin network</source> <translation><numerusform>%n активне з'єднання з мережею Bitcoin</numerusform><numerusform>%n активні з'єднання з мережею Bitcoin</numerusform><numerusform>%n активних з'єднань з мережею Bitcoin</numerusform></translation> </message> + <message> + <source>Indexing blocks on disk...</source> + <translation>Індексація блоків на диску ...</translation> + </message> + <message> + <source>Processing blocks on disk...</source> + <translation>Обробка блоків на диску...</translation> + </message> <message numerus="yes"> <source>Processed %n block(s) of transaction history.</source> <translation><numerusform>Оброблено %n блок історії транзакцій.</numerusform><numerusform>Оброблено %n блоки історії транзакцій.</numerusform><numerusform>Оброблено %n блоків історії транзакцій.</numerusform></translation> @@ -342,6 +478,18 @@ <translation>Синхронізовано</translation> </message> <message> + <source>Show the %1 help message to get a list with possible Bitcoin command-line options</source> + <translation>Показати довідку %1 для отримання переліку можливих параметрів командного рядка.</translation> + </message> + <message> + <source>%1 client</source> + <translation>%1 клієнт</translation> + </message> + <message> + <source>Connecting to peers...</source> + <translation>Підключення до вузлів...</translation> + </message> + <message> <source>Catching up...</source> <translation>Синхронізується...</translation> </message> @@ -384,6 +532,14 @@ <translation>Отримані транзакції</translation> </message> <message> + <source>HD key generation is <b>enabled</b></source> + <translation>Генерація HD ключа <b>увімкнена</b></translation> + </message> + <message> + <source>HD key generation is <b>disabled</b></source> + <translation>Генерація HD ключа<b>вимкнена</b></translation> + </message> + <message> <source>Wallet is <b>encrypted</b> and currently <b>unlocked</b></source> <translation><b>Зашифрований</b> гаманець <b>розблоковано</b></translation> </message> @@ -391,7 +547,11 @@ <source>Wallet is <b>encrypted</b> and currently <b>locked</b></source> <translation><b>Зашифрований</b> гаманець <b>заблоковано</b></translation> </message> - </context> + <message> + <source>A fatal error occurred. Bitcoin can no longer continue safely and will quit.</source> + <translation>Сталася фатальна помилка. Помилки не сумісні з подальщою роботою. Гаманець буде закрито.</translation> + </message> +</context> <context> <name>CoinControlDialog</name> <message> @@ -463,10 +623,82 @@ <translation>Підтверджені</translation> </message> <message> + <source>Copy address</source> + <translation>Скопіювати адресу</translation> + </message> + <message> + <source>Copy label</source> + <translation>Скопіювати мітку</translation> + </message> + <message> + <source>Copy amount</source> + <translation>Скопіювати суму</translation> + </message> + <message> + <source>Copy transaction ID</source> + <translation>Скопіювати ID транзакції </translation> + </message> + <message> + <source>Lock unspent</source> + <translation>Заблокувати</translation> + </message> + <message> + <source>Unlock unspent</source> + <translation>Розблокувати</translation> + </message> + <message> + <source>Copy quantity</source> + <translation>Скопіювати кількість</translation> + </message> + <message> + <source>Copy fee</source> + <translation>Скопіювати комісію</translation> + </message> + <message> + <source>Copy after fee</source> + <translation>Скопіювати після комісії</translation> + </message> + <message> + <source>Copy bytes</source> + <translation>Скопіювати байти</translation> + </message> + <message> + <source>Copy dust</source> + <translation>Скопіювати інше</translation> + </message> + <message> + <source>Copy change</source> + <translation>Скопіювати решту</translation> + </message> + <message> + <source>(%1 locked)</source> + <translation>(%1 заблоковано)</translation> + </message> + <message> + <source>yes</source> + <translation>так</translation> + </message> + <message> + <source>no</source> + <translation>ні</translation> + </message> + <message> + <source>Can vary +/- %1 satoshi(s) per input.</source> + <translation>Може відрізнятися на +/- %1 сатоші за введені</translation> + </message> + <message> <source>(no label)</source> <translation>немає мітки</translation> </message> - </context> + <message> + <source>change from %1 (%2)</source> + <translation>решта з %1 (%2)</translation> + </message> + <message> + <source>(change)</source> + <translation>(решта)</translation> + </message> +</context> <context> <name>EditAddressDialog</name> <message> @@ -489,7 +721,39 @@ <source>&Address</source> <translation>&Адреса</translation> </message> - </context> + <message> + <source>New receiving address</source> + <translation>Нова адреса для отримання</translation> + </message> + <message> + <source>New sending address</source> + <translation>Нова адреса для відправлення</translation> + </message> + <message> + <source>Edit receiving address</source> + <translation>Редагувати адресу для отримання</translation> + </message> + <message> + <source>Edit sending address</source> + <translation>Редагувати адресу для відправлення</translation> + </message> + <message> + <source>The entered address "%1" is not a valid Bitcoin address.</source> + <translation>Введена адреса "%1" не є адресою в мережі Bitcoin.</translation> + </message> + <message> + <source>The entered address "%1" is already in the address book.</source> + <translation>Введена адреса «%1» вже присутня в адресній книзі.</translation> + </message> + <message> + <source>Could not unlock wallet.</source> + <translation>Неможливо розблокувати гаманець.</translation> + </message> + <message> + <source>New key generation failed.</source> + <translation>Не вдалося згенерувати нові ключі.</translation> + </message> +</context> <context> <name>FreespaceChecker</name> <message> @@ -524,6 +788,10 @@ <translation>(%1-бітний)</translation> </message> <message> + <source>About %1</source> + <translation>Про %1</translation> + </message> + <message> <source>Command-line options</source> <translation>Параметри командного рядка</translation> </message> @@ -559,7 +827,11 @@ <source>Show splash screen on startup (default: %u)</source> <translation>Показувати заставку під час запуску (типово: %u)</translation> </message> - </context> + <message> + <source>Reset all settings changed in the GUI</source> + <translation>Скинути налаштування, які було змінено через графічний інтерфейс користувача</translation> + </message> +</context> <context> <name>Intro</name> <message> @@ -567,6 +839,14 @@ <translation>Вітання</translation> </message> <message> + <source>Welcome to %1.</source> + <translation>Ласкаво просимо до %1.</translation> + </message> + <message> + <source>As this is the first time the program is launched, you can choose where %1 will store its data.</source> + <translation>Оскільки це перший запуск програми, ви можете обрати де %1 буде зберігати дані.</translation> + </message> + <message> <source>Use the default data directory</source> <translation>Використовувати типовий каталог даних</translation> </message> @@ -598,14 +878,50 @@ <translation>Форма</translation> </message> <message> + <source>Recent transactions may not yet be visible, and therefore your wallet's balance might be incorrect. This information will be correct once your wallet has finished synchronizing with the bitcoin network, as detailed below.</source> + <translation>Нещодавні транзакції ще не відображаються, тому баланс вашого гаманця може бути неточним. Ця інформація буде вірною після того, як ваш гаманець завершить синхронізацію з мережею біткойн, врахровуйте показники нижче.</translation> + </message> + <message> + <source>Attempting to spend bitcoins that are affected by not-yet-displayed transactions will not be accepted by the network.</source> + <translation>Спроба видправити біткойни, які ще не відображаються, не буде прийнята мережею.</translation> + </message> + <message> + <source>Number of blocks left</source> + <translation>Залишилося блоків</translation> + </message> + <message> + <source>Unknown...</source> + <translation>Невідомо...</translation> + </message> + <message> <source>Last block time</source> <translation>Час останнього блоку</translation> </message> <message> + <source>Progress</source> + <translation>Прогрес</translation> + </message> + <message> + <source>Progress increase per hour</source> + <translation>Прогрес за годину</translation> + </message> + <message> + <source>calculating...</source> + <translation>рахування...</translation> + </message> + <message> + <source>Estimated time left until synced</source> + <translation>Орієнтовний час до кінця синхронізації</translation> + </message> + <message> <source>Hide</source> <translation>Приховати</translation> </message> - </context> + <message> + <source>Unknown. Syncing Headers (%1)...</source> + <translation>Невідомо. Синхронізація заголовків (%1%)...</translation> + </message> +</context> <context> <name>OpenURIDialog</name> <message> @@ -624,7 +940,11 @@ <source>Select payment request file</source> <translation>Виберіть файл запиту платежу</translation> </message> - </context> + <message> + <source>Select payment request file to open</source> + <translation>Виберіть файл запиту платежу</translation> + </message> +</context> <context> <name>OptionsDialog</name> <message> @@ -636,6 +956,10 @@ <translation>&Головні</translation> </message> <message> + <source>&Start %1 on system login</source> + <translation>&Запускати %1 при вході в систему</translation> + </message> + <message> <source>Size of &database cache</source> <translation>Розмір &кешу бази даних</translation> </message> @@ -772,6 +1096,10 @@ <translation>&Вікно</translation> </message> <message> + <source>Hide tray icon</source> + <translation>Сховати іконку в треї</translation> + </message> + <message> <source>Show only a tray icon after minimizing the window.</source> <translation>Показувати лише іконку в треї після згортання вікна.</translation> </message> @@ -917,6 +1245,14 @@ </context> <context> <name>PaymentServer</name> + <message> + <source>Payment request error</source> + <translation>Помилка запиту платежу</translation> + </message> + <message> + <source>URI handling</source> + <translation>Обробка URI</translation> + </message> </context> <context> <name>PeerTableModel</name> @@ -928,7 +1264,11 @@ <source>Node/Service</source> <translation>Вузол/Сервіс</translation> </message> - </context> + <message> + <source>Ping</source> + <translation>Затримка</translation> + </message> +</context> <context> <name>QObject</name> <message> @@ -974,10 +1314,30 @@ </context> <context> <name>QObject::QObject</name> - </context> + <message> + <source>Error: %1</source> + <translation>Помилка: %1</translation> + </message> +</context> <context> <name>QRImageWidget</name> - </context> + <message> + <source>&Save Image...</source> + <translation>&Зберегти зображення...</translation> + </message> + <message> + <source>&Copy Image</source> + <translation>&Копіювати зображення</translation> + </message> + <message> + <source>Save QR Code</source> + <translation>Зберегти QR-код</translation> + </message> + <message> + <source>PNG Image (*.png)</source> + <translation>Зображення PNG (*.png)</translation> + </message> +</context> <context> <name>RPCConsole</name> <message> @@ -1089,6 +1449,14 @@ <translation>Клієнт користувача</translation> </message> <message> + <source>Decrease font size</source> + <translation>Зменшити розмір шрифту</translation> + </message> + <message> + <source>Increase font size</source> + <translation>Збільшити розмір шрифту</translation> + </message> + <message> <source>Services</source> <translation>Сервіси</translation> </message> @@ -1189,6 +1557,10 @@ <translation>Наберіть <b>help</b> для перегляду доступних команд.</translation> </message> <message> + <source>Network activity disabled</source> + <translation>Мережева активність вимкнена.</translation> + </message> + <message> <source>%1 B</source> <translation>%1 Б</translation> </message> @@ -1307,7 +1679,23 @@ <source>Remove</source> <translation>Вилучити</translation> </message> - </context> + <message> + <source>Copy URI</source> + <translation>Скопіювати адресу</translation> + </message> + <message> + <source>Copy label</source> + <translation>Скопіювати мітку</translation> + </message> + <message> + <source>Copy message</source> + <translation>Скопіювати повідомлення</translation> + </message> + <message> + <source>Copy amount</source> + <translation>Скопіювати суму</translation> + </message> +</context> <context> <name>ReceiveRequestDialog</name> <message> @@ -1327,21 +1715,57 @@ <translation>&Зберегти зображення...</translation> </message> <message> + <source>Payment information</source> + <translation>Інформація про платіж</translation> + </message> + <message> + <source>Address</source> + <translation>Адреса</translation> + </message> + <message> + <source>Amount</source> + <translation>Кількість</translation> + </message> + <message> <source>Label</source> <translation>Мітка</translation> </message> + <message> + <source>Message</source> + <translation>Повідомлення</translation> + </message> </context> <context> <name>RecentRequestsTableModel</name> <message> + <source>Date</source> + <translation>Дата</translation> + </message> + <message> <source>Label</source> <translation>Мітка</translation> </message> <message> + <source>Message</source> + <translation>Повідомлення</translation> + </message> + <message> <source>(no label)</source> <translation>немає мітки</translation> </message> - </context> + <message> + <source>(no message)</source> + <translation>(без повідомлення)</translation> + </message> + <message> + <source>(no amount requested)</source> + <translation>(без суми)</translation> + </message> + <message> + <source>Requested</source> + <translation>Запрошено</translation> + </message> +</context> <context> <name>SendCoinsDialog</name> <message> @@ -1469,6 +1893,10 @@ <translation>Пил:</translation> </message> <message> + <source>Confirmation time target:</source> + <translation>Час підтвердження:</translation> + </message> + <message> <source>Clear &All</source> <translation>Очистити &все</translation> </message> @@ -1485,6 +1913,34 @@ <translation>&Відправити</translation> </message> <message> + <source>Copy quantity</source> + <translation>Скопіювати кількість</translation> + </message> + <message> + <source>Copy amount</source> + <translation>Скопіювати суму</translation> + </message> + <message> + <source>Copy fee</source> + <translation>Скопіювати комісію</translation> + </message> + <message> + <source>Copy after fee</source> + <translation>Скопіювати після комісії</translation> + </message> + <message> + <source>Copy bytes</source> + <translation>Скопіювати байти</translation> + </message> + <message> + <source>Copy dust</source> + <translation>Скопіювати інше</translation> + </message> + <message> + <source>Copy change</source> + <translation>Скопіювати решту</translation> + </message> + <message> <source>(no label)</source> <translation>немає мітки</translation> </message> @@ -1567,10 +2023,18 @@ <source>Memo:</source> <translation>Нотатка:</translation> </message> - </context> + <message> + <source>Enter a label for this address to add it to your address book</source> + <translation>Введіть мітку для цієї адреси для додавання її в адресну книгу</translation> + </message> +</context> <context> <name>SendConfirmationDialog</name> - </context> + <message> + <source>Yes</source> + <translation>Так</translation> + </message> +</context> <context> <name>ShutdownWindow</name> <message> @@ -1664,7 +2128,59 @@ <source>Reset all verify message fields</source> <translation>Скинути всі поля перевірки повідомлення</translation> </message> - </context> + <message> + <source>Click "Sign Message" to generate signature</source> + <translation>Натисніть кнопку «Підписати повідомлення», для отримання підпису</translation> + </message> + <message> + <source>The entered address is invalid.</source> + <translation>Введена адреса не співпадає.</translation> + </message> + <message> + <source>Please check the address and try again.</source> + <translation>Будь ласка, перевірте адресу та спробуйте ще.</translation> + </message> + <message> + <source>The entered address does not refer to a key.</source> + <translation>Введена адреса не відноситься до ключа.</translation> + </message> + <message> + <source>Wallet unlock was cancelled.</source> + <translation>Розблокування гаманця було скасоване.</translation> + </message> + <message> + <source>Private key for the entered address is not available.</source> + <translation>Приватний ключ для введеної адреси недоступний. </translation> + </message> + <message> + <source>Message signing failed.</source> + <translation>Не вдалося підписати повідомлення.</translation> + </message> + <message> + <source>Message signed.</source> + <translation>Повідомлення підписано.</translation> + </message> + <message> + <source>The signature could not be decoded.</source> + <translation>Підпис не можливо декодувати.</translation> + </message> + <message> + <source>Please check the signature and try again.</source> + <translation>Будь ласка, перевірте підпис та спробуйте ще.</translation> + </message> + <message> + <source>The signature did not match the message digest.</source> + <translation>Підпис не збігається з хешем повідомлення.</translation> + </message> + <message> + <source>Message verification failed.</source> + <translation>Не вдалося перевірити повідомлення.</translation> + </message> + <message> + <source>Message verified.</source> + <translation>Повідомлення перевірено.</translation> + </message> +</context> <context> <name>SplashScreen</name> <message> @@ -1681,36 +2197,356 @@ </context> <context> <name>TransactionDesc</name> - </context> + <message> + <source>Open until %1</source> + <translation>Відкрито до %1</translation> + </message> + <message> + <source>Status</source> + <translation>Статут</translation> + </message> + <message> + <source>Date</source> + <translation>Дата</translation> + </message> + <message> + <source>Source</source> + <translation>Джерело</translation> + </message> + <message> + <source>Generated</source> + <translation>Згенеровано</translation> + </message> + <message> + <source>From</source> + <translation>Від</translation> + </message> + <message> + <source>unknown</source> + <translation>невідомо</translation> + </message> + <message> + <source>To</source> + <translation>Отримувач</translation> + </message> + <message> + <source>own address</source> + <translation>Власна адреса</translation> + </message> + <message> + <source>label</source> + <translation>мітка</translation> + </message> + <message> + <source>Credit</source> + <translation>Кредит</translation> + </message> + <message> + <source>not accepted</source> + <translation>не прийнято</translation> + </message> + <message> + <source>Debit</source> + <translation>Дебет</translation> + </message> + <message> + <source>Total debit</source> + <translation>Загальний дебет</translation> + </message> + <message> + <source>Total credit</source> + <translation>Загальний кредит</translation> + </message> + <message> + <source>Transaction fee</source> + <translation>Комісія за транзакцію</translation> + </message> + <message> + <source>Net amount</source> + <translation>Загальна сума</translation> + </message> + <message> + <source>Message</source> + <translation>Повідомлення</translation> + </message> + <message> + <source>Comment</source> + <translation>Коментар</translation> + </message> + <message> + <source>Transaction ID</source> + <translation>ID транзакції</translation> + </message> + <message> + <source>Transaction total size</source> + <translation>Розмір транзакції</translation> + </message> + <message> + <source>Merchant</source> + <translation>Продавець</translation> + </message> + <message> + <source>Transaction</source> + <translation>Транзакція</translation> + </message> + <message> + <source>Inputs</source> + <translation>Входи</translation> + </message> + <message> + <source>Amount</source> + <translation>Кількість</translation> + </message> + <message> + <source>true</source> + <translation>вірний</translation> + </message> + <message> + <source>false</source> + <translation>хибний</translation> + </message> +</context> <context> <name>TransactionDescDialog</name> <message> <source>This pane shows a detailed description of the transaction</source> <translation>Даний діалог показує детальну статистику по вибраній транзакції</translation> </message> - </context> + <message> + <source>Details for %1</source> + <translation>Інформація по %1</translation> + </message> +</context> <context> <name>TransactionTableModel</name> <message> + <source>Date</source> + <translation>Дата</translation> + </message> + <message> + <source>Type</source> + <translation>Тип</translation> + </message> + <message> <source>Label</source> <translation>Мітка</translation> </message> <message> + <source>Open until %1</source> + <translation>Відкрито до %1</translation> + </message> + <message> + <source>Offline</source> + <translation>Поза мережею</translation> + </message> + <message> + <source>Unconfirmed</source> + <translation>Не підтверджено</translation> + </message> + <message> + <source>Abandoned</source> + <translation>Відкинуті</translation> + </message> + <message> + <source>Confirming (%1 of %2 recommended confirmations)</source> + <translation>Підтверджується (%1 з %2 рекомендованих підтверджень)</translation> + </message> + <message> + <source>Confirmed (%1 confirmations)</source> + <translation>Підтверджено (%1 підтверджень)</translation> + </message> + <message> + <source>Conflicted</source> + <translation>Суперечить</translation> + </message> + <message> + <source>Immature (%1 confirmations, will be available after %2)</source> + <translation>Повністтю не підтверджено (%1 підтверджень, будуть доступні після %2)</translation> + </message> + <message> + <source>This block was not received by any other nodes and will probably not be accepted!</source> + <translation>Цей блок не був отриманий жодними іншими вузлами і, ймовірно, не буде прийнятий!</translation> + </message> + <message> + <source>Generated but not accepted</source> + <translation>Згенеровано (не підтверджено)</translation> + </message> + <message> + <source>Received with</source> + <translation>Отримано з</translation> + </message> + <message> + <source>Received from</source> + <translation>Отримано від</translation> + </message> + <message> + <source>Sent to</source> + <translation>Відправлені на</translation> + </message> + <message> + <source>Payment to yourself</source> + <translation>Відправлено собі</translation> + </message> + <message> + <source>Mined</source> + <translation>Добуті</translation> + </message> + <message> <source>(no label)</source> <translation>немає мітки</translation> </message> - </context> + <message> + <source>Transaction status. Hover over this field to show number of confirmations.</source> + <translation>Статус транзакції. Наведіть вказівник на це поле, щоб показати кількість підтверджень.</translation> + </message> + <message> + <source>Date and time that the transaction was received.</source> + <translation>Дата і час, коли транзакцію було отримано.</translation> + </message> + <message> + <source>Type of transaction.</source> + <translation>Тип транзакції.</translation> + </message> + <message> + <source>User-defined intent/purpose of the transaction.</source> + <translation>Визначений користувачем намір чи мета транзакції.</translation> + </message> + <message> + <source>Amount removed from or added to balance.</source> + <translation>Сума, додана чи знята з балансу.</translation> + </message> +</context> <context> <name>TransactionView</name> <message> + <source>All</source> + <translation>Всі</translation> + </message> + <message> + <source>Today</source> + <translation>Сьогодні</translation> + </message> + <message> + <source>This week</source> + <translation>На цьому тижні</translation> + </message> + <message> + <source>This month</source> + <translation>Цього місяця</translation> + </message> + <message> + <source>Last month</source> + <translation>Минулого місяця</translation> + </message> + <message> + <source>This year</source> + <translation>Цього року</translation> + </message> + <message> + <source>Range...</source> + <translation>Діапазон від:</translation> + </message> + <message> + <source>Received with</source> + <translation>Отримано з</translation> + </message> + <message> + <source>Sent to</source> + <translation>Відправлені на</translation> + </message> + <message> + <source>To yourself</source> + <translation>Відправлені собі</translation> + </message> + <message> + <source>Mined</source> + <translation>Добуті</translation> + </message> + <message> + <source>Other</source> + <translation>Інше</translation> + </message> + <message> + <source>Enter address or label to search</source> + <translation>Введіть адресу чи мітку для пошуку</translation> + </message> + <message> + <source>Min amount</source> + <translation>Мінімальна сума</translation> + </message> + <message> + <source>Abandon transaction</source> + <translation>Відмовитися від транзакції</translation> + </message> + <message> + <source>Copy address</source> + <translation>Скопіювати адресу</translation> + </message> + <message> + <source>Copy label</source> + <translation>Скопіювати мітку</translation> + </message> + <message> + <source>Copy amount</source> + <translation>Скопіювати суму</translation> + </message> + <message> + <source>Copy transaction ID</source> + <translation>Скопіювати ID транзакції </translation> + </message> + <message> + <source>Copy raw transaction</source> + <translation>Скопіювати RAW транзакцію</translation> + </message> + <message> + <source>Copy full transaction details</source> + <translation>Скопіювати повні деталі транзакції</translation> + </message> + <message> + <source>Edit label</source> + <translation>Редагувати мітку</translation> + </message> + <message> + <source>Show transaction details</source> + <translation>Показати деталі транзакції</translation> + </message> + <message> + <source>Export Transaction History</source> + <translation>Експортувати історію транзакцій</translation> + </message> + <message> <source>Comma separated file (*.csv)</source> <translation>Файли (*.csv) розділеі комами</translation> </message> <message> + <source>Confirmed</source> + <translation>Підтверджено</translation> + </message> + <message> + <source>Watch-only</source> + <translation>Тільки спостереження:</translation> + </message> + <message> + <source>Date</source> + <translation>Дата</translation> + </message> + <message> + <source>Type</source> + <translation>Тип</translation> + </message> + <message> <source>Label</source> <translation>Мітка</translation> </message> <message> + <source>Address</source> + <translation>Адреса</translation> + </message> + <message> + <source>ID</source> + <translation>Ідентифікатор</translation> + </message> + <message> <source>Exporting Failed</source> <translation>Експортування пройшло не успішно</translation> </message> @@ -1730,7 +2566,35 @@ </context> <context> <name>WalletView</name> - </context> + <message> + <source>&Export</source> + <translation>&Експорт</translation> + </message> + <message> + <source>Export the data in the current tab to a file</source> + <translation>Експортувати дані з поточної вкладки в файл</translation> + </message> + <message> + <source>Backup Wallet</source> + <translation>Зробити резервне копіювання гаманця</translation> + </message> + <message> + <source>Wallet Data (*.dat)</source> + <translation>Данi гаманця (*.dat)</translation> + </message> + <message> + <source>Backup Failed</source> + <translation>Помилка резервного копіювання</translation> + </message> + <message> + <source>Backup Successful</source> + <translation>Резервну копію створено успішно</translation> + </message> + <message> + <source>The wallet data was successfully saved to %1.</source> + <translation>Дані гаманця успішно збережено в %1.</translation> + </message> +</context> <context> <name>bitcoin-core</name> <message> @@ -1834,6 +2698,10 @@ <translation>Параметри з'єднання:</translation> </message> <message> + <source>Copyright (C) %i-%i</source> + <translation>Всі права збережено. %i-%i</translation> + </message> + <message> <source>Corrupted block database detected</source> <translation>Виявлено пошкоджений блок бази даних</translation> </message> @@ -1914,6 +2782,10 @@ <translation>Підключатися тільки до вузлів в мережі <net> (ipv4, ipv6 або onion)</translation> </message> <message> + <source>Print this help message and exit</source> + <translation>Надрукувати це довідкове повідомлення та вийти</translation> + </message> + <message> <source>Print version and exit</source> <translation>Версія для друку і виходу</translation> </message> @@ -1926,6 +2798,10 @@ <translation>Використання скороченого ланцюжка блоків несумісне з параметром -txindex.</translation> </message> <message> + <source>Rewinding blocks...</source> + <translation>Відтворення блоків...</translation> + </message> + <message> <source>Set database cache size in megabytes (%d to %d, default: %d)</source> <translation>Встановити розмір кешу бази даних в мегабайтах (від %d до %d, типово: %d)</translation> </message> @@ -2298,10 +3174,18 @@ <translation>Ретранслювати не-P2SH транзакції з мультипідписом (типово: %u)</translation> </message> <message> + <source>Send transactions with full-RBF opt-in enabled (default: %u)</source> + <translation>Надіслати транзакції з увімкненням full-RBF opt-in (типово: %u)</translation> + </message> + <message> <source>Set key pool size to <n> (default: %u)</source> <translation>Встановити розмір пулу ключів <n> (типово: %u)</translation> </message> <message> + <source>Set maximum BIP141 block weight (default: %d)</source> + <translation>Встановити максимальний розмір блоку BIP141 (за замовчуванням: %d)</translation> + </message> + <message> <source>Set the number of threads to service RPC calls (default: %d)</source> <translation>Встановити число потоків для обслуговування викликів RPC (типово: %d)</translation> </message> @@ -2322,10 +3206,38 @@ <translation>Витрачати непідтверджену решту при відправленні транзакцій (типово: %u)</translation> </message> <message> + <source>Starting network threads...</source> + <translation>Запуск мережевих потоків...</translation> + </message> + <message> + <source>The wallet will avoid paying less than the minimum relay fee.</source> + <translation>Гаманець не не переведе кошти якщо комісія менше мінімальної плати за транзакцію.</translation> + </message> + <message> + <source>This is the minimum transaction fee you pay on every transaction.</source> + <translation>Це мінімальна плата за транзакцію, яку ви сплачуєте за кожну операцію.</translation> + </message> + <message> + <source>This is the transaction fee you will pay if you send a transaction.</source> + <translation>Це транзакційна комісія, яку ви сплатите, якщо будете надсилати транзакцію.</translation> + </message> + <message> <source>Threshold for disconnecting misbehaving peers (default: %u)</source> <translation>Поріг відключення учасників з поганою поведінкою (типово: %u)</translation> </message> <message> + <source>Transaction amounts must not be negative</source> + <translation>Сума транзакції занадто мала (зменьшіть комісію, якщо можливо)</translation> + </message> + <message> + <source>Transaction has too long of a mempool chain</source> + <translation>У транзакції занадто довгий ланцюг</translation> + </message> + <message> + <source>Transaction must have at least one recipient</source> + <translation>У транзакції повинен бути щонайменше один одержувач</translation> + </message> + <message> <source>Unknown network specified in -onlynet: '%s'</source> <translation>Невідома мережа вказана в -onlynet: «%s»</translation> </message> diff --git a/src/random.cpp b/src/random.cpp index 3a48c72b68..b004bfa91e 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -27,9 +27,12 @@ #include <sys/syscall.h> #include <linux/random.h> #endif -#ifdef HAVE_GETENTROPY +#if defined(HAVE_GETENTROPY) || (defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)) #include <unistd.h> #endif +#if defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX) +#include <sys/random.h> +#endif #ifdef HAVE_SYSCTL_ARND #include <sys/sysctl.h> #endif @@ -237,6 +240,15 @@ void GetOSRand(unsigned char *ent32) if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) { RandFailure(); } +#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX) + // We need a fallback for OSX < 10.12 + if (&getentropy != NULL) { + if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) { + RandFailure(); + } + } else { + GetDevURandom(ent32); + } #elif defined(HAVE_SYSCTL_ARND) /* FreeBSD and similar. It is possible for the call to return less * bytes than requested, so need to read in a loop. diff --git a/src/reverse_iterator.h b/src/reverse_iterator.h index 409f895ce0..46789e5417 100644 --- a/src/reverse_iterator.h +++ b/src/reverse_iterator.h @@ -1,7 +1,7 @@ // Taken from https://gist.github.com/arvidsson/7231973 -#ifndef BITCOIN_REVERSE_ITERATOR_HPP -#define BITCOIN_REVERSE_ITERATOR_HPP +#ifndef BITCOIN_REVERSE_ITERATOR_H +#define BITCOIN_REVERSE_ITERATOR_H /** * Template used for reverse iteration in C++11 range-based for loops. @@ -14,19 +14,19 @@ template <typename T> class reverse_range { - T &x; + T &m_x; public: - reverse_range(T &x) : x(x) {} + reverse_range(T &x) : m_x(x) {} - auto begin() const -> decltype(this->x.rbegin()) + auto begin() const -> decltype(this->m_x.rbegin()) { - return x.rbegin(); + return m_x.rbegin(); } - auto end() const -> decltype(this->x.rend()) + auto end() const -> decltype(this->m_x.rend()) { - return x.rend(); + return m_x.rend(); } }; @@ -36,4 +36,4 @@ reverse_range<T> reverse_iterate(T &x) return reverse_range<T>(x); } -#endif // BITCOIN_REVERSE_ITERATOR_HPP +#endif // BITCOIN_REVERSE_ITERATOR_H diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 6975d26c69..701608e132 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -962,7 +962,6 @@ UniValue gettxout(const JSONRPCRequest& request) " ,...\n" " ]\n" " },\n" - " \"version\" : n, (numeric) The version\n" " \"coinbase\" : true|false (boolean) Coinbase or not\n" "}\n" diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 08920915ae..efff4a99ae 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -6,6 +6,7 @@ #include "base58.h" #include "chain.h" #include "clientversion.h" +#include "core_io.h" #include "init.h" #include "validation.h" #include "httpserver.h" diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index e890f0ddcd..e463a4eda4 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -6,6 +6,7 @@ #include "chainparams.h" #include "clientversion.h" +#include "core_io.h" #include "validation.h" #include "net.h" #include "net_processing.h" diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index c3c9d10e2a..1799c8e98e 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -123,16 +123,6 @@ CAmount AmountFromValue(const UniValue& value) return amount; } -UniValue ValueFromAmount(const CAmount& amount) -{ - bool sign = amount < 0; - int64_t n_abs = (sign ? -amount : amount); - int64_t quotient = n_abs / COIN; - int64_t remainder = n_abs % COIN; - return UniValue(UniValue::VNUM, - strprintf("%s%d.%08d", sign ? "-" : "", quotient, remainder)); -} - uint256 ParseHashV(const UniValue& v, std::string strName) { std::string strHex; diff --git a/src/rpc/server.h b/src/rpc/server.h index b20c827727..dd6f763245 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -185,7 +185,6 @@ extern std::vector<unsigned char> ParseHexV(const UniValue& v, std::string strNa extern std::vector<unsigned char> ParseHexO(const UniValue& o, std::string strKey); extern CAmount AmountFromValue(const UniValue& value); -extern UniValue ValueFromAmount(const CAmount& amount); extern std::string HelpExampleCli(const std::string& methodname, const std::string& args); extern std::string HelpExampleRpc(const std::string& methodname, const std::string& args); diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp index 067a9c6ff0..2ad22d34ad 100644 --- a/src/test/addrman_tests.cpp +++ b/src/test/addrman_tests.cpp @@ -15,9 +15,14 @@ class CAddrManTest : public CAddrMan uint64_t state; public: - CAddrManTest() + CAddrManTest(bool makeDeterministic = true) { state = 1; + + if (makeDeterministic) { + // Set addrman addr placement to be deterministic. + MakeDeterministic(); + } } //! Ensure that bucket placement is always the same for testing purposes. @@ -79,9 +84,6 @@ BOOST_AUTO_TEST_CASE(addrman_simple) { CAddrManTest addrman; - // Set addrman addr placement to be deterministic. - addrman.MakeDeterministic(); - CNetAddr source = ResolveIP("252.2.2.2"); // Test: Does Addrman respond correctly when empty. @@ -131,9 +133,6 @@ BOOST_AUTO_TEST_CASE(addrman_ports) { CAddrManTest addrman; - // Set addrman addr placement to be deterministic. - addrman.MakeDeterministic(); - CNetAddr source = ResolveIP("252.2.2.2"); BOOST_CHECK_EQUAL(addrman.size(), 0); @@ -163,9 +162,6 @@ BOOST_AUTO_TEST_CASE(addrman_select) { CAddrManTest addrman; - // Set addrman addr placement to be deterministic. - addrman.MakeDeterministic(); - CNetAddr source = ResolveIP("252.2.2.2"); // Test: Select from new with 1 addr in new. @@ -225,9 +221,6 @@ BOOST_AUTO_TEST_CASE(addrman_new_collisions) { CAddrManTest addrman; - // Set addrman addr placement to be deterministic. - addrman.MakeDeterministic(); - CNetAddr source = ResolveIP("252.2.2.2"); BOOST_CHECK_EQUAL(addrman.size(), 0); @@ -254,9 +247,6 @@ BOOST_AUTO_TEST_CASE(addrman_tried_collisions) { CAddrManTest addrman; - // Set addrman addr placement to be deterministic. - addrman.MakeDeterministic(); - CNetAddr source = ResolveIP("252.2.2.2"); BOOST_CHECK_EQUAL(addrman.size(), 0); @@ -284,9 +274,6 @@ BOOST_AUTO_TEST_CASE(addrman_find) { CAddrManTest addrman; - // Set addrman addr placement to be deterministic. - addrman.MakeDeterministic(); - BOOST_CHECK_EQUAL(addrman.size(), 0); CAddress addr1 = CAddress(ResolveService("250.1.2.1", 8333), NODE_NONE); @@ -320,9 +307,6 @@ BOOST_AUTO_TEST_CASE(addrman_create) { CAddrManTest addrman; - // Set addrman addr placement to be deterministic. - addrman.MakeDeterministic(); - BOOST_CHECK_EQUAL(addrman.size(), 0); CAddress addr1 = CAddress(ResolveService("250.1.2.1", 8333), NODE_NONE); @@ -343,9 +327,6 @@ BOOST_AUTO_TEST_CASE(addrman_delete) { CAddrManTest addrman; - // Set addrman addr placement to be deterministic. - addrman.MakeDeterministic(); - BOOST_CHECK_EQUAL(addrman.size(), 0); CAddress addr1 = CAddress(ResolveService("250.1.2.1", 8333), NODE_NONE); @@ -366,9 +347,6 @@ BOOST_AUTO_TEST_CASE(addrman_getaddr) { CAddrManTest addrman; - // Set addrman addr placement to be deterministic. - addrman.MakeDeterministic(); - // Test: Sanity check, GetAddr should never return anything if addrman // is empty. BOOST_CHECK_EQUAL(addrman.size(), 0); @@ -430,9 +408,6 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_tried_bucket) { CAddrManTest addrman; - // Set addrman addr placement to be deterministic. - addrman.MakeDeterministic(); - CAddress addr1 = CAddress(ResolveService("250.1.1.1", 8333), NODE_NONE); CAddress addr2 = CAddress(ResolveService("250.1.1.1", 9999), NODE_NONE); @@ -487,9 +462,6 @@ BOOST_AUTO_TEST_CASE(caddrinfo_get_new_bucket) { CAddrManTest addrman; - // Set addrman addr placement to be deterministic. - addrman.MakeDeterministic(); - CAddress addr1 = CAddress(ResolveService("250.1.2.1", 8333), NODE_NONE); CAddress addr2 = CAddress(ResolveService("250.1.2.1", 9999), NODE_NONE); diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp index 134bd7c609..c6643be7a7 100644 --- a/src/test/rpc_tests.cpp +++ b/src/test/rpc_tests.cpp @@ -6,6 +6,7 @@ #include "rpc/client.h" #include "base58.h" +#include "core_io.h" #include "netbase.h" #include "test/test_bitcoin.h" diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index a64fb6903f..72d7f1b19f 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -75,7 +75,7 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha pcoinsdbview = new CCoinsViewDB(1 << 23, true); pcoinsTip = new CCoinsViewCache(pcoinsdbview); if (!LoadGenesisBlock(chainparams)) { - throw std::runtime_error("InitBlockIndex failed."); + throw std::runtime_error("LoadGenesisBlock failed."); } { CValidationState state; diff --git a/src/txdb.cpp b/src/txdb.cpp index fd730c368a..7f7eb65673 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -422,5 +422,5 @@ bool CCoinsViewDB::Upgrade() { db.CompactRange({DB_COINS, uint256()}, key); uiInterface.SetProgressBreakAction(std::function<void(void)>()); LogPrintf("[%s].\n", ShutdownRequested() ? "CANCELLED" : "DONE"); - return true; + return !ShutdownRequested(); } diff --git a/src/utilmoneystr.h b/src/utilmoneystr.h index 5839b07344..bc885ee167 100644 --- a/src/utilmoneystr.h +++ b/src/utilmoneystr.h @@ -14,6 +14,9 @@ #include "amount.h" +/* Do not use these functions to represent or parse monetary amounts to or from + * JSON but use AmountFromValue and ValueFromAmount for that. + */ std::string FormatMoney(const CAmount& n); bool ParseMoney(const std::string& str, CAmount& nRet); bool ParseMoney(const char* pszIn, CAmount& nRet); diff --git a/src/validation.cpp b/src/validation.cpp index 5e0c710de0..f21700c673 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1863,95 +1863,100 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd */ bool static FlushStateToDisk(const CChainParams& chainparams, CValidationState &state, FlushStateMode mode, int nManualPruneHeight) { int64_t nMempoolUsage = mempool.DynamicMemoryUsage(); - LOCK2(cs_main, cs_LastBlockFile); + LOCK(cs_main); static int64_t nLastWrite = 0; static int64_t nLastFlush = 0; static int64_t nLastSetChain = 0; std::set<int> setFilesToPrune; bool fFlushForPrune = false; + bool fDoFullFlush = false; + int64_t nNow = 0; try { - if (fPruneMode && (fCheckForPruning || nManualPruneHeight > 0) && !fReindex) { - if (nManualPruneHeight > 0) { - FindFilesToPruneManual(setFilesToPrune, nManualPruneHeight); - } else { - FindFilesToPrune(setFilesToPrune, chainparams.PruneAfterHeight()); - fCheckForPruning = false; - } - if (!setFilesToPrune.empty()) { - fFlushForPrune = true; - if (!fHavePruned) { - pblocktree->WriteFlag("prunedblockfiles", true); - fHavePruned = true; - } - } - } - int64_t nNow = GetTimeMicros(); - // Avoid writing/flushing immediately after startup. - if (nLastWrite == 0) { - nLastWrite = nNow; - } - if (nLastFlush == 0) { - nLastFlush = nNow; - } - if (nLastSetChain == 0) { - nLastSetChain = nNow; - } - int64_t nMempoolSizeMax = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; - int64_t cacheSize = pcoinsTip->DynamicMemoryUsage(); - int64_t nTotalSpace = nCoinCacheUsage + std::max<int64_t>(nMempoolSizeMax - nMempoolUsage, 0); - // The cache is large and we're within 10% and 10 MiB of the limit, but we have time now (not in the middle of a block processing). - bool fCacheLarge = mode == FLUSH_STATE_PERIODIC && cacheSize > std::max((9 * nTotalSpace) / 10, nTotalSpace - MAX_BLOCK_COINSDB_USAGE * 1024 * 1024); - // The cache is over the limit, we have to write now. - bool fCacheCritical = mode == FLUSH_STATE_IF_NEEDED && cacheSize > nTotalSpace; - // It's been a while since we wrote the block index to disk. Do this frequently, so we don't need to redownload after a crash. - bool fPeriodicWrite = mode == FLUSH_STATE_PERIODIC && nNow > nLastWrite + (int64_t)DATABASE_WRITE_INTERVAL * 1000000; - // It's been very long since we flushed the cache. Do this infrequently, to optimize cache usage. - bool fPeriodicFlush = mode == FLUSH_STATE_PERIODIC && nNow > nLastFlush + (int64_t)DATABASE_FLUSH_INTERVAL * 1000000; - // Combine all conditions that result in a full cache flush. - bool fDoFullFlush = (mode == FLUSH_STATE_ALWAYS) || fCacheLarge || fCacheCritical || fPeriodicFlush || fFlushForPrune; - // Write blocks and block index to disk. - if (fDoFullFlush || fPeriodicWrite) { - // Depend on nMinDiskSpace to ensure we can write block index - if (!CheckDiskSpace(0)) - return state.Error("out of disk space"); - // First make sure all block and undo data is flushed to disk. - FlushBlockFile(); - // Then update all block file information (which may refer to block and undo files). - { - std::vector<std::pair<int, const CBlockFileInfo*> > vFiles; - vFiles.reserve(setDirtyFileInfo.size()); - for (std::set<int>::iterator it = setDirtyFileInfo.begin(); it != setDirtyFileInfo.end(); ) { - vFiles.push_back(std::make_pair(*it, &vinfoBlockFile[*it])); - setDirtyFileInfo.erase(it++); + { + LOCK(cs_LastBlockFile); + if (fPruneMode && (fCheckForPruning || nManualPruneHeight > 0) && !fReindex) { + if (nManualPruneHeight > 0) { + FindFilesToPruneManual(setFilesToPrune, nManualPruneHeight); + } else { + FindFilesToPrune(setFilesToPrune, chainparams.PruneAfterHeight()); + fCheckForPruning = false; } - std::vector<const CBlockIndex*> vBlocks; - vBlocks.reserve(setDirtyBlockIndex.size()); - for (std::set<CBlockIndex*>::iterator it = setDirtyBlockIndex.begin(); it != setDirtyBlockIndex.end(); ) { - vBlocks.push_back(*it); - setDirtyBlockIndex.erase(it++); + if (!setFilesToPrune.empty()) { + fFlushForPrune = true; + if (!fHavePruned) { + pblocktree->WriteFlag("prunedblockfiles", true); + fHavePruned = true; + } } - if (!pblocktree->WriteBatchSync(vFiles, nLastBlockFile, vBlocks)) { - return AbortNode(state, "Failed to write to block index database"); + } + nNow = GetTimeMicros(); + // Avoid writing/flushing immediately after startup. + if (nLastWrite == 0) { + nLastWrite = nNow; + } + if (nLastFlush == 0) { + nLastFlush = nNow; + } + if (nLastSetChain == 0) { + nLastSetChain = nNow; + } + int64_t nMempoolSizeMax = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; + int64_t cacheSize = pcoinsTip->DynamicMemoryUsage(); + int64_t nTotalSpace = nCoinCacheUsage + std::max<int64_t>(nMempoolSizeMax - nMempoolUsage, 0); + // The cache is large and we're within 10% and 10 MiB of the limit, but we have time now (not in the middle of a block processing). + bool fCacheLarge = mode == FLUSH_STATE_PERIODIC && cacheSize > std::max((9 * nTotalSpace) / 10, nTotalSpace - MAX_BLOCK_COINSDB_USAGE * 1024 * 1024); + // The cache is over the limit, we have to write now. + bool fCacheCritical = mode == FLUSH_STATE_IF_NEEDED && cacheSize > nTotalSpace; + // It's been a while since we wrote the block index to disk. Do this frequently, so we don't need to redownload after a crash. + bool fPeriodicWrite = mode == FLUSH_STATE_PERIODIC && nNow > nLastWrite + (int64_t)DATABASE_WRITE_INTERVAL * 1000000; + // It's been very long since we flushed the cache. Do this infrequently, to optimize cache usage. + bool fPeriodicFlush = mode == FLUSH_STATE_PERIODIC && nNow > nLastFlush + (int64_t)DATABASE_FLUSH_INTERVAL * 1000000; + // Combine all conditions that result in a full cache flush. + fDoFullFlush = (mode == FLUSH_STATE_ALWAYS) || fCacheLarge || fCacheCritical || fPeriodicFlush || fFlushForPrune; + // Write blocks and block index to disk. + if (fDoFullFlush || fPeriodicWrite) { + // Depend on nMinDiskSpace to ensure we can write block index + if (!CheckDiskSpace(0)) + return state.Error("out of disk space"); + // First make sure all block and undo data is flushed to disk. + FlushBlockFile(); + // Then update all block file information (which may refer to block and undo files). + { + std::vector<std::pair<int, const CBlockFileInfo*> > vFiles; + vFiles.reserve(setDirtyFileInfo.size()); + for (std::set<int>::iterator it = setDirtyFileInfo.begin(); it != setDirtyFileInfo.end(); ) { + vFiles.push_back(std::make_pair(*it, &vinfoBlockFile[*it])); + setDirtyFileInfo.erase(it++); + } + std::vector<const CBlockIndex*> vBlocks; + vBlocks.reserve(setDirtyBlockIndex.size()); + for (std::set<CBlockIndex*>::iterator it = setDirtyBlockIndex.begin(); it != setDirtyBlockIndex.end(); ) { + vBlocks.push_back(*it); + setDirtyBlockIndex.erase(it++); + } + if (!pblocktree->WriteBatchSync(vFiles, nLastBlockFile, vBlocks)) { + return AbortNode(state, "Failed to write to block index database"); + } } + // Finally remove any pruned files + if (fFlushForPrune) + UnlinkPrunedFiles(setFilesToPrune); + nLastWrite = nNow; + } + // Flush best chain related state. This can only be done if the blocks / block index write was also done. + if (fDoFullFlush) { + // Typical Coin structures on disk are around 48 bytes in size. + // Pushing a new one to the database can cause it to be written + // twice (once in the log, and once in the tables). This is already + // an overestimation, as most will delete an existing entry or + // overwrite one. Still, use a conservative safety factor of 2. + if (!CheckDiskSpace(48 * 2 * 2 * pcoinsTip->GetCacheSize())) + return state.Error("out of disk space"); + // Flush the chainstate (which may refer to block index entries). + if (!pcoinsTip->Flush()) + return AbortNode(state, "Failed to write to coin database"); + nLastFlush = nNow; } - // Finally remove any pruned files - if (fFlushForPrune) - UnlinkPrunedFiles(setFilesToPrune); - nLastWrite = nNow; - } - // Flush best chain related state. This can only be done if the blocks / block index write was also done. - if (fDoFullFlush) { - // Typical Coin structures on disk are around 48 bytes in size. - // Pushing a new one to the database can cause it to be written - // twice (once in the log, and once in the tables). This is already - // an overestimation, as most will delete an existing entry or - // overwrite one. Still, use a conservative safety factor of 2. - if (!CheckDiskSpace(48 * 2 * 2 * pcoinsTip->GetCacheSize())) - return state.Error("out of disk space"); - // Flush the chainstate (which may refer to block index entries). - if (!pcoinsTip->Flush()) - return AbortNode(state, "Failed to write to coin database"); - nLastFlush = nNow; } if (fDoFullFlush || ((mode == FLUSH_STATE_ALWAYS || mode == FLUSH_STATE_PERIODIC) && nNow > nLastSetChain + (int64_t)DATABASE_WRITE_INTERVAL * 1000000)) { // Update best block in wallet (so we can detect restored wallets). @@ -2830,22 +2835,6 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P return true; } -static bool CheckIndexAgainstCheckpoint(const CBlockIndex* pindexPrev, CValidationState& state, const CChainParams& chainparams, const uint256& hash) -{ - if (*pindexPrev->phashBlock == chainparams.GetConsensus().hashGenesisBlock) - return true; - - int nHeight = pindexPrev->nHeight+1; - // Don't accept any forks from the main chain prior to last checkpoint. - // GetLastCheckpoint finds the last checkpoint in MapCheckpoints that's in our - // MapBlockIndex. - CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(chainparams.Checkpoints()); - if (pcheckpoint && nHeight < pcheckpoint->nHeight) - return state.DoS(100, error("%s: forked chain older than last checkpoint (height %d)", __func__, nHeight), REJECT_CHECKPOINT, "bad-fork-prior-to-checkpoint"); - - return true; -} - bool IsWitnessEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& params) { LOCK(cs_main); @@ -2911,14 +2900,26 @@ std::vector<unsigned char> GenerateCoinbaseCommitment(CBlock& block, const CBloc /** Context-dependent validity checks. * By "context", we mean only the previous block headers, but not the UTXO * set; UTXO-related validity checks are done in ConnectBlock(). */ -static bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& state, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev, int64_t nAdjustedTime) +static bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& state, const CChainParams& params, const CBlockIndex* pindexPrev, int64_t nAdjustedTime) { assert(pindexPrev != nullptr); const int nHeight = pindexPrev->nHeight + 1; + // Check proof of work + const Consensus::Params& consensusParams = params.GetConsensus(); if (block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams)) return state.DoS(100, false, REJECT_INVALID, "bad-diffbits", false, "incorrect proof of work"); + // Check against checkpoints + if (fCheckpointsEnabled) { + // Don't accept any forks from the main chain prior to last checkpoint. + // GetLastCheckpoint finds the last checkpoint in MapCheckpoints that's in our + // MapBlockIndex. + CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(params.Checkpoints()); + if (pcheckpoint && nHeight < pcheckpoint->nHeight) + return state.DoS(100, error("%s: forked chain older than last checkpoint (height %d)", __func__, nHeight), REJECT_CHECKPOINT, "bad-fork-prior-to-checkpoint"); + } + // Check timestamp against prev if (block.GetBlockTime() <= pindexPrev->GetMedianTimePast()) return state.Invalid(false, REJECT_INVALID, "time-too-old", "block's timestamp is too early"); @@ -3049,12 +3050,7 @@ static bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state pindexPrev = (*mi).second; if (pindexPrev->nStatus & BLOCK_FAILED_MASK) return state.DoS(100, error("%s: prev block invalid", __func__), REJECT_INVALID, "bad-prevblk"); - - assert(pindexPrev); - if (fCheckpointsEnabled && !CheckIndexAgainstCheckpoint(pindexPrev, state, chainparams, hash)) - return error("%s: CheckIndexAgainstCheckpoint(): %s", __func__, state.GetRejectReason().c_str()); - - if (!ContextualCheckBlockHeader(block, state, chainparams.GetConsensus(), pindexPrev, GetAdjustedTime())) + if (!ContextualCheckBlockHeader(block, state, chainparams, pindexPrev, GetAdjustedTime())) return error("%s: Consensus::ContextualCheckBlockHeader: %s, %s", __func__, hash.ToString(), FormatStateMessage(state)); } if (pindex == nullptr) @@ -3203,16 +3199,13 @@ bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, { AssertLockHeld(cs_main); assert(pindexPrev && pindexPrev == chainActive.Tip()); - if (fCheckpointsEnabled && !CheckIndexAgainstCheckpoint(pindexPrev, state, chainparams, block.GetHash())) - return error("%s: CheckIndexAgainstCheckpoint(): %s", __func__, state.GetRejectReason().c_str()); - CCoinsViewCache viewNew(pcoinsTip); CBlockIndex indexDummy(block); indexDummy.pprev = pindexPrev; indexDummy.nHeight = pindexPrev->nHeight + 1; // NOTE: CheckBlockHeader is called by CheckBlock - if (!ContextualCheckBlockHeader(block, state, chainparams.GetConsensus(), pindexPrev, GetAdjustedTime())) + if (!ContextualCheckBlockHeader(block, state, chainparams, pindexPrev, GetAdjustedTime())) return error("%s: Consensus::ContextualCheckBlockHeader: %s", __func__, FormatStateMessage(state)); if (!CheckBlock(block, state, chainparams.GetConsensus(), fCheckPOW, fCheckMerkleRoot)) return error("%s: Consensus::CheckBlock: %s", __func__, FormatStateMessage(state)); @@ -3916,7 +3909,6 @@ bool LoadGenesisBlock(const CChainParams& chainparams) if (mapBlockIndex.count(chainparams.GenesisBlock().GetHash())) return true; - // Only add the genesis block if not reindexing (in which case we reuse the one already on disk) try { CBlock &block = const_cast<CBlock&>(chainparams.GenesisBlock()); // Start new block file diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 5abf32480a..67c6d9ec64 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -619,9 +619,8 @@ UniValue dumpwallet(const JSONRPCRequest& request) throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file"); std::map<CTxDestination, int64_t> mapKeyBirth; - std::set<CKeyID> setKeyPool; + const std::map<CKeyID, int64_t>& mapKeyPool = pwallet->GetAllReserveKeys(); pwallet->GetKeyBirthTimes(mapKeyBirth); - pwallet->GetAllReserveKeys(setKeyPool); // sort time/key pairs std::vector<std::pair<int64_t, CKeyID> > vKeyBirth; @@ -666,7 +665,7 @@ UniValue dumpwallet(const JSONRPCRequest& request) file << strprintf("label=%s", EncodeDumpString(pwallet->mapAddressBook[keyid].name)); } else if (keyid == masterKeyID) { file << "hdmaster=1"; - } else if (setKeyPool.count(keyid)) { + } else if (mapKeyPool.count(keyid)) { file << "reserve=1"; } else if (pwallet->mapKeyMetadata[keyid].hdKeypath == "m") { file << "inactivehdmaster=1"; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2c6d93e1ad..8ef33f248b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2589,6 +2589,7 @@ UniValue resendwallettransactions(const JSONRPCRequest& request) "Immediately re-broadcast unconfirmed wallet transactions to all peers.\n" "Intended only for testing; the wallet code periodically re-broadcasts\n" "automatically.\n" + "Returns an RPC error if -walletbroadcast is set to false.\n" "Returns array of transaction ids that were re-broadcast.\n" ); @@ -2597,6 +2598,10 @@ UniValue resendwallettransactions(const JSONRPCRequest& request) LOCK2(cs_main, pwallet->cs_wallet); + if (!pwallet->GetBroadcastTransactions()) { + throw JSONRPCError(RPC_WALLET_ERROR, "Error: Wallet transaction broadcasting is disabled with -walletbroadcast"); + } + std::vector<uint256> txids = pwallet->ResendWalletTransactionsBefore(GetTime(), g_connman.get()); UniValue result(UniValue::VARR); for (const uint256& txid : txids) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 17b101ffef..c152b9d697 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -12,6 +12,7 @@ #include "consensus/consensus.h" #include "consensus/validation.h" #include "fs.h" +#include "init.h" #include "key.h" #include "keystore.h" #include "validation.h" @@ -80,6 +81,38 @@ std::string COutput::ToString() const return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->tx->vout[i].nValue)); } +class CAffectedKeysVisitor : public boost::static_visitor<void> { +private: + const CKeyStore &keystore; + std::vector<CKeyID> &vKeys; + +public: + CAffectedKeysVisitor(const CKeyStore &keystoreIn, std::vector<CKeyID> &vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {} + + void Process(const CScript &script) { + txnouttype type; + std::vector<CTxDestination> vDest; + int nRequired; + if (ExtractDestinations(script, type, vDest, nRequired)) { + for (const CTxDestination &dest : vDest) + boost::apply_visitor(*this, dest); + } + } + + void operator()(const CKeyID &keyId) { + if (keystore.HaveKey(keyId)) + vKeys.push_back(keyId); + } + + void operator()(const CScriptID &scriptId) { + CScript script; + if (keystore.GetCScript(scriptId, script)) + Process(script); + } + + void operator()(const CNoDestination &none) {} +}; + const CWalletTx* CWallet::GetWalletTx(const uint256& hash) const { LOCK(cs_wallet); @@ -1021,6 +1054,30 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransactionRef& ptx, const CBlockI if (fExisted && !fUpdate) return false; if (fExisted || IsMine(tx) || IsFromMe(tx)) { + /* Check if any keys in the wallet keypool that were supposed to be unused + * have appeared in a new transaction. If so, remove those keys from the keypool. + * This can happen when restoring an old wallet backup that does not contain + * the mostly recently created transactions from newer versions of the wallet. + */ + + // loop though all outputs + for (const CTxOut& txout: tx.vout) { + // extract addresses and check if they match with an unused keypool key + std::vector<CKeyID> vAffected; + CAffectedKeysVisitor(*this, vAffected).Process(txout.scriptPubKey); + for (const CKeyID &keyid : vAffected) { + std::map<CKeyID, int64_t>::const_iterator mi = m_pool_key_to_index.find(keyid); + if (mi != m_pool_key_to_index.end()) { + LogPrintf("%s: Detected a used keypool key, mark all keypool key up to this key as used\n", __func__); + MarkReserveKeysAsUsed(mi->second); + + if (!TopUpKeyPool()) { + LogPrintf("%s: Topping up keypool failed (locked wallet)\n", __func__); + } + } + } + } + CWalletTx wtx(this, ptx); // Get merkle branch if transaction was found in a block @@ -1868,6 +1925,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime, CCon std::vector<uint256> result; LOCK(cs_wallet); + // Sort them in chronological order std::multimap<unsigned int, CWalletTx*> mapSorted; for (std::pair<const uint256, CWalletTx>& item : mapWallet) @@ -3049,6 +3107,7 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet) LOCK(cs_wallet); setInternalKeyPool.clear(); setExternalKeyPool.clear(); + m_pool_key_to_index.clear(); // Note: can't top-up keypool here, because wallet is locked. // User will be prompted to unlock wallet the next operation // that requires a new key. @@ -3078,6 +3137,7 @@ DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256 { setInternalKeyPool.clear(); setExternalKeyPool.clear(); + m_pool_key_to_index.clear(); // Note: can't top-up keypool here, because wallet is locked. // User will be prompted to unlock wallet the next operation // that requires a new key. @@ -3104,6 +3164,7 @@ DBErrors CWallet::ZapWalletTx(std::vector<CWalletTx>& vWtx) LOCK(cs_wallet); setInternalKeyPool.clear(); setExternalKeyPool.clear(); + m_pool_key_to_index.clear(); // Note: can't top-up keypool here, because wallet is locked. // User will be prompted to unlock wallet the next operation // that requires a new key. @@ -3198,6 +3259,8 @@ bool CWallet::NewKeyPool() } setExternalKeyPool.clear(); + m_pool_key_to_index.clear(); + if (!TopUpKeyPool()) { return false; } @@ -3212,6 +3275,25 @@ size_t CWallet::KeypoolCountExternalKeys() return setExternalKeyPool.size(); } +void CWallet::LoadKeyPool(int64_t nIndex, const CKeyPool &keypool) +{ + AssertLockHeld(cs_wallet); + if (keypool.fInternal) { + setInternalKeyPool.insert(nIndex); + } else { + setExternalKeyPool.insert(nIndex); + } + m_max_keypool_index = std::max(m_max_keypool_index, nIndex); + m_pool_key_to_index[keypool.vchPubKey.GetID()] = nIndex; + + // If no metadata exists yet, create a default with the pool key's + // creation time. Note that this may be overwritten by actually + // stored metadata for that key later, which is fine. + CKeyID keyid = keypool.vchPubKey.GetID(); + if (mapKeyMetadata.count(keyid) == 0) + mapKeyMetadata[keyid] = CKeyMetadata(keypool.nTime); +} + bool CWallet::TopUpKeyPool(unsigned int kpSize) { { @@ -3248,7 +3330,8 @@ bool CWallet::TopUpKeyPool(unsigned int kpSize) assert(m_max_keypool_index < std::numeric_limits<int64_t>::max()); // How in the hell did you use so many keys? int64_t index = ++m_max_keypool_index; - if (!walletdb.WritePool(index, CKeyPool(GenerateNewKey(walletdb, internal), internal))) { + CPubKey pubkey(GenerateNewKey(walletdb, internal)); + if (!walletdb.WritePool(index, CKeyPool(pubkey, internal))) { throw std::runtime_error(std::string(__func__) + ": writing generated key failed"); } @@ -3257,6 +3340,7 @@ bool CWallet::TopUpKeyPool(unsigned int kpSize) } else { setExternalKeyPool.insert(index); } + m_pool_key_to_index[pubkey.GetID()] = index; } if (missingInternal + missingExternal > 0) { LogPrintf("keypool added %d keys (%d internal), size=%u (%u internal)\n", missingInternal + missingExternal, missingInternal, setInternalKeyPool.size() + setExternalKeyPool.size(), setInternalKeyPool.size()); @@ -3298,6 +3382,7 @@ void CWallet::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool, bool fRe } assert(keypool.vchPubKey.IsValid()); + m_pool_key_to_index.erase(keypool.vchPubKey.GetID()); LogPrintf("keypool reserve %d\n", nIndex); } } @@ -3310,7 +3395,7 @@ void CWallet::KeepKey(int64_t nIndex) LogPrintf("keypool keep %d\n", nIndex); } -void CWallet::ReturnKey(int64_t nIndex, bool fInternal) +void CWallet::ReturnKey(int64_t nIndex, bool fInternal, const CPubKey& pubkey) { // Return to key pool { @@ -3320,6 +3405,7 @@ void CWallet::ReturnKey(int64_t nIndex, bool fInternal) } else { setExternalKeyPool.insert(nIndex); } + m_pool_key_to_index[pubkey.GetID()] = nIndex; } LogPrintf("keypool return %d\n", nIndex); } @@ -3549,41 +3635,39 @@ void CReserveKey::KeepKey() void CReserveKey::ReturnKey() { if (nIndex != -1) { - pwallet->ReturnKey(nIndex, fInternal); + pwallet->ReturnKey(nIndex, fInternal, vchPubKey); } nIndex = -1; vchPubKey = CPubKey(); } -static void LoadReserveKeysToSet(std::set<CKeyID>& setAddress, const std::set<int64_t>& setKeyPool, CWalletDB& walletdb) { - for (const int64_t& id : setKeyPool) - { - CKeyPool keypool; - if (!walletdb.ReadPool(id, keypool)) - throw std::runtime_error(std::string(__func__) + ": read failed"); - assert(keypool.vchPubKey.IsValid()); - CKeyID keyID = keypool.vchPubKey.GetID(); - setAddress.insert(keyID); - } -} - -void CWallet::GetAllReserveKeys(std::set<CKeyID>& setAddress) const +void CWallet::MarkReserveKeysAsUsed(int64_t keypool_id) { - setAddress.clear(); + AssertLockHeld(cs_wallet); + bool internal = setInternalKeyPool.count(keypool_id); + if (!internal) assert(setExternalKeyPool.count(keypool_id)); + std::set<int64_t> *setKeyPool = internal ? &setInternalKeyPool : &setExternalKeyPool; + auto it = setKeyPool->begin(); CWalletDB walletdb(*dbw); + while (it != std::end(*setKeyPool)) { + const int64_t& index = *(it); + if (index > keypool_id) break; // set*KeyPool is ordered - LOCK2(cs_main, cs_wallet); - LoadReserveKeysToSet(setAddress, setInternalKeyPool, walletdb); - LoadReserveKeysToSet(setAddress, setExternalKeyPool, walletdb); - - for (const CKeyID& keyID : setAddress) { - if (!HaveKey(keyID)) { - throw std::runtime_error(std::string(__func__) + ": unknown key in key pool"); + CKeyPool keypool; + if (walletdb.ReadPool(index, keypool)) { //TODO: This should be unnecessary + m_pool_key_to_index.erase(keypool.vchPubKey.GetID()); } + walletdb.ErasePool(index); + it = setKeyPool->erase(it); } } +bool CWallet::HasUnusedKeys(int min_keys) const +{ + return setExternalKeyPool.size() >= min_keys && (setInternalKeyPool.size() >= min_keys || !CanSupportFeature(FEATURE_HD_SPLIT)); +} + void CWallet::GetScriptForMining(std::shared_ptr<CReserveScript> &script) { std::shared_ptr<CReserveKey> rKey = std::make_shared<CReserveKey>(this); @@ -3633,38 +3717,6 @@ void CWallet::ListLockedCoins(std::vector<COutPoint>& vOutpts) const /** @} */ // end of Actions -class CAffectedKeysVisitor : public boost::static_visitor<void> { -private: - const CKeyStore &keystore; - std::vector<CKeyID> &vKeys; - -public: - CAffectedKeysVisitor(const CKeyStore &keystoreIn, std::vector<CKeyID> &vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {} - - void Process(const CScript &script) { - txnouttype type; - std::vector<CTxDestination> vDest; - int nRequired; - if (ExtractDestinations(script, type, vDest, nRequired)) { - for (const CTxDestination &dest : vDest) - boost::apply_visitor(*this, dest); - } - } - - void operator()(const CKeyID &keyId) { - if (keystore.HaveKey(keyId)) - vKeys.push_back(keyId); - } - - void operator()(const CScriptID &scriptId) { - CScript script; - if (keystore.GetCScript(scriptId, script)) - Process(script); - } - - void operator()(const CNoDestination &none) {} -}; - void CWallet::GetKeyBirthTimes(std::map<CTxDestination, int64_t> &mapKeyBirth) const { AssertLockHeld(cs_wallet); // mapKeyMetadata mapKeyBirth.clear(); @@ -3989,6 +4041,9 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile) RegisterValidationInterface(walletInstance); + // Try to top up keypool. No-op if the wallet is locked. + walletInstance->TopUpKeyPool(); + CBlockIndex *pindexRescan = chainActive.Genesis(); if (!GetBoolArg("-rescan", false)) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index a75f1b3fe5..f97a99d82a 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -470,6 +470,7 @@ public: int64_t GetTxTime() const; int GetRequestCount() const; + // RelayWalletTransaction may only be called if fBroadcastTransactions! bool RelayWalletTransaction(CConnman* connman); std::set<uint256> GetConflicts() const; @@ -704,6 +705,7 @@ private: std::set<int64_t> setInternalKeyPool; std::set<int64_t> setExternalKeyPool; int64_t m_max_keypool_index; + std::map<CKeyID, int64_t> m_pool_key_to_index; int64_t nTimeFirstKey; @@ -746,22 +748,7 @@ public: } } - void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool) - { - if (keypool.fInternal) { - setInternalKeyPool.insert(nIndex); - } else { - setExternalKeyPool.insert(nIndex); - } - m_max_keypool_index = std::max(m_max_keypool_index, nIndex); - - // If no metadata exists yet, create a default with the pool key's - // creation time. Note that this may be overwritten by actually - // stored metadata for that key later, which is fine. - CKeyID keyid = keypool.vchPubKey.GetID(); - if (mapKeyMetadata.count(keyid) == 0) - mapKeyMetadata[keyid] = CKeyMetadata(keypool.nTime); - } + void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool); // Map from Key ID (for regular keys) or Script ID (for watch-only keys) to // key metadata. @@ -827,7 +814,7 @@ public: const CWalletTx* GetWalletTx(const uint256& hash) const; //! check whether we are allowed to upgrade (or already support) to the named feature - bool CanSupportFeature(enum WalletFeature wf) { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; } + bool CanSupportFeature(enum WalletFeature wf) const { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; } /** * populate vCoins with vector of available COutputs. @@ -937,6 +924,7 @@ public: CBlockIndex* ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false); void ReacceptWalletTransactions(); void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) override; + // ResendWalletTransactionsBefore may only be called if fBroadcastTransactions! std::vector<uint256> ResendWalletTransactionsBefore(int64_t nTime, CConnman* connman); CAmount GetBalance() const; CAmount GetUnconfirmedBalance() const; @@ -988,10 +976,16 @@ public: bool TopUpKeyPool(unsigned int kpSize = 0); void ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool, bool fRequestedInternal); void KeepKey(int64_t nIndex); - void ReturnKey(int64_t nIndex, bool fInternal); + void ReturnKey(int64_t nIndex, bool fInternal, const CPubKey& pubkey); bool GetKeyFromPool(CPubKey &key, bool internal = false); int64_t GetOldestKeyPoolTime(); - void GetAllReserveKeys(std::set<CKeyID>& setAddress) const; + /** + * Marks all keys in the keypool up to and including reserve_key as used. + */ + void MarkReserveKeysAsUsed(int64_t keypool_id); + const std::map<CKeyID, int64_t>& GetAllReserveKeys() const { return m_pool_key_to_index; } + /** Does the wallet have at least min_keys in the keypool? */ + bool HasUnusedKeys(int min_keys) const; std::set< std::set<CTxDestination> > GetAddressGroupings(); std::map<CTxDestination, CAmount> GetAddressBalances(); diff --git a/test/functional/README.md b/test/functional/README.md index 96fe0becce..44efda33d3 100644 --- a/test/functional/README.md +++ b/test/functional/README.md @@ -90,7 +90,7 @@ on nodes 2 and up. - Implement a (generator) function called `get_tests()` which yields `TestInstance`s. Each `TestInstance` consists of: - - a list of `[object, outcome, hash]` entries + - A list of `[object, outcome, hash]` entries * `object` is a `CBlock`, `CTransaction`, or `CBlockHeader`. `CBlock`'s and `CTransaction`'s are tested for acceptance. `CBlockHeader`s can be used so that the test runner can deliver diff --git a/test/functional/bip65-cltv-p2p.py b/test/functional/bip65-cltv-p2p.py index bb83042f35..7e5e4cf682 100755 --- a/test/functional/bip65-cltv-p2p.py +++ b/test/functional/bip65-cltv-p2p.py @@ -4,173 +4,162 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test BIP65 (CHECKLOCKTIMEVERIFY). -Connect to a single node. -Mine 2 (version 3) blocks (save the coinbases for later). -Generate 98 more version 3 blocks, verify the node accepts. -Mine 749 version 4 blocks, verify the node accepts. -Check that the new CLTV rules are not enforced on the 750th version 4 block. -Check that the new CLTV rules are enforced on the 751st version 4 block. -Mine 199 new version blocks. -Mine 1 old-version block. -Mine 1 new version block. -Mine 1 old version block, see that the node rejects. +Test that the CHECKLOCKTIMEVERIFY soft-fork activates at (regtest) block height +1351. """ -from test_framework.test_framework import ComparisonTestFramework +from test_framework.test_framework import BitcoinTestFramework from test_framework.util import * -from test_framework.mininode import CTransaction, NetworkThread +from test_framework.mininode import * from test_framework.blocktools import create_coinbase, create_block -from test_framework.comptool import TestInstance, TestManager -from test_framework.script import CScript, OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP +from test_framework.script import CScript, OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP, CScriptNum from io import BytesIO -import time + +CLTV_HEIGHT = 1351 + +# Reject codes that we might receive in this test +REJECT_INVALID = 16 +REJECT_OBSOLETE = 17 +REJECT_NONSTANDARD = 64 def cltv_invalidate(tx): '''Modify the signature in vin 0 of the tx to fail CLTV Prepends -1 CLTV DROP in the scriptSig itself. + + TODO: test more ways that transactions using CLTV could be invalid (eg + locktime requirements fail, sequence time requirements fail, etc). ''' tx.vin[0].scriptSig = CScript([OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP] + list(CScript(tx.vin[0].scriptSig))) - -class BIP65Test(ComparisonTestFramework): +def cltv_validate(node, tx, height): + '''Modify the signature in vin 0 of the tx to pass CLTV + Prepends <height> CLTV DROP in the scriptSig, and sets + the locktime to height''' + tx.vin[0].nSequence = 0 + tx.nLockTime = height + + # Need to re-sign, since nSequence and nLockTime changed + signed_result = node.signrawtransaction(ToHex(tx)) + new_tx = CTransaction() + new_tx.deserialize(BytesIO(hex_str_to_bytes(signed_result['hex']))) + + new_tx.vin[0].scriptSig = CScript([CScriptNum(height), OP_CHECKLOCKTIMEVERIFY, OP_DROP] + + list(CScript(new_tx.vin[0].scriptSig))) + return new_tx + +def create_transaction(node, coinbase, to_address, amount): + from_txid = node.getblock(coinbase)['tx'][0] + inputs = [{ "txid" : from_txid, "vout" : 0}] + outputs = { to_address : amount } + rawtx = node.createrawtransaction(inputs, outputs) + signresult = node.signrawtransaction(rawtx) + tx = CTransaction() + tx.deserialize(BytesIO(hex_str_to_bytes(signresult['hex']))) + return tx + +class BIP65Test(BitcoinTestFramework): def __init__(self): super().__init__() self.num_nodes = 1 - self.extra_args = [['-whitelist=127.0.0.1', '-blockversion=3']] + self.extra_args = [['-promiscuousmempoolflags=1', '-whitelist=127.0.0.1']] + self.setup_clean_chain = True def run_test(self): - test = TestManager(self, self.options.tmpdir) - test.add_all_connections(self.nodes) + node0 = NodeConnCB() + connections = [] + connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], node0)) + node0.add_connection(connections[0]) + NetworkThread().start() # Start up network handling in another thread - test.run() - - def create_transaction(self, node, coinbase, to_address, amount): - from_txid = node.getblock(coinbase)['tx'][0] - inputs = [{ "txid" : from_txid, "vout" : 0}] - outputs = { to_address : amount } - rawtx = node.createrawtransaction(inputs, outputs) - signresult = node.signrawtransaction(rawtx) - tx = CTransaction() - f = BytesIO(hex_str_to_bytes(signresult['hex'])) - tx.deserialize(f) - return tx - - def get_tests(self): - - self.coinbase_blocks = self.nodes[0].generate(2) - height = 3 # height of the next block to build - self.tip = int("0x" + self.nodes[0].getbestblockhash(), 0) + + # wait_for_verack ensures that the P2P connection is fully up. + node0.wait_for_verack() + + self.log.info("Mining %d blocks", CLTV_HEIGHT - 2) + self.coinbase_blocks = self.nodes[0].generate(CLTV_HEIGHT - 2) self.nodeaddress = self.nodes[0].getnewaddress() - self.last_block_time = int(time.time()) - - ''' 398 more version 3 blocks ''' - test_blocks = [] - for i in range(398): - block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1) - block.nVersion = 3 - block.rehash() - block.solve() - test_blocks.append([block, True]) - self.last_block_time += 1 - self.tip = block.sha256 - height += 1 - yield TestInstance(test_blocks, sync_every_block=False) - - ''' Mine 749 version 4 blocks ''' - test_blocks = [] - for i in range(749): - block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1) - block.nVersion = 4 - block.rehash() - block.solve() - test_blocks.append([block, True]) - self.last_block_time += 1 - self.tip = block.sha256 - height += 1 - yield TestInstance(test_blocks, sync_every_block=False) - - ''' - Check that the new CLTV rules are not enforced in the 750th - version 3 block. - ''' - spendtx = self.create_transaction(self.nodes[0], - self.coinbase_blocks[0], self.nodeaddress, 1.0) + + self.log.info("Test that an invalid-according-to-CLTV transaction can still appear in a block") + + spendtx = create_transaction(self.nodes[0], self.coinbase_blocks[0], + self.nodeaddress, 1.0) cltv_invalidate(spendtx) spendtx.rehash() - block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1) - block.nVersion = 4 + tip = self.nodes[0].getbestblockhash() + block_time = self.nodes[0].getblockheader(tip)['mediantime'] + 1 + block = create_block(int(tip, 16), create_coinbase(CLTV_HEIGHT - 1), block_time) + block.nVersion = 3 block.vtx.append(spendtx) block.hashMerkleRoot = block.calc_merkle_root() - block.rehash() block.solve() - self.last_block_time += 1 - self.tip = block.sha256 - height += 1 - yield TestInstance([[block, True]]) - - ''' Mine 199 new version blocks on last valid tip ''' - test_blocks = [] - for i in range(199): - block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1) - block.nVersion = 4 - block.rehash() - block.solve() - test_blocks.append([block, True]) - self.last_block_time += 1 - self.tip = block.sha256 - height += 1 - yield TestInstance(test_blocks, sync_every_block=False) - - ''' Mine 1 old version block ''' - block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1) + node0.send_and_ping(msg_block(block)) + assert_equal(self.nodes[0].getbestblockhash(), block.hash) + + self.log.info("Test that blocks must now be at least version 4") + tip = block.sha256 + block_time += 1 + block = create_block(tip, create_coinbase(CLTV_HEIGHT), block_time) block.nVersion = 3 - block.rehash() block.solve() - self.last_block_time += 1 - self.tip = block.sha256 - height += 1 - yield TestInstance([[block, True]]) + node0.send_and_ping(msg_block(block)) + assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip) - ''' Mine 1 new version block ''' - block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1) + assert wait_until(lambda: "reject" in node0.last_message.keys()) + with mininode_lock: + assert_equal(node0.last_message["reject"].code, REJECT_OBSOLETE) + assert_equal(node0.last_message["reject"].reason, b'bad-version(0x00000003)') + assert_equal(node0.last_message["reject"].data, block.sha256) + del node0.last_message["reject"] + + self.log.info("Test that invalid-according-to-cltv transactions cannot appear in a block") block.nVersion = 4 - block.rehash() - block.solve() - self.last_block_time += 1 - self.tip = block.sha256 - height += 1 - yield TestInstance([[block, True]]) - - ''' - Check that the new CLTV rules are enforced in the 951st version 4 - block. - ''' - spendtx = self.create_transaction(self.nodes[0], - self.coinbase_blocks[1], self.nodeaddress, 1.0) + + spendtx = create_transaction(self.nodes[0], self.coinbase_blocks[1], + self.nodeaddress, 1.0) cltv_invalidate(spendtx) spendtx.rehash() - block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1) - block.nVersion = 4 + # First we show that this tx is valid except for CLTV by getting it + # accepted to the mempool (which we can achieve with + # -promiscuousmempoolflags). + node0.send_and_ping(msg_tx(spendtx)) + assert spendtx.hash in self.nodes[0].getrawmempool() + + # Now we verify that a block with this transaction is invalid. block.vtx.append(spendtx) block.hashMerkleRoot = block.calc_merkle_root() - block.rehash() block.solve() - self.last_block_time += 1 - yield TestInstance([[block, False]]) - ''' Mine 1 old version block, should be invalid ''' - block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1) - block.nVersion = 3 - block.rehash() + node0.send_and_ping(msg_block(block)) + assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip) + + assert wait_until (lambda: "reject" in node0.last_message.keys()) + with mininode_lock: + assert node0.last_message["reject"].code in [REJECT_INVALID, REJECT_NONSTANDARD] + assert_equal(node0.last_message["reject"].data, block.sha256) + if node0.last_message["reject"].code == REJECT_INVALID: + # Generic rejection when a block is invalid + assert_equal(node0.last_message["reject"].reason, b'block-validation-failed') + else: + assert b'Negative locktime' in node0.last_message["reject"].reason + + self.log.info("Test that a version 4 block with a valid-according-to-CLTV transaction is accepted") + spendtx = cltv_validate(self.nodes[0], spendtx, CLTV_HEIGHT - 1) + spendtx.rehash() + + block.vtx.pop(1) + block.vtx.append(spendtx) + block.hashMerkleRoot = block.calc_merkle_root() block.solve() - self.last_block_time += 1 - yield TestInstance([[block, False]]) + + node0.send_and_ping(msg_block(block)) + assert_equal(int(self.nodes[0].getbestblockhash(), 16), block.sha256) + if __name__ == '__main__': BIP65Test().main() diff --git a/test/functional/bip65-cltv.py b/test/functional/bip65-cltv.py deleted file mode 100755 index ddf932c746..0000000000 --- a/test/functional/bip65-cltv.py +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (c) 2015-2016 The Bitcoin Core developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. -"""Test the CHECKLOCKTIMEVERIFY (BIP65) soft-fork logic.""" - -from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import * - -class BIP65Test(BitcoinTestFramework): - def __init__(self): - super().__init__() - self.num_nodes = 3 - self.setup_clean_chain = False - self.extra_args = [[], ["-blockversion=3"], ["-blockversion=4"]] - - def setup_network(self): - self.setup_nodes() - connect_nodes(self.nodes[1], 0) - connect_nodes(self.nodes[2], 0) - self.sync_all() - - def run_test(self): - cnt = self.nodes[0].getblockcount() - - # Mine some old-version blocks - self.nodes[1].generate(200) - cnt += 100 - self.sync_all() - if (self.nodes[0].getblockcount() != cnt + 100): - raise AssertionError("Failed to mine 100 version=3 blocks") - - # Mine 750 new-version blocks - for i in range(15): - self.nodes[2].generate(50) - self.sync_all() - if (self.nodes[0].getblockcount() != cnt + 850): - raise AssertionError("Failed to mine 750 version=4 blocks") - - # TODO: check that new CHECKLOCKTIMEVERIFY rules are not enforced - - # Mine 1 new-version block - self.nodes[2].generate(1) - self.sync_all() - if (self.nodes[0].getblockcount() != cnt + 851): - raise AssertionError("Failed to mine a version=4 blocks") - - # TODO: check that new CHECKLOCKTIMEVERIFY rules are enforced - - # Mine 198 new-version blocks - for i in range(2): - self.nodes[2].generate(99) - self.sync_all() - if (self.nodes[0].getblockcount() != cnt + 1049): - raise AssertionError("Failed to mine 198 version=4 blocks") - - # Mine 1 old-version block - self.nodes[1].generate(1) - self.sync_all() - if (self.nodes[0].getblockcount() != cnt + 1050): - raise AssertionError("Failed to mine a version=3 block after 949 version=4 blocks") - - # Mine 1 new-version blocks - self.nodes[2].generate(1) - self.sync_all() - if (self.nodes[0].getblockcount() != cnt + 1051): - raise AssertionError("Failed to mine a version=4 block") - - # Mine 1 old-version blocks. This should fail - assert_raises_jsonrpc(-1,"CreateNewBlock: TestBlockValidity failed: bad-version(0x00000003)", self.nodes[1].generate, 1) - self.sync_all() - if (self.nodes[0].getblockcount() != cnt + 1051): - raise AssertionError("Accepted a version=3 block after 950 version=4 blocks") - - # Mine 1 new-version blocks - self.nodes[2].generate(1) - self.sync_all() - if (self.nodes[0].getblockcount() != cnt + 1052): - raise AssertionError("Failed to mine a version=4 block") - -if __name__ == '__main__': - BIP65Test().main() diff --git a/test/functional/bipdersig-p2p.py b/test/functional/bipdersig-p2p.py index 31c7ebba90..38a9009544 100755 --- a/test/functional/bipdersig-p2p.py +++ b/test/functional/bipdersig-p2p.py @@ -4,28 +4,24 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test BIP66 (DER SIG). -Connect to a single node. -Mine 2 (version 2) blocks (save the coinbases for later). -Generate 98 more version 2 blocks, verify the node accepts. -Mine 749 version 3 blocks, verify the node accepts. -Check that the new DERSIG rules are not enforced on the 750th version 3 block. -Check that the new DERSIG rules are enforced on the 751st version 3 block. -Mine 199 new version blocks. -Mine 1 old-version block. -Mine 1 new version block. -Mine 1 old version block, see that the node rejects. +Test that the DERSIG soft-fork activates at (regtest) height 1251. """ -from test_framework.test_framework import ComparisonTestFramework +from test_framework.test_framework import BitcoinTestFramework from test_framework.util import * -from test_framework.mininode import CTransaction, NetworkThread +from test_framework.mininode import * from test_framework.blocktools import create_coinbase, create_block -from test_framework.comptool import TestInstance, TestManager from test_framework.script import CScript from io import BytesIO -import time -# A canonical signature consists of: +DERSIG_HEIGHT = 1251 + +# Reject codes that we might receive in this test +REJECT_INVALID = 16 +REJECT_OBSOLETE = 17 +REJECT_NONSTANDARD = 64 + +# A canonical signature consists of: # <30> <total len> <02> <len R> <R> <02> <len S> <S> <hashtype> def unDERify(tx): """ @@ -40,143 +36,122 @@ def unDERify(tx): else: newscript.append(i) tx.vin[0].scriptSig = CScript(newscript) - -class BIP66Test(ComparisonTestFramework): + +def create_transaction(node, coinbase, to_address, amount): + from_txid = node.getblock(coinbase)['tx'][0] + inputs = [{ "txid" : from_txid, "vout" : 0}] + outputs = { to_address : amount } + rawtx = node.createrawtransaction(inputs, outputs) + signresult = node.signrawtransaction(rawtx) + tx = CTransaction() + tx.deserialize(BytesIO(hex_str_to_bytes(signresult['hex']))) + return tx + +class BIP66Test(BitcoinTestFramework): def __init__(self): super().__init__() self.num_nodes = 1 + self.extra_args = [['-promiscuousmempoolflags=1', '-whitelist=127.0.0.1']] + self.setup_clean_chain = True def run_test(self): - test = TestManager(self, self.options.tmpdir) - test.add_all_connections(self.nodes) + node0 = NodeConnCB() + connections = [] + connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], node0)) + node0.add_connection(connections[0]) NetworkThread().start() # Start up network handling in another thread - test.run() - - def create_transaction(self, node, coinbase, to_address, amount): - from_txid = node.getblock(coinbase)['tx'][0] - inputs = [{ "txid" : from_txid, "vout" : 0}] - outputs = { to_address : amount } - rawtx = node.createrawtransaction(inputs, outputs) - signresult = node.signrawtransaction(rawtx) - tx = CTransaction() - f = BytesIO(hex_str_to_bytes(signresult['hex'])) - tx.deserialize(f) - return tx - - def get_tests(self): - - self.coinbase_blocks = self.nodes[0].generate(2) - height = 3 # height of the next block to build - self.tip = int("0x" + self.nodes[0].getbestblockhash(), 0) + + # wait_for_verack ensures that the P2P connection is fully up. + node0.wait_for_verack() + + self.log.info("Mining %d blocks", DERSIG_HEIGHT - 2) + self.coinbase_blocks = self.nodes[0].generate(DERSIG_HEIGHT - 2) self.nodeaddress = self.nodes[0].getnewaddress() - self.last_block_time = int(time.time()) - - ''' 298 more version 2 blocks ''' - test_blocks = [] - for i in range(298): - block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1) - block.nVersion = 2 - block.rehash() - block.solve() - test_blocks.append([block, True]) - self.last_block_time += 1 - self.tip = block.sha256 - height += 1 - yield TestInstance(test_blocks, sync_every_block=False) - - ''' Mine 749 version 3 blocks ''' - test_blocks = [] - for i in range(749): - block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1) - block.nVersion = 3 - block.rehash() - block.solve() - test_blocks.append([block, True]) - self.last_block_time += 1 - self.tip = block.sha256 - height += 1 - yield TestInstance(test_blocks, sync_every_block=False) - - ''' - Check that the new DERSIG rules are not enforced in the 750th - version 3 block. - ''' - spendtx = self.create_transaction(self.nodes[0], - self.coinbase_blocks[0], self.nodeaddress, 1.0) + + self.log.info("Test that a transaction with non-DER signature can still appear in a block") + + spendtx = create_transaction(self.nodes[0], self.coinbase_blocks[0], + self.nodeaddress, 1.0) unDERify(spendtx) spendtx.rehash() - block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1) - block.nVersion = 3 + tip = self.nodes[0].getbestblockhash() + block_time = self.nodes[0].getblockheader(tip)['mediantime'] + 1 + block = create_block(int(tip, 16), create_coinbase(DERSIG_HEIGHT - 1), block_time) + block.nVersion = 2 block.vtx.append(spendtx) block.hashMerkleRoot = block.calc_merkle_root() block.rehash() block.solve() - self.last_block_time += 1 - self.tip = block.sha256 - height += 1 - yield TestInstance([[block, True]]) - - ''' Mine 199 new version blocks on last valid tip ''' - test_blocks = [] - for i in range(199): - block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1) - block.nVersion = 3 - block.rehash() - block.solve() - test_blocks.append([block, True]) - self.last_block_time += 1 - self.tip = block.sha256 - height += 1 - yield TestInstance(test_blocks, sync_every_block=False) - - ''' Mine 1 old version block ''' - block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1) + node0.send_and_ping(msg_block(block)) + assert_equal(self.nodes[0].getbestblockhash(), block.hash) + + self.log.info("Test that blocks must now be at least version 3") + tip = block.sha256 + block_time += 1 + block = create_block(tip, create_coinbase(DERSIG_HEIGHT), block_time) block.nVersion = 2 block.rehash() block.solve() - self.last_block_time += 1 - self.tip = block.sha256 - height += 1 - yield TestInstance([[block, True]]) + node0.send_and_ping(msg_block(block)) + assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip) - ''' Mine 1 new version block ''' - block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1) + assert wait_until(lambda: "reject" in node0.last_message.keys()) + with mininode_lock: + assert_equal(node0.last_message["reject"].code, REJECT_OBSOLETE) + assert_equal(node0.last_message["reject"].reason, b'bad-version(0x00000002)') + assert_equal(node0.last_message["reject"].data, block.sha256) + del node0.last_message["reject"] + + self.log.info("Test that transactions with non-DER signatures cannot appear in a block") block.nVersion = 3 - block.rehash() - block.solve() - self.last_block_time += 1 - self.tip = block.sha256 - height += 1 - yield TestInstance([[block, True]]) - - ''' - Check that the new DERSIG rules are enforced in the 951st version 3 - block. - ''' - spendtx = self.create_transaction(self.nodes[0], - self.coinbase_blocks[1], self.nodeaddress, 1.0) + + spendtx = create_transaction(self.nodes[0], self.coinbase_blocks[1], + self.nodeaddress, 1.0) unDERify(spendtx) spendtx.rehash() - block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1) - block.nVersion = 3 + # First we show that this tx is valid except for DERSIG by getting it + # accepted to the mempool (which we can achieve with + # -promiscuousmempoolflags). + node0.send_and_ping(msg_tx(spendtx)) + assert spendtx.hash in self.nodes[0].getrawmempool() + + # Now we verify that a block with this transaction is invalid. block.vtx.append(spendtx) block.hashMerkleRoot = block.calc_merkle_root() block.rehash() block.solve() - self.last_block_time += 1 - yield TestInstance([[block, False]]) - ''' Mine 1 old version block, should be invalid ''' - block = create_block(self.tip, create_coinbase(height), self.last_block_time + 1) - block.nVersion = 2 + node0.send_and_ping(msg_block(block)) + assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip) + + assert wait_until (lambda: "reject" in node0.last_message.keys()) + with mininode_lock: + # We can receive different reject messages depending on whether + # bitcoind is running with multiple script check threads. If script + # check threads are not in use, then transaction script validation + # happens sequentially, and bitcoind produces more specific reject + # reasons. + assert node0.last_message["reject"].code in [REJECT_INVALID, REJECT_NONSTANDARD] + assert_equal(node0.last_message["reject"].data, block.sha256) + if node0.last_message["reject"].code == REJECT_INVALID: + # Generic rejection when a block is invalid + assert_equal(node0.last_message["reject"].reason, b'block-validation-failed') + else: + assert b'Non-canonical DER signature' in node0.last_message["reject"].reason + + self.log.info("Test that a version 3 block with a DERSIG-compliant transaction is accepted") + block.vtx[1] = create_transaction(self.nodes[0], + self.coinbase_blocks[1], self.nodeaddress, 1.0) + block.hashMerkleRoot = block.calc_merkle_root() block.rehash() block.solve() - self.last_block_time += 1 - yield TestInstance([[block, False]]) + + node0.send_and_ping(msg_block(block)) + assert_equal(int(self.nodes[0].getbestblockhash(), 16), block.sha256) if __name__ == '__main__': BIP66Test().main() diff --git a/test/functional/bipdersig.py b/test/functional/bipdersig.py deleted file mode 100755 index 41f88fb664..0000000000 --- a/test/functional/bipdersig.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (c) 2014-2016 The Bitcoin Core developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. -"""Test the BIP66 changeover logic.""" - -from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import * - -class BIP66Test(BitcoinTestFramework): - def __init__(self): - super().__init__() - self.num_nodes = 3 - self.setup_clean_chain = False - self.extra_args = [[], ["-blockversion=2"], ["-blockversion=3"]] - - def setup_network(self): - self.setup_nodes() - connect_nodes(self.nodes[1], 0) - connect_nodes(self.nodes[2], 0) - self.sync_all() - - def run_test(self): - cnt = self.nodes[0].getblockcount() - - # Mine some old-version blocks - self.nodes[1].generate(100) - self.sync_all() - if (self.nodes[0].getblockcount() != cnt + 100): - raise AssertionError("Failed to mine 100 version=2 blocks") - - # Mine 750 new-version blocks - for i in range(15): - self.nodes[2].generate(50) - self.sync_all() - if (self.nodes[0].getblockcount() != cnt + 850): - raise AssertionError("Failed to mine 750 version=3 blocks") - - # TODO: check that new DERSIG rules are not enforced - - # Mine 1 new-version block - self.nodes[2].generate(1) - self.sync_all() - if (self.nodes[0].getblockcount() != cnt + 851): - raise AssertionError("Failed to mine a version=3 blocks") - - # TODO: check that new DERSIG rules are enforced - - # Mine 198 new-version blocks - for i in range(2): - self.nodes[2].generate(99) - self.sync_all() - if (self.nodes[0].getblockcount() != cnt + 1049): - raise AssertionError("Failed to mine 198 version=3 blocks") - - # Mine 1 old-version block - self.nodes[1].generate(1) - self.sync_all() - if (self.nodes[0].getblockcount() != cnt + 1050): - raise AssertionError("Failed to mine a version=2 block after 949 version=3 blocks") - - # Mine 1 new-version blocks - self.nodes[2].generate(1) - self.sync_all() - if (self.nodes[0].getblockcount() != cnt + 1051): - raise AssertionError("Failed to mine a version=3 block") - - # Mine 1 old-version blocks. This should fail - assert_raises_jsonrpc(-1, "CreateNewBlock: TestBlockValidity failed: bad-version(0x00000002)", self.nodes[1].generate, 1) - self.sync_all() - if (self.nodes[0].getblockcount() != cnt + 1051): - raise AssertionError("Accepted a version=2 block after 950 version=3 blocks") - - # Mine 1 new-version blocks - self.nodes[2].generate(1) - self.sync_all() - if (self.nodes[0].getblockcount() != cnt + 1052): - raise AssertionError("Failed to mine a version=3 block") - -if __name__ == '__main__': - BIP66Test().main() diff --git a/test/functional/example_test.py b/test/functional/example_test.py index 1ba5f756cd..7709524f23 100755 --- a/test/functional/example_test.py +++ b/test/functional/example_test.py @@ -58,6 +58,10 @@ class BaseNode(NodeConnCB): message.block.calc_sha256() self.block_receive_map[message.block.sha256] += 1 + def on_inv(self, conn, message): + """Override the standard on_inv callback""" + pass + def custom_function(): """Do some custom behaviour @@ -198,10 +202,10 @@ class ExampleTest(BitcoinTestFramework): self.log.info("Wait for node2 reach current tip. Test that it has propogated all the blocks to us") + getdata_request = msg_getdata() for block in blocks: - getdata_request = msg_getdata() getdata_request.inv.append(CInv(2, block)) - node2.send_message(getdata_request) + node2.send_message(getdata_request) # wait_until() will loop until a predicate condition is met. Use it to test properties of the # NodeConnCB objects. diff --git a/test/functional/keypool-topup.py b/test/functional/keypool-topup.py new file mode 100755 index 0000000000..0e0c0ea74b --- /dev/null +++ b/test/functional/keypool-topup.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 +# Copyright (c) 2017 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +"""Test HD Wallet keypool restore function. + +Two nodes. Node1 is under test. Node0 is providing transactions and generating blocks. + +- Start node1, shutdown and backup wallet. +- Generate 110 keys (enough to drain the keypool). Store key 90 (in the initial keypool) and key 110 (beyond the initial keypool). Send funds to key 90 and key 110. +- Stop node1, clear the datadir, move wallet file back into the datadir and restart node1. +- connect node1 to node0. Verify that they sync and node1 receives its funds.""" +import shutil + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import ( + assert_equal, + connect_nodes_bi, + sync_blocks, +) + +class KeypoolRestoreTest(BitcoinTestFramework): + def __init__(self): + super().__init__() + self.setup_clean_chain = True + self.num_nodes = 2 + self.extra_args = [['-usehd=0'], ['-usehd=1', '-keypool=100', '-keypoolmin=20']] + + def run_test(self): + self.tmpdir = self.options.tmpdir + self.nodes[0].generate(101) + + self.log.info("Make backup of wallet") + + self.stop_node(1) + + shutil.copyfile(self.tmpdir + "/node1/regtest/wallet.dat", self.tmpdir + "/wallet.bak") + self.nodes[1] = self.start_node(1, self.tmpdir, self.extra_args[1]) + connect_nodes_bi(self.nodes, 0, 1) + + self.log.info("Generate keys for wallet") + + for _ in range(90): + addr_oldpool = self.nodes[1].getnewaddress() + for _ in range(20): + addr_extpool = self.nodes[1].getnewaddress() + + self.log.info("Send funds to wallet") + + self.nodes[0].sendtoaddress(addr_oldpool, 10) + self.nodes[0].generate(1) + self.nodes[0].sendtoaddress(addr_extpool, 5) + self.nodes[0].generate(1) + sync_blocks(self.nodes) + + self.log.info("Restart node with wallet backup") + + self.stop_node(1) + + shutil.copyfile(self.tmpdir + "/wallet.bak", self.tmpdir + "/node1/regtest/wallet.dat") + + self.log.info("Verify keypool is restored and balance is correct") + + self.nodes[1] = self.start_node(1, self.tmpdir, self.extra_args[1]) + connect_nodes_bi(self.nodes, 0, 1) + self.sync_all() + + assert_equal(self.nodes[1].getbalance(), 15) + assert_equal(self.nodes[1].listtransactions()[0]['category'], "receive") + + # Check that we have marked all keys up to the used keypool key as used + assert_equal(self.nodes[1].validateaddress(self.nodes[1].getnewaddress())['hdkeypath'], "m/0'/0'/111'") + +if __name__ == '__main__': + KeypoolRestoreTest().main() diff --git a/test/functional/p2p-leaktests.py b/test/functional/p2p-leaktests.py index 33b57ef33d..5611c876ae 100755 --- a/test/functional/p2p-leaktests.py +++ b/test/functional/p2p-leaktests.py @@ -9,7 +9,10 @@ received a VERACK. This test connects to a node and sends it a few messages, trying to intice it into sending us something it shouldn't. -""" + +Also test that nodes that send unsupported service bits to bitcoind are disconnected +and don't receive a VERACK. Unsupported service bits are currently 1 << 5 and +1 << 7 (until August 1st 2018).""" from test_framework.mininode import * from test_framework.test_framework import BitcoinTestFramework @@ -98,20 +101,29 @@ class P2PLeakTest(BitcoinTestFramework): no_version_bannode = CNodeNoVersionBan() no_version_idlenode = CNodeNoVersionIdle() no_verack_idlenode = CNodeNoVerackIdle() + unsupported_service_bit5_node = CLazyNode() + unsupported_service_bit7_node = CLazyNode() + self.nodes[0].setmocktime(1501545600) # August 1st 2017 connections = [] connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], no_version_bannode, send_version=False)) connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], no_version_idlenode, send_version=False)) connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], no_verack_idlenode)) + connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], unsupported_service_bit5_node, services=NODE_NETWORK|NODE_UNSUPPORTED_SERVICE_BIT_5)) + connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], unsupported_service_bit7_node, services=NODE_NETWORK|NODE_UNSUPPORTED_SERVICE_BIT_7)) no_version_bannode.add_connection(connections[0]) no_version_idlenode.add_connection(connections[1]) no_verack_idlenode.add_connection(connections[2]) + unsupported_service_bit5_node.add_connection(connections[3]) + unsupported_service_bit7_node.add_connection(connections[4]) NetworkThread().start() # Start up network handling in another thread assert wait_until(lambda: no_version_bannode.ever_connected, timeout=10) assert wait_until(lambda: no_version_idlenode.ever_connected, timeout=10) assert wait_until(lambda: no_verack_idlenode.version_received, timeout=10) + assert wait_until(lambda: unsupported_service_bit5_node.ever_connected, timeout=10) + assert wait_until(lambda: unsupported_service_bit7_node.ever_connected, timeout=10) # Mine a block and make sure that it's not sent to the connected nodes self.nodes[0].generate(1) @@ -122,12 +134,32 @@ class P2PLeakTest(BitcoinTestFramework): #This node should have been banned assert not no_version_bannode.connected + # These nodes should have been disconnected + assert not unsupported_service_bit5_node.connected + assert not unsupported_service_bit7_node.connected + [conn.disconnect_node() for conn in connections] # Make sure no unexpected messages came in assert(no_version_bannode.unexpected_msg == False) assert(no_version_idlenode.unexpected_msg == False) assert(no_verack_idlenode.unexpected_msg == False) + assert not unsupported_service_bit5_node.unexpected_msg + assert not unsupported_service_bit7_node.unexpected_msg + + self.log.info("Service bits 5 and 7 are allowed after August 1st 2018") + self.nodes[0].setmocktime(1533168000) # August 2nd 2018 + + allowed_service_bit5_node = NodeConnCB() + allowed_service_bit7_node = NodeConnCB() + + connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], allowed_service_bit5_node, services=NODE_NETWORK|NODE_UNSUPPORTED_SERVICE_BIT_5)) + connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], allowed_service_bit7_node, services=NODE_NETWORK|NODE_UNSUPPORTED_SERVICE_BIT_7)) + allowed_service_bit5_node.add_connection(connections[5]) + allowed_service_bit7_node.add_connection(connections[6]) + + assert wait_until(lambda: allowed_service_bit5_node.message_count["verack"], timeout=10) + assert wait_until(lambda: allowed_service_bit7_node.message_count["verack"], timeout=10) if __name__ == '__main__': P2PLeakTest().main() diff --git a/test/functional/resendwallettransactions.py b/test/functional/resendwallettransactions.py new file mode 100755 index 0000000000..5059aa106e --- /dev/null +++ b/test/functional/resendwallettransactions.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +# Copyright (c) 2017 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +"""Test resendwallettransactions RPC.""" + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import assert_equal, assert_raises_jsonrpc + +class ResendWalletTransactionsTest(BitcoinTestFramework): + + def __init__(self): + super().__init__() + self.extra_args = [['--walletbroadcast=false']] + self.num_nodes = 1 + + def run_test(self): + # Should raise RPC_WALLET_ERROR (-4) if walletbroadcast is disabled. + assert_raises_jsonrpc(-4, "Error: Wallet transaction broadcasting is disabled with -walletbroadcast", self.nodes[0].resendwallettransactions) + + # Should return an empty array if there aren't unconfirmed wallet transactions. + self.stop_node(0) + self.nodes[0] = self.start_node(0, self.options.tmpdir) + assert_equal(self.nodes[0].resendwallettransactions(), []) + + # Should return an array with the unconfirmed wallet transaction. + txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) + assert_equal(self.nodes[0].resendwallettransactions(), [txid]) + +if __name__ == '__main__': + ResendWalletTransactionsTest().main() diff --git a/test/functional/sendheaders.py b/test/functional/sendheaders.py index 44c357c6db..e47e07fb86 100755 --- a/test/functional/sendheaders.py +++ b/test/functional/sendheaders.py @@ -121,9 +121,6 @@ class TestNode(NodeConnCB): message.headers[-1].calc_sha256() self.last_blockhash_announced = message.headers[-1].sha256 - def on_block(self, conn, message): - self.last_message["block"].calc_sha256() - # Test whether the last announcement we received had the # right header or the right inv # inv and headers should be lists of block hashes diff --git a/test/functional/test_framework/mininode.py b/test/functional/test_framework/mininode.py index 688347a68f..a4d85501e7 100755 --- a/test/functional/test_framework/mininode.py +++ b/test/functional/test_framework/mininode.py @@ -51,6 +51,8 @@ NODE_NETWORK = (1 << 0) NODE_GETUTXO = (1 << 1) NODE_BLOOM = (1 << 2) NODE_WITNESS = (1 << 3) +NODE_UNSUPPORTED_SERVICE_BIT_5 = (1 << 5) +NODE_UNSUPPORTED_SERVICE_BIT_7 = (1 << 7) logger = logging.getLogger("TestFramework.mininode") diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py index 8d698a7327..e562d11938 100755 --- a/test/functional/test_framework/test_framework.py +++ b/test/functional/test_framework/test_framework.py @@ -11,6 +11,7 @@ import http.client import logging import optparse import os +import pdb import shutil import subprocess import sys @@ -125,6 +126,8 @@ class BitcoinTestFramework(object): help="Write tested RPC commands into this directory") parser.add_option("--configfile", dest="configfile", help="Location of the test framework config file") + parser.add_option("--pdbonfailure", dest="pdbonfailure", default=False, action="store_true", + help="Attach a python debugger if test fails") self.add_options(parser) (self.options, self.args) = parser.parse_args() @@ -162,6 +165,10 @@ class BitcoinTestFramework(object): except KeyboardInterrupt as e: self.log.warning("Exiting after keyboard interrupt") + if success == TestStatus.FAILED and self.options.pdbonfailure: + print("Testcase failed. Attaching python debugger. Enter ? for help") + pdb.set_trace() + if not self.options.noshutdown: self.log.info("Stopping nodes") if self.nodes: diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index a043560ea8..93f180555d 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -79,6 +79,7 @@ BASE_SCRIPTS= [ 'rawtransactions.py', 'reindex.py', # vv Tests less than 30s vv + 'keypool-topup.py', 'zmq_test.py', 'mempool_resurrect_test.py', 'txn_doublespend.py --mineblock', @@ -115,7 +116,10 @@ BASE_SCRIPTS= [ 'listsinceblock.py', 'p2p-leaktests.py', 'wallet-encryption.py', + 'bipdersig-p2p.py', + 'bip65-cltv-p2p.py', 'uptime.py', + 'resendwallettransactions.py', ] EXTENDED_SCRIPTS = [ @@ -138,10 +142,6 @@ EXTENDED_SCRIPTS = [ 'rpcbind_test.py', # vv Tests less than 30s vv 'assumevalid.py', - 'bip65-cltv.py', - 'bip65-cltv-p2p.py', - 'bipdersig-p2p.py', - 'bipdersig.py', 'example_test.py', 'txn_doublespend.py', 'txn_clone.py --mineblock', diff --git a/test/functional/wallet-hd.py b/test/functional/wallet-hd.py index dfd3dc83c5..821575ed19 100755 --- a/test/functional/wallet-hd.py +++ b/test/functional/wallet-hd.py @@ -9,7 +9,6 @@ from test_framework.util import ( assert_equal, connect_nodes_bi, ) -import os import shutil @@ -72,10 +71,12 @@ class WalletHDTest(BitcoinTestFramework): self.log.info("Restore backup ...") self.stop_node(1) - os.remove(self.options.tmpdir + "/node1/regtest/wallet.dat") + # we need to delete the complete regtest directory + # otherwise node1 would auto-recover all funds in flag the keypool keys as used + shutil.rmtree(tmpdir + "/node1/regtest/blocks") + shutil.rmtree(tmpdir + "/node1/regtest/chainstate") shutil.copyfile(tmpdir + "/hd.bak", tmpdir + "/node1/regtest/wallet.dat") self.nodes[1] = self.start_node(1, self.options.tmpdir, self.extra_args[1]) - #connect_nodes_bi(self.nodes, 0, 1) # Assert that derivation is deterministic hd_add_2 = None @@ -85,11 +86,12 @@ class WalletHDTest(BitcoinTestFramework): assert_equal(hd_info_2["hdkeypath"], "m/0'/0'/"+str(_+1)+"'") assert_equal(hd_info_2["hdmasterkeyid"], masterkeyid) assert_equal(hd_add, hd_add_2) + connect_nodes_bi(self.nodes, 0, 1) + self.sync_all() # Needs rescan self.stop_node(1) self.nodes[1] = self.start_node(1, self.options.tmpdir, self.extra_args[1] + ['-rescan']) - #connect_nodes_bi(self.nodes, 0, 1) assert_equal(self.nodes[1].getbalance(), num_hd_adds + 1) # send a tx and make sure its using the internal chain for the changeoutput diff --git a/test/util/data/tt-delin1-out.json b/test/util/data/tt-delin1-out.json index f6dfbb51cc..0b3235dd4a 100644 --- a/test/util/data/tt-delin1-out.json +++ b/test/util/data/tt-delin1-out.json @@ -189,7 +189,7 @@ ], "vout": [ { - "value": 1.3782, + "value": 1.37820000, "n": 0, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 8fd139bb39ced713f231c58a4d07bf6954d1c201 OP_EQUALVERIFY OP_CHECKSIG", diff --git a/test/util/data/tt-delout1-out.json b/test/util/data/tt-delout1-out.json index 6769ed79ff..5b69d0cd86 100644 --- a/test/util/data/tt-delout1-out.json +++ b/test/util/data/tt-delout1-out.json @@ -198,7 +198,7 @@ ], "vout": [ { - "value": 1.3782, + "value": 1.37820000, "n": 0, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 8fd139bb39ced713f231c58a4d07bf6954d1c201 OP_EQUALVERIFY OP_CHECKSIG", diff --git a/test/util/data/tt-locktime317000-out.json b/test/util/data/tt-locktime317000-out.json index 82b64df075..cf1ebcdf38 100644 --- a/test/util/data/tt-locktime317000-out.json +++ b/test/util/data/tt-locktime317000-out.json @@ -198,7 +198,7 @@ ], "vout": [ { - "value": 1.3782, + "value": 1.37820000, "n": 0, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 8fd139bb39ced713f231c58a4d07bf6954d1c201 OP_EQUALVERIFY OP_CHECKSIG", diff --git a/test/util/data/txcreate1.json b/test/util/data/txcreate1.json index 36741044c9..edb091f946 100644 --- a/test/util/data/txcreate1.json +++ b/test/util/data/txcreate1.json @@ -36,7 +36,7 @@ ], "vout": [ { - "value": 0.18, + "value": 0.18000000, "n": 0, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 1fc11f39be1729bf973a7ab6a615ca4729d64574 OP_EQUALVERIFY OP_CHECKSIG", @@ -49,7 +49,7 @@ } }, { - "value": 4.00, + "value": 4.00000000, "n": 1, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 f2d4db28cad6502226ee484ae24505c2885cb12d OP_EQUALVERIFY OP_CHECKSIG", diff --git a/test/util/data/txcreate2.json b/test/util/data/txcreate2.json index 23fe7ace67..cca00f752b 100644 --- a/test/util/data/txcreate2.json +++ b/test/util/data/txcreate2.json @@ -9,7 +9,7 @@ ], "vout": [ { - "value": 0.00, + "value": 0.00000000, "n": 0, "scriptPubKey": { "asm": "", diff --git a/test/util/data/txcreatedata1.json b/test/util/data/txcreatedata1.json index e65a1859eb..e66a6bb9a5 100644 --- a/test/util/data/txcreatedata1.json +++ b/test/util/data/txcreatedata1.json @@ -18,7 +18,7 @@ ], "vout": [ { - "value": 0.18, + "value": 0.18000000, "n": 0, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 1fc11f39be1729bf973a7ab6a615ca4729d64574 OP_EQUALVERIFY OP_CHECKSIG", @@ -31,7 +31,7 @@ } }, { - "value": 4.00, + "value": 4.00000000, "n": 1, "scriptPubKey": { "asm": "OP_RETURN 54686973204f505f52455455524e207472616e73616374696f6e206f7574707574207761732063726561746564206279206d6f646966696564206372656174657261777472616e73616374696f6e2e", diff --git a/test/util/data/txcreatedata2.json b/test/util/data/txcreatedata2.json index 8f1544e1c0..0f8edcafdd 100644 --- a/test/util/data/txcreatedata2.json +++ b/test/util/data/txcreatedata2.json @@ -18,7 +18,7 @@ ], "vout": [ { - "value": 0.18, + "value": 0.18000000, "n": 0, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 1fc11f39be1729bf973a7ab6a615ca4729d64574 OP_EQUALVERIFY OP_CHECKSIG", @@ -31,7 +31,7 @@ } }, { - "value": 0.00, + "value": 0.00000000, "n": 1, "scriptPubKey": { "asm": "OP_RETURN 54686973204f505f52455455524e207472616e73616374696f6e206f7574707574207761732063726561746564206279206d6f646966696564206372656174657261777472616e73616374696f6e2e", diff --git a/test/util/data/txcreatedata_seq0.json b/test/util/data/txcreatedata_seq0.json index e52401f418..4b5a7cab4a 100644 --- a/test/util/data/txcreatedata_seq0.json +++ b/test/util/data/txcreatedata_seq0.json @@ -18,7 +18,7 @@ ], "vout": [ { - "value": 0.18, + "value": 0.18000000, "n": 0, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 1fc11f39be1729bf973a7ab6a615ca4729d64574 OP_EQUALVERIFY OP_CHECKSIG", diff --git a/test/util/data/txcreatedata_seq1.json b/test/util/data/txcreatedata_seq1.json index 093ff4a56b..771ff1bb10 100644 --- a/test/util/data/txcreatedata_seq1.json +++ b/test/util/data/txcreatedata_seq1.json @@ -27,7 +27,7 @@ ], "vout": [ { - "value": 0.18, + "value": 0.18000000, "n": 0, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 1fc11f39be1729bf973a7ab6a615ca4729d64574 OP_EQUALVERIFY OP_CHECKSIG", diff --git a/test/util/data/txcreatemultisig1.json b/test/util/data/txcreatemultisig1.json index 0cc530836a..7c814dad83 100644 --- a/test/util/data/txcreatemultisig1.json +++ b/test/util/data/txcreatemultisig1.json @@ -9,7 +9,7 @@ ], "vout": [ { - "value": 1.00, + "value": 1.00000000, "n": 0, "scriptPubKey": { "asm": "2 02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397 021ac43c7ff740014c3b33737ede99c967e4764553d1b2b83db77c83b8715fa72d 02df2089105c77f266fa11a9d33f05c735234075f2e8780824c6b709415f9fb485 3 OP_CHECKMULTISIG", diff --git a/test/util/data/txcreatemultisig2.json b/test/util/data/txcreatemultisig2.json index 8ad2ffdc65..7d94ce7396 100644 --- a/test/util/data/txcreatemultisig2.json +++ b/test/util/data/txcreatemultisig2.json @@ -9,7 +9,7 @@ ], "vout": [ { - "value": 1.00, + "value": 1.00000000, "n": 0, "scriptPubKey": { "asm": "OP_HASH160 1c6fbaf46d64221e80cbae182c33ddf81b9294ac OP_EQUAL", diff --git a/test/util/data/txcreatemultisig3.json b/test/util/data/txcreatemultisig3.json index 086bf44b8a..06e093e224 100644 --- a/test/util/data/txcreatemultisig3.json +++ b/test/util/data/txcreatemultisig3.json @@ -9,7 +9,7 @@ ], "vout": [ { - "value": 1.00, + "value": 1.00000000, "n": 0, "scriptPubKey": { "asm": "0 e15a86a23178f433d514dbbce042e87d72662b8b5edcacfd2e37ab7a2d135f05", diff --git a/test/util/data/txcreatemultisig4.json b/test/util/data/txcreatemultisig4.json index d23ccc045e..9a5d2f4a06 100644 --- a/test/util/data/txcreatemultisig4.json +++ b/test/util/data/txcreatemultisig4.json @@ -9,7 +9,7 @@ ], "vout": [ { - "value": 1.00, + "value": 1.00000000, "n": 0, "scriptPubKey": { "asm": "OP_HASH160 6edf12858999f0dae74f9c692e6694ee3621b2ac OP_EQUAL", diff --git a/test/util/data/txcreateoutpubkey1.json b/test/util/data/txcreateoutpubkey1.json index f10aaecf7a..2704ed7673 100644 --- a/test/util/data/txcreateoutpubkey1.json +++ b/test/util/data/txcreateoutpubkey1.json @@ -9,7 +9,7 @@ ], "vout": [ { - "value": 0.00, + "value": 0.00000000, "n": 0, "scriptPubKey": { "asm": "02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397 OP_CHECKSIG", diff --git a/test/util/data/txcreateoutpubkey2.json b/test/util/data/txcreateoutpubkey2.json index 5a473b76c3..5144722230 100644 --- a/test/util/data/txcreateoutpubkey2.json +++ b/test/util/data/txcreateoutpubkey2.json @@ -9,7 +9,7 @@ ], "vout": [ { - "value": 0.00, + "value": 0.00000000, "n": 0, "scriptPubKey": { "asm": "0 a2516e770582864a6a56ed21a102044e388c62e3", diff --git a/test/util/data/txcreateoutpubkey3.json b/test/util/data/txcreateoutpubkey3.json index b8389b8f7e..0a5d489e15 100644 --- a/test/util/data/txcreateoutpubkey3.json +++ b/test/util/data/txcreateoutpubkey3.json @@ -9,7 +9,7 @@ ], "vout": [ { - "value": 0.00, + "value": 0.00000000, "n": 0, "scriptPubKey": { "asm": "OP_HASH160 a5ab14c9804d0d8bf02f1aea4e82780733ad0a83 OP_EQUAL", diff --git a/test/util/data/txcreatescript1.json b/test/util/data/txcreatescript1.json index 823168e9fb..5072452fed 100644 --- a/test/util/data/txcreatescript1.json +++ b/test/util/data/txcreatescript1.json @@ -9,7 +9,7 @@ ], "vout": [ { - "value": 0.00, + "value": 0.00000000, "n": 0, "scriptPubKey": { "asm": "OP_DROP", diff --git a/test/util/data/txcreatescript2.json b/test/util/data/txcreatescript2.json index d4c7e10c78..94b669ffb6 100644 --- a/test/util/data/txcreatescript2.json +++ b/test/util/data/txcreatescript2.json @@ -9,7 +9,7 @@ ], "vout": [ { - "value": 0.00, + "value": 0.00000000, "n": 0, "scriptPubKey": { "asm": "OP_HASH160 71ed53322d470bb96657deb786b94f97dd46fb15 OP_EQUAL", diff --git a/test/util/data/txcreatescript3.json b/test/util/data/txcreatescript3.json index 001e69511f..980da2fb31 100644 --- a/test/util/data/txcreatescript3.json +++ b/test/util/data/txcreatescript3.json @@ -9,7 +9,7 @@ ], "vout": [ { - "value": 0.00, + "value": 0.00000000, "n": 0, "scriptPubKey": { "asm": "0 0bfe935e70c321c7ca3afc75ce0d0ca2f98b5422e008bb31c00c6d7f1f1c0ad6", diff --git a/test/util/data/txcreatescript4.json b/test/util/data/txcreatescript4.json index 20094bcd44..eecdf858b7 100644 --- a/test/util/data/txcreatescript4.json +++ b/test/util/data/txcreatescript4.json @@ -9,7 +9,7 @@ ], "vout": [ { - "value": 0.00, + "value": 0.00000000, "n": 0, "scriptPubKey": { "asm": "OP_HASH160 6a2c482f4985f57e702f325816c90e3723ca81ae OP_EQUAL", diff --git a/test/util/data/txcreatesignv1.json b/test/util/data/txcreatesignv1.json index 519d3ab066..92a3f76a07 100644 --- a/test/util/data/txcreatesignv1.json +++ b/test/util/data/txcreatesignv1.json @@ -18,7 +18,7 @@ ], "vout": [ { - "value": 0.001, + "value": 0.00100000, "n": 0, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 5834479edbbe0539b31ffd3a8f8ebadc2165ed01 OP_EQUALVERIFY OP_CHECKSIG", |