Commit graph

35183 commits

Author SHA1 Message Date
w0xlt
07df6cda14 wallet: Return util::Result from WalletLoader methods 2022-08-10 11:14:53 -03:00
josibake
8cd21bb279
refactor: improve readability for AttemptSelection
it was pointed out by a few reviewers that the code block at the end
of attempt selection was difficult to follow and lacked comments.

refactor to get rid of triple nested if statement and improve
readibility.
2022-08-10 15:19:32 +02:00
josibake
f47ff71761
test: only run test for descriptor wallets
since this test uses bech32m, we skip unless sqlite is used, which is the
same as checking if we are using descriptor wallets or not
2022-08-10 15:19:32 +02:00
josibake
0760ce0b9e
test: add missing BOOST_ASSERT
this was missed in the original PR
2022-08-10 15:19:32 +02:00
josibake
db09aec937
wallet: switch to new shuffle, erase, push_back
switch to new methods, remove old code. this also
updates the Size, All, and Clear methods to now use
the coins map.

this commit is not strictly a refactor because previously
coin selection was never run over the UNKNOWN type until the last
step when being run over all. now that we are iterating over each,
it is run over UNKNOWN but this is expected to be empty most of the time.

Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
2022-08-10 15:19:31 +02:00
josibake
b6b50b0f2b
scripted-diff: Uppercase function names
Change `CoinsResult` functions to uppercase to be consistent with
the style guide.

-BEGIN VERIFY SCRIPT-
git grep -l "available_coins" | grep -v mempool_stress.cpp | xargs sed -i "s/available_coins\.\(size\|all\|clear\)/available_coins\.\u\1/"
git grep -l AvailableCoins | xargs sed -i "/AvailableCoins/ s/\(all()\|size()\|clear()\)/\u\1/"
sed -i "s/\(clear()\|all()\|size()\)/\u&/g" src/wallet/spend.h
sed -i "/CoinsResult::/ s/\(clear()\|all()\|size()\)/\u&/" src/wallet/spend.cpp
sed -i "s/result.size/result.Size/" src/wallet/spend.cpp
sed -i "s/this->size/this->Size/" src/wallet/spend.cpp
-END VERIFY SCRIPT-
2022-08-10 15:19:31 +02:00
josibake
3f27a2adce
refactor: add new helper methods
add Shuffle, Erase, and Add to CoinsResult struct
add a helper function for mapping TxoutType to OutputType

Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
2022-08-10 15:19:18 +02:00
Vasil Dimov
daabd41211
net: simplify GetLocalAddress()
There is no need to use two variables `ret` and `addr` of the same type
`CService` and assign one to the other in a strange way like
`ret = CService{addr}`.
2022-08-10 15:09:29 +02:00
fanquake
d8b26abed9
build: move raw rule into Makefile.am
The same rule is used by the tests and benchmarks to generate headers,
and currently causes #25501. Just deduplicate the code into Makefile.am.
2022-08-10 13:36:33 +01:00
MacroFake
a6fc293c0a
Merge bitcoin/bitcoin#25656: refactor: wallet: return util::Result from GetReservedDestination methods
76b3c37fcb refactor: wallet: return util::Result from `GetReservedDestination` methods (Sebastian Falbesoner)

Pull request description:

  This PR is a follow-up to #25218, as suggested in comment https://github.com/bitcoin/bitcoin/pull/25218#discussion_r907710067. The interfaces of the methods `ReserveDestination::GetReservedDestination`, `{Legacy,Descriptor,}ScriptPubKeyMan::GetReservedDestination` are improved by returning `util::Result<CTxDestination>` instead of `bool` in order to get rid of the two `CTxDestination&` and `bilingual_str&` out-parameters.

ACKs for top commit:
  furszy:
    ACK 76b3c37f

Tree-SHA512: bf15560a88d645bcf8768024013d36012cd65caaa4a613e8a055dfd8f29cb4a219c19084606992bad177920cdca3a732ec168e9b9526f9295491f2cf79cc6815
2022-08-10 14:19:17 +02:00
MacroFake
aac200801b
Merge bitcoin/bitcoin#25794: test, tracing: don't rely on block_connected USDT event order in tests
0532aa7444 test: don't rely on usdt block_conn event order (0xb10c)

Pull request description:

  Relying on block_connected event order in the USDT interface tests turned out to be brittle.

  Closes https://github.com/bitcoin/bitcoin/issues/25793
  Closes https://github.com/bitcoin/bitcoin/issues/25764

Top commit has no ACKs.

Tree-SHA512: 40b5012ac80a8eac9d2f374cd39304488009c29adb474dc5e8c03b96c354be358298d2ddee8de480afecc187e1bf42ee119b7aa6216b086a8bf77b7e1310213c
2022-08-10 14:04:40 +02:00
MacroFake
ebf094ff3a
Merge bitcoin/bitcoin#25731: test: negative/unknown rpcserialversion should throw an init error
155344960b test: negative/unknown `rpcserialversion` should throw an init error (brunoerg)

Pull request description:

  This PR adds test coverage for the following init errors:
  41205bf442/src/init.cpp (L1025-L1030)

Top commit has no ACKs.

Tree-SHA512: 4456949e9a13908a5a59b13ed57bc3002b7ffd626e8dfb0346aa2600937ba1ef1b69cbae45cdb6bbc1c019dbcd64844e736a2ddd671a4704e53804355b6ea9f9
2022-08-10 13:51:44 +02:00
josibake
f5649db9d5
refactor: add UNKNOWN OutputType
add to enum, array and handle UNKNOWN in various case statements
2022-08-10 10:17:54 +02:00
Luke Dashjr
90a5dfa509 RPC/Mining: Clean out pre-Segwit miner compatibility code 2022-08-09 22:15:34 +00:00
Andrew Chow
ac59112a6a
Merge bitcoin/bitcoin#23480: Add rawtr() descriptor for P2TR with specified (tweaked) output key
544b4332f0 Add wallet tests for spending rawtr() (Pieter Wuille)
e1e3081200 If P2TR tweaked key is available, sign with it (Pieter Wuille)
8d9670ccb7 Add rawtr() descriptor for P2TR with unknown tweak (Pieter Wuille)

Pull request description:

  It may be useful to be able to represent P2TR outputs in descriptors whose script tree and/or internal key aren't known. This PR does that, by adding a `rawtr(KEY)` descriptor, where the KEY represents the output key directly. If the private key corresponding to that output key is known, it also permits signing with it.

  I'm not convinced this is desirable, but presumably "tr(KEY)" sounds more intended for direct use than "rawtr(KEY)".

ACKs for top commit:
  achow101:
    ACK 544b4332f0
  sanket1729:
    code review ACK 544b4332f0
  w0xlt:
    reACK 544b4332f0

Tree-SHA512: 0de08de517468bc22ab0c00db471ce33144f5dc211ebc2974c6ea95709f44e830532ec5cdb0128c572513d352120bd651c4559516d4500b5b0a3d257c4b45aca
2022-08-09 16:36:00 -04:00
Sebastian Falbesoner
4edc689382 doc: test: suggest multi-line imports in functional test style guide 2022-08-09 18:04:20 +02:00
Sebastian Falbesoner
b4a5ab96b4 test: refactor: deduplicate DEFAULT_{ANCESTOR,DESCENDANT}_LIMIT constants 2022-08-09 15:22:38 +02:00
Sebastian Falbesoner
0fda1c7df6 scripted-diff: test: rename MAX_{ANCESTORS,DESCENDANTS} to DEFAULT_{ANCESTOR,DESCENDANT}_LIMIT
-BEGIN VERIFY SCRIPT-
ren() { sed -i "s:$1:$2:g" $(git grep -l "$1" ./test); }

ren MAX_ANCESTORS_CUSTOM    CUSTOM_ANCESTOR_LIMIT
ren MAX_DESCENDANTS_CUSTOM  CUSTOM_DESCENDANT_LIMIT
ren MAX_ANCESTORS           DEFAULT_ANCESTOR_LIMIT
ren MAX_DESCENDANTS         DEFAULT_DESCENDANT_LIMIT
-END VERIFY SCRIPT-
2022-08-09 14:59:47 +02:00
glozow
c012875b9d
Merge bitcoin/bitcoin#24564: doc: Clarify that CheckSequenceLocksAtTip is a validation function
fa86710187 Clarify that CheckSequenceLocksAtTip is a validation function (MarcoFalke)

Pull request description:

  It has been pointed out that a bug in this function can prevent block template creation. ( https://github.com/bitcoin/bitcoin/pull/24080#issuecomment-1065148776 ) So it seems that the scope of this function is more than "policy". Rename it back to "validation", to partially revert commit fa4e30b0f3.

ACKs for top commit:
  ajtowns:
    ACK fa86710187 - looks fine to me
  glozow:
    ACK fa86710187

Tree-SHA512: 2e0df8c70df4cbea857977f140a8616cfa7505e74df66c9c9fbcf184670ce3ce7567183c3f76e6f3fe8ca6de0e065b9babde6352d6cb495e71ea077ddedbc3f4
2022-08-09 11:51:55 +01:00
fanquake
d755ffc327
build: package test_bitcoin in Windows installer 2022-08-09 09:13:23 +01:00
fanquake
aa30e046ac
build: remove entire docs dir from Windows installer 2022-08-09 09:08:46 +01:00
Andrew Chow
e7ca8afef6
Merge bitcoin/bitcoin#25782: test: check that verifymessage RPC fails for non-P2PKH addresses
68006c10ab test: check that `verifymessage` RPC fails for non-P2PKH addresses (Sebastian Falbesoner)

Pull request description:

  This PR adds missing test coverage for the `verifymessage` RPC, for the case that a non-P2PKH (but otherwise valid) address is passed:
  e09ad284c7/src/util/message.cpp (L38-L40)
  e09ad284c7/src/rpc/signmessage.cpp (L48-L49)
  The passed addresses to trigger the error are of the types nested segwit (P2SH-P2WPKH) and native segwit (P2WPKH) and are created with a helper function `addresses_from_privkey` using descriptors and the `deriveaddresses` RPC. At some point in the future, if we have BIP322 support, all those will likely succeed and can then be moved from error-throwing to the succedding assert loop.

ACKs for top commit:
  achow101:
    ACK 68006c10ab
  w0xlt:
    ACK 68006c10ab

Tree-SHA512: fec4ed97460787c2ef3d04e3fce89c9365c87207c8358b59c41890f3738355c002e64f289ab4aef794ef4dfd5c867be8b67d736fb620489204f2c6bfb8d3363c
2022-08-08 19:07:14 -04:00
fanquake
9ff6adc43a
Merge bitcoin/bitcoin#25804: Update translations for 24.0 string freeze
ff52b24e5c qt: Update translation source file (Hennadii Stepanov)
15f762fc65 qt: Bump Transifex slug for 24.x (Hennadii Stepanov)

Pull request description:

  Required to open Transifex translations for 24.0 (see bitcoin/bitcoin#24987).

ACKs for top commit:
  laanwj:
    Changes-match-release-process ACK ff52b24e5c
  jarolrod:
    ACK ff52b24e5c

Tree-SHA512: f3e65b1608818084f4a3adddd2a58541ebe91ebcdb3717da2eb6f4147a0fc5f0d536a2e9f8b4eacc2a580b12c619d9eec391bfdcc5e81fa02f527408ec73a984
2022-08-08 16:28:07 +01:00
Andrew Chow
a478c5350a
Merge bitcoin/bitcoin#25790: wallet: improve {LoadActive,Deactivate}ScriptPubKeyMan log
b5a762a353 wallet: improve `{LoadActive,Deactivate}ScriptPubKeyMan` log (w0xlt)

Pull request description:

  This PR includes the output type description in the log. It currently shows the enum position, which is only useful if the reader knows the code.

  Master:
  ```
  Setting spkMan to active: id = 9f..04, type = 3, internal = 0
  Setting spkMan to active: id = 3d..21, type = 2, internal = 0
  Setting spkMan to active: id = 69..d4, type = 0, internal = 1
  Setting spkMan to active: id = 97..ea, type = 1, internal = 1
  ```

  PR:
  ```
  Setting spkMan to active: id = 6a..4f, type = bech32m, internal = false
  Setting spkMan to active: id = 83..dc, type = legacy, internal = true
  Setting spkMan to active: id = 7e..5d, type = p2sh-segwit, internal = true
  Setting spkMan to active: id = bd..d2, type = bech32, internal = true
  Setting spkMan to active: id = 13...7c, type = bech32m, internal = true

  ```

ACKs for top commit:
  S3RK:
    Code review ACK b5a762a353
  achow101:
    ACK b5a762a353
  theStack:
    Code-review ACK b5a762a353

Tree-SHA512: 5a79706d5452e523b0456fb8435545c6c8e550b6722c0d7966af79011275a97ed97cab297562e031d601aa855118082c5b770af118783b1faaaec0cba9f9ee6a
2022-08-08 11:18:08 -04:00
Hennadii Stepanov
ff52b24e5c
qt: Update translation source file 2022-08-08 12:18:55 +01:00
Hennadii Stepanov
15f762fc65
qt: Bump Transifex slug for 24.x 2022-08-08 12:07:47 +01:00
Hennadii Stepanov
fea75ad3ca
refactor: Drop boost/algorithm/string/replace.hpp dependency 2022-08-08 11:53:23 +01:00
Hennadii Stepanov
857526e8cb
test: Add test case for ReplaceAll() function 2022-08-08 11:53:17 +01:00
Antoine Poinsot
c232ef20c0
outputtype: remove redundant check for uncompressed keys in AddAndGetDestinationForScript
It's already checked by its (only) caller, AddAndGetMultisigDestination.
2022-08-07 22:57:56 +02:00
fanquake
5474f5c356
build: fix cleanup of test logs
make clean currently looks for test.cpp.log, when it should be test.log.
2022-08-07 12:13:51 +01:00
0xb10c
0532aa7444
test: don't rely on usdt block_conn event order
Relying on block_connected event order in the USDT interface tests
turned out to be brittle.

Fixes https://github.com/bitcoin/bitcoin/issues/25793
Fixes https://github.com/bitcoin/bitcoin/issues/25764
2022-08-06 13:59:38 +02:00
w0xlt
b5a762a353 wallet: improve {LoadActive,Deactivate}ScriptPubKeyMan log 2022-08-05 17:19:52 -03:00
Andrew Chow
b1a2021f78
Merge bitcoin/bitcoin#25788: guix: patch NSIS to remove .reloc sections from installer stubs
7a0b129c41 guix: patch NSIS to remove .reloc sections from install stubs (fanquake)

Pull request description:

  With the release of binutils/ld 2.36, ld swapped to much improved
  default settings when producing windows binaries with mingw-w64. One of
  these changes was to stop stripping the .reloc section from binaries,
  which is required for working ASLR.

  When we switched to using a newer Guix time-machine in #23778, we begun
  using binutils 2.37 to produce releases. Since then, our windows
  installer (produced with makensis) has not functioned correctly when run on
  a Windows system with the "Force randomization for images (Mandatory ASLR)"
  option enabled. Note that all of our other release binaries, which all
  contain .reloc sections, function fine under the same option, so it
  cannot be just the presence of a .reloc section that is the issue.

  The root cause of the problem is that when we compile NSIS (makensis), a number
  of exe installer stubs are produced at the same time, for use later when makensis
  is actually run. Given the new linker defaults, the stubs will contain .reloc sections,
  when previously they would not. It seems that, in combination with how makensis
  mutates the stub when it actually builds the installer, causes the problem.

  According to upstream, https://sourceforge.net/p/nsis/bugs/1131/#abb6:
  > Looks like the problem is the very existance of the .reloc section.
  > It's not supposed to be there, and makensis doesn't handle it.

  The most recent .reloc related upstream activity is in
  https://sourceforge.net/p/nsis/bugs/1283/, where the conclusion again seemed to
  be that .relo sections are not wanted, but there hasn't been any further follow up.

  For now, restore pre-binutils-2.36 behaviour, by passing `-Wl,--disable-reloc-section`
  to the linker when building the installer stubs, which fixes the produced installer.
  The underlying issue can be further investigated in future.

  .reloc section stripping is something we've accounted for previously,
  see #18702, and related upstream discussion is in this thread:
  https://sourceware.org/bugzilla/show_bug.cgi?id=19011.

  Fixes #25726.

  Guix Build (x86_64):
  ```bash
  7e0723388913ac1ec9f650b943c6b23351ba0cd921c0ec830abf16b16724d503  guix-build-7a0b129c41d9/output/dist-archive/bitcoin-7a0b129c41d9.tar.gz
  c3bb9c68895ffafa2900b0d18c1268e299d012a7dc70593f20f9900cf116eb05  guix-build-7a0b129c41d9/output/x86_64-w64-mingw32/SHA256SUMS.part
  b57aa99c242b0aae64653c64ada38f6d3f0cbd902bbc096d3dc529fdcf87d681  guix-build-7a0b129c41d9/output/x86_64-w64-mingw32/bitcoin-7a0b129c41d9-win64-debug.zip
  341d99afc9961299883be6cd9666e8bc0f3f6296cff758719a32d27419acad36  guix-build-7a0b129c41d9/output/x86_64-w64-mingw32/bitcoin-7a0b129c41d9-win64-setup-unsigned.exe
  1d9ef48d3c9ed93a925962356b41cdaeb9d09fd758de193cd4d5f4d1ec6791eb  guix-build-7a0b129c41d9/output/x86_64-w64-mingw32/bitcoin-7a0b129c41d9-win64-unsigned.tar.gz
  28c81d99a9a4bd6648449393f91db213369e958add579ba9e9a1721540d2c4f7  guix-build-7a0b129c41d9/output/x86_64-w64-mingw32/bitcoin-7a0b129c41d9-win64.zip
  ```

  Guix Build (arm64):
  ```bash
  7e0723388913ac1ec9f650b943c6b23351ba0cd921c0ec830abf16b16724d503  guix-build-7a0b129c41d9/output/dist-archive/bitcoin-7a0b129c41d9.tar.gz
  c3bb9c68895ffafa2900b0d18c1268e299d012a7dc70593f20f9900cf116eb05  guix-build-7a0b129c41d9/output/x86_64-w64-mingw32/SHA256SUMS.part
  b57aa99c242b0aae64653c64ada38f6d3f0cbd902bbc096d3dc529fdcf87d681  guix-build-7a0b129c41d9/output/x86_64-w64-mingw32/bitcoin-7a0b129c41d9-win64-debug.zip
  341d99afc9961299883be6cd9666e8bc0f3f6296cff758719a32d27419acad36  guix-build-7a0b129c41d9/output/x86_64-w64-mingw32/bitcoin-7a0b129c41d9-win64-setup-unsigned.exe
  1d9ef48d3c9ed93a925962356b41cdaeb9d09fd758de193cd4d5f4d1ec6791eb  guix-build-7a0b129c41d9/output/x86_64-w64-mingw32/bitcoin-7a0b129c41d9-win64-unsigned.tar.gz
  28c81d99a9a4bd6648449393f91db213369e958add579ba9e9a1721540d2c4f7  guix-build-7a0b129c41d9/output/x86_64-w64-mingw32/bitcoin-7a0b129c41d9-win64.zip
  ```

ACKs for top commit:
  achow101:
    ACK 7a0b129c41
  hebasto:
    ACK 7a0b129c41
  jarolrod:
    ACK 7a0b129c41

Tree-SHA512: 9e14e98207d20236b833603319fc4bb335c878a7c179ab495b33d143e2a900c6926125536bbb7499ee4f0f676cd5ea45c8c86cd7e544ed9a76bb298f98db6197
2022-08-05 15:32:26 -04:00
Andrew Chow
59bd6b6d37
Merge bitcoin/bitcoin#24699: wallet: Improve AvailableCoins performance by reducing duplicated operations
bc886fcb31 Change mapWallet to be a std::unordered_map (Andrew Chow)
272356024d Change getWalletTxs to return a set instead of a vector (Andrew Chow)
97532867cf Change mapTxSpends to be a std::unordered_multimap (Andrew Chow)
1f798fe85b wallet: Cache SigningProviders (Andrew Chow)
8a105ecd1a wallet: Use CalculateMaximumSignedInputSize to indicate solvability (Andrew Chow)

Pull request description:

  While running my coin selection simulations, I noticed that towards the end of the simulation, the wallet would become slow to make new transactions. The wallet generally performs much more slowly when there are a large number of transactions and/or a large number of keys. The improvements here are focused on wallets with a large number of transactions as that is what the simulations produce.

  Most of the slowdown I observed was due to `DescriptorScriptPubKeyMan::GetSigningProvider` re-deriving keys every time it is called. To avoid this, it will now cache the `SigningProvider` produced so that repeatedly fetching the `SigningProvider` for the same script will not result in the same key being derived over and over. This has a side effect of making the function non-const, which makes a lot of other functions non-const as well. This helps with wallets with lots of address reuse (as my coin selection simulations are), but not if addresses are not reused as keys will end up needing to be derived the first time `GetSigningProvider` is called for a script.

  The `GetSigningProvider` problem was also exacerbated by unnecessarily fetching a `SigningProvider` for the same script multiple times. A `SigningProvider` is retrieved to be used inside of `IsSolvable`. A few lines later, we use `GetTxSpendSize` which fetches a `SigningProvider` and then calls `CalculateMaximumSignedInputSize`. We can avoid a second call to `GetSigningProvider` by using `CalculateMaximumSignedInputSize` directly with the `SigningProvider` already retrieved for `IsSolvable`.

  There is an additional slowdown where `ProduceSignature` with a dummy signer is called twice for each output. The first time is `IsSolvable` checks that `ProduceSignature` succeeds, thereby informing whether we have solving data. The second is `CalculateMaximumSignedInputSize` which returns -1 if `ProduceSignature` fails, and returns the input size otherwise. We can reduce this to one call of `ProduceSignature` by using `CalculateMaximumSignedInputSize`'s result to set `solvable`.

  Lastly, a lot of time is spent looking in `mapWallet` and `mapTxSpends` to determine whether an output is already spent. The performance of these lookups is slightly improved by changing those maps to use `std::unordered_map` and `std::unordered_multimap` respectively.

ACKs for top commit:
  Xekyo:
    ACK bc886fcb31
  furszy:
    diff re-reACK bc886fcb

Tree-SHA512: fd710fe1224ef67d2bb83d6ac9e7428d9f76a67f14085915f9d80e1a492d2c51cb912edfcaad1db11c2edf8d2d97eb7ddd95bfb364587fb1f143490fd72c9ec1
2022-08-05 15:31:45 -04:00
Andrew Chow
35305c759a
Merge bitcoin/bitcoin#22751: rpc/wallet: add simulaterawtransaction RPC
db10cf8ae3 rpc/wallet: add simulaterawtransaction RPC (Karl-Johan Alm)
701a64f548 test: add support for Decimal to assert_approx (Karl-Johan Alm)

Pull request description:

  (note: this was originally titled "add analyzerawtransaction RPC")

  This command iterates over the inputs and outputs of the given transactions, and tallies up the balance change for the given wallet. This can be useful e.g. when verifying that a coin join like transaction doesn't contain unexpected inputs that the wallet will then sign for unintentionally.

  I originally proposed this to Elements (https://github.com/ElementsProject/elements/pull/1016) and it was suggested that I propose this upstream.

  There is an alternative #22776 to instead add this info to `getbalances` when providing an optional transaction as argument.

ACKs for top commit:
  jonatack:
    ACK db10cf8ae3
  achow101:
    re-ACK db10cf8ae3

Tree-SHA512: adf222ec7dcdc068d007ae6f465dbc35b692dc7bb2db337be25340ad0c2f9c64cfab4124df23400995c700f41c83c29a2c34812121782c26063b100c7969b89d
2022-08-05 15:19:03 -04:00
fanquake
7a0b129c41
guix: patch NSIS to remove .reloc sections from install stubs
With the release of binutils/ld 2.36, ld swapped to much improved
default settings when producing windows binaries with mingw-w64. One of
these changes was to stop stripping the .reloc section from binaries,
which is required for working ASLR.

.reloc section stripping is something we've accounted for previously,
see #18702. The related upstream discussion is in this thread:
https://sourceware.org/bugzilla/show_bug.cgi?id=19011.

When we switched to using a newer Guix time-machine in #23778, we begun
using binutils 2.37 to produce releases. Since then, our windows
installer (produced with makensis) has not functioned correctly when run on
a Windows system with the "Force randomization for images (Mandatory ASLR)"
option enabled. Note that all of our other release binaries, which all
contain .reloc sections, function fine under the same option, so it
cannot be just the presence of a .reloc section that is the issue.

For now, restore makensis to it's pre-binutils-2.36 behaviour, which
fixes the produced installer. The underlying issue can be further
investigated in future.
2022-08-05 18:15:12 +01:00
Sebastian Falbesoner
76b3c37fcb refactor: wallet: return util::Result from GetReservedDestination methods 2022-08-05 17:19:09 +02:00
MacroFake
7d3817b29a
Merge bitcoin/bitcoin#25760: rest: clean-up for mempool endpoints
acbea66589 rest: clean-up for `mempool` endpoints (brunoerg)

Pull request description:

  The functions `rest_mempool_info` and `rest_mempool_contents` are similar, the only difference between them is:
  `rest_mempool_info` uses `MempoolInfoToJSON` to get the mempool informations and `rest_mempool_contents` uses `MempoolToJSON`, for this reason this PR creates a new function to handle it and reduce duplicated code.

  Also,
  1. Rename `strURIPart` to `str_uri_part`.
  2. Rename `strJSON` to `str_json`.

ACKs for top commit:
  stickies-v:
    re-ACK acbea66589 - verified that just the error message was updated since da0c612c3d
  theStack:
    re-ACK acbea66589

Tree-SHA512: 35f6f0732a573fe8a6cdcc782f89ae3427a1de19f069a68c9c51bb525118c2b07e20303cbe19b9d4b7d1ad055d69c32def2d0fb8f886c851da562dd9ce33ad6a
2022-08-05 16:43:29 +02:00
MacroFake
006740b6f6
Merge bitcoin/bitcoin#25721: refactor: Replace BResult with util::Result
a23cca56c0 refactor: Replace BResult with util::Result (Ryan Ofsky)

Pull request description:

  Rename `BResult` class to `util::Result` and update the class interface to be more compatible with `std::optional` and with a full-featured result class implemented in https://github.com/bitcoin/bitcoin/pull/25665. Motivation for this change is to update existing `BResult` usages now so they don't have to change later when more features are added in https://github.com/bitcoin/bitcoin/pull/25665.

  This change makes the following improvements originally implemented in https://github.com/bitcoin/bitcoin/pull/25665:

  - More explicit API. Drops potentially misleading `BResult` constructor that treats any bilingual string argument as an error. Adds `util::Error` constructor so it is never ambiguous when a result is being assigned an error or non-error value.

  - Better type compatibility. Supports `util::Result<bilingual_str>` return values to hold translated messages which are not errors.

  - More standard and consistent API. `util::Result` supports most of the same operators and methods as `std::optional`. `BResult` had a less familiar interface with `HasRes`/`GetObj`/`ReleaseObj` methods. The Result/Res/Obj naming was also not internally consistent.

  - Better code organization. Puts `src/util/` code in the `util::` namespace so naming reflects code organization and it is obvious where the class is coming from. Drops "B" from name because it is undocumented what it stands for (bilingual?)

  - Has unit tests.

ACKs for top commit:
  MarcoFalke:
    ACK a23cca56c0 🏵
  jonatack:
    ACK a23cca56c0

Tree-SHA512: 2769791e08cd62f21d850aa13fa7afce4fb6875a9cedc39ad5025150dbc611c2ecfd7b3aba8b980a79fde7fbda13babdfa37340633c69b501b6e89727bad5b31
2022-08-05 15:33:45 +02:00
brunoerg
acbea66589 rest: clean-up for mempool endpoints 2022-08-05 10:28:11 -03:00
MacroFake
eeee5ada23
Make adjusted time type safe 2022-08-05 14:59:15 +02:00
MacroFake
fa3be799fe
Add time helpers
To be used in the next commit
2022-08-05 14:45:02 +02:00
Ben Woosley
478695982b bench: Add a benchmark for descriptor expansion 2022-08-05 12:04:43 +02:00
Sebastian Falbesoner
68006c10ab test: check that verifymessage RPC fails for non-P2PKH addresses 2022-08-05 11:59:56 +02:00
fanquake
92f6461cfd
Merge bitcoin/bitcoin#25779: guix: ignore additional failing certvalidator test
4cf3b7d763 guix: ignore additional failing certvalidator test (fanquake)

Pull request description:

  Any Guix build that needs to build the python-certvalidator code will currently fail due to expired certs. So once again ignore the failing tests. Similar to 8588591965.

  ```bash
  ERROR: test_revocation_mode_soft (tests.test_validate.ValidateTests)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/tmp/guix-build-python-certvalidator-0.1-1.a145bf2.drv-0/source/tests/test_validate.py", line 85, in test_revocation_mode_soft
      validate_path(context, path)
    File "/tmp/guix-build-python-certvalidator-0.1-1.a145bf2.drv-0/source/tests/../certvalidator/validate.py", line 50, in validate_path
      return _validate_path(validation_context, path)
    File "/tmp/guix-build-python-certvalidator-0.1-1.a145bf2.drv-0/source/tests/../certvalidator/validate.py", line 358, in _validate_path
      raise PathValidationError(pretty_message(
  certvalidator.errors.PathValidationError: The path could not be validated because the end-entity certificate expired 2022-07-27 12:00:00Z
  ```

  Guix Build (arm64):
  ```bash
  b843f87a61eb2a44d085ab99793ff095290436102b19cd6d6d703c281eba539f  guix-build-4cf3b7d763b0/output/arm64-apple-darwin/SHA256SUMS.part
  280c19bd0a6899dd6100e1d6f632ba9e845500f58f59ed7d6703d818ae2780f0  guix-build-4cf3b7d763b0/output/arm64-apple-darwin/bitcoin-4cf3b7d763b0-arm64-apple-darwin-unsigned.dmg
  9b80cc44e3eeeadb2a17bdcf10fcae7cca4bceceec8fb47c2c757a43753a03c6  guix-build-4cf3b7d763b0/output/arm64-apple-darwin/bitcoin-4cf3b7d763b0-arm64-apple-darwin-unsigned.tar.gz
  43d781b61817a8e0c6168d6611ccb9a4242cf7289b4cc4b5ac77484f34d01738  guix-build-4cf3b7d763b0/output/arm64-apple-darwin/bitcoin-4cf3b7d763b0-arm64-apple-darwin.tar.gz
  38d261b70baf018f8a1ee980fb139451b085dc484516562af4b5ae86a0b71869  guix-build-4cf3b7d763b0/output/dist-archive/bitcoin-4cf3b7d763b0.tar.gz
  e5d08f055f73a1abf5eef0ea4e55098a53e859d0ea7ff29d21a78e30204e8b5c  guix-build-4cf3b7d763b0/output/x86_64-apple-darwin/SHA256SUMS.part
  2388708d670068515bec06219792f34494ab7ac939999572dc4b5d92430e0890  guix-build-4cf3b7d763b0/output/x86_64-apple-darwin/bitcoin-4cf3b7d763b0-x86_64-apple-darwin-unsigned.dmg
  cb43edd02b8eb11c3e9d8bf6baf65b5656577a2f7a2b21374f90c08a196aa608  guix-build-4cf3b7d763b0/output/x86_64-apple-darwin/bitcoin-4cf3b7d763b0-x86_64-apple-darwin-unsigned.tar.gz
  6f443713f2e23da705defddc09c8c66743691841e01d0debe29dad442454e5c8  guix-build-4cf3b7d763b0/output/x86_64-apple-darwin/bitcoin-4cf3b7d763b0-x86_64-apple-darwin.tar.gz
  ```

  Guix Build (x86_64):
  ```bash
  7e18af2409e9811ea2bb2aa41a19dcc0b4ac626bb5effe30909ef21942bfb611  guix-build-4cf3b7d763b0/output/arm64-apple-darwin/SHA256SUMS.part
  b6ec0c9ca967e1e3301894bb2ac92d1fab663cfd620004c8044a3685deb7c9e5  guix-build-4cf3b7d763b0/output/arm64-apple-darwin/bitcoin-4cf3b7d763b0-arm64-apple-darwin-unsigned.dmg
  9f8de6d555d0922fd1fc970628bd2a9a9d3e6779b458038e18bd9d5dd9633a1b  guix-build-4cf3b7d763b0/output/arm64-apple-darwin/bitcoin-4cf3b7d763b0-arm64-apple-darwin-unsigned.tar.gz
  534b83732ff90bca57e748b25465f8d3d52d653e7ca52cf4ce2226e5bed814fc  guix-build-4cf3b7d763b0/output/arm64-apple-darwin/bitcoin-4cf3b7d763b0-arm64-apple-darwin.tar.gz
  38d261b70baf018f8a1ee980fb139451b085dc484516562af4b5ae86a0b71869  guix-build-4cf3b7d763b0/output/dist-archive/bitcoin-4cf3b7d763b0.tar.gz
  e5d08f055f73a1abf5eef0ea4e55098a53e859d0ea7ff29d21a78e30204e8b5c  guix-build-4cf3b7d763b0/output/x86_64-apple-darwin/SHA256SUMS.part
  2388708d670068515bec06219792f34494ab7ac939999572dc4b5d92430e0890  guix-build-4cf3b7d763b0/output/x86_64-apple-darwin/bitcoin-4cf3b7d763b0-x86_64-apple-darwin-unsigned.dmg
  cb43edd02b8eb11c3e9d8bf6baf65b5656577a2f7a2b21374f90c08a196aa608  guix-build-4cf3b7d763b0/output/x86_64-apple-darwin/bitcoin-4cf3b7d763b0-x86_64-apple-darwin-unsigned.tar.gz
  6f443713f2e23da705defddc09c8c66743691841e01d0debe29dad442454e5c8  guix-build-4cf3b7d763b0/output/x86_64-apple-darwin/bitcoin-4cf3b7d763b0-x86_64-apple-darwin.tar.gz
  ```

ACKs for top commit:
  achow101:
    ACK 4cf3b7d763
  jarolrod:
    ACK 4cf3b7d763

Tree-SHA512: fd83e05f5d772cdcd5a92862bd65a85f128492972be0cb441770bcee7764f889f13b1d109988d360bb9b294942c5b14e46258442b1b3fa1b2902ce958015a897
2022-08-05 09:58:22 +01:00
MacroFake
7d82f86341
Merge bitcoin/bitcoin#25650: script: default to necessary tags in test/get_previous_releases.py
21a9e94dbb ci: remove hardcoded tag list from ci scripts (josibake)
d530ba390e doc: update test/README.md (josibake)
614d4682ba script: default to necessary tags in get_previous_releases.py (josibake)

Pull request description:

  Almost every time I need to use this script, I forget the tag list is needed and that a specific set of tags is needed for the backwards compatibility tests to work. I end up wasting time reading through the script and googling to find the tag list before remembering it is in `test/README.md`

  I assume (hope) I'm not the only one this happens to, so I figured it would make more sense to have the script default to downloading/building the necessary tags. This has the added benefit of making the script the source of truth: the script already needs to be updated with the SHA256_SUM of the binary for every new tag that is added, so it makes sense to use `SHA256_SUMS` list as the necessary tag list. This means there is less risk of the README and the script drifting (i.e updating the readme with a new tag and forgetting to update the script, or updating the script and forgetting to update the README). Now all that needs to happen is to update the `SHA256_SUMS` list in the script and everything Just Works (TM)

ACKs for top commit:
  Sjors:
    re-tACK 21a9e94dbb

Tree-SHA512: 97b488227a89a6827584edd251820a7074fad75dfd7f26f1aa5f858e2521d2e02effd0f11e6dc4676e1155d3d5aba6ff94a4b58ffef80dc201376afd5927deb9
2022-08-05 10:51:06 +02:00
fanquake
e038605585
Merge bitcoin/bitcoin#24662: addrman: Use system time instead of adjusted network time
fadd8b2676 addrman: Use system time instead of adjusted network time (MarcoFalke)

Pull request description:

  This changes addrman to use system time for address relay instead of the network adjusted time.

  This is an improvement, because network time has multiple issues:

  * It is non-monotonic, even if the system time is monotonic.
  * It may be wrong, even if the system time is correct.
  * It may be wrong, if the system time is wrong. For example, when the node has limited number of connections (`4`), or the system time is wrong by too much (more than +-70 minutes), or the system time only got wrong after timedata collected more than half of the entries while the time was correct, ...)

  This may slightly degrade addr relay for nodes where timedata successfully adjusted the time. Addr relay can already deal with minor offsets of up to 10 minutes. Offsets larger than this should still allow addr relay and not result in a DoS.

ACKs for top commit:
  dergoegge:
    Code review ACK fadd8b2676

Tree-SHA512: b6c178fa01161544e5bc76c4cb23e11bcc30391f7b7a64accce864923766647bcfce2e8ae21d36fb1ffc1afa07bc46415aca612405bd8d4cc1f319c92a08498f
2022-08-05 09:03:33 +01:00
Luke Dashjr
0cb6d2aec6 Bugfix: Wallet: Document expectations for AddWalletFlags (now InitWalletFlags) correctly 2022-08-05 02:54:15 +00:00
Karl-Johan Alm
db10cf8ae3
rpc/wallet: add simulaterawtransaction RPC
This command iterates over the inputs and outputs of the given transactions, and tallies up the balance change for the given wallet. This can be useful e.g. when verifying that a coin join like transaction doesn't contain unexpected inputs that the wallet will then sign for unintentionally.
2022-08-05 09:48:09 +09:00
MacroFake
2c3115d4f5
Merge bitcoin/bitcoin#25773: test: Target exact weight in MiniWallet _bulk_tx
fa2537cf0a test: Target exact weight in MiniWallet _bulk_tx (MacroFake)

Pull request description:

  Seems better to target the exact weight than a weight that is up to more than 2000 WU larger.

  Also, replace a broad `-acceptnonstdtxn=1` with `-datacarriersize=100000` to document the test assumptions better.

ACKs for top commit:
  theStack:
    Code-review ACK fa2537cf0a

Tree-SHA512: cf02c3082a13195b8aa730866aeaf2575ce01974ae2b0244739d8cfc12e60c66312729ed703bb3214651744166a3b560bfaa8dc302ef46ed79fc4d1fe7fcc214
2022-08-04 19:21:48 +02:00