mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-24 12:41:41 -05:00

a0abcbd382
doc: Mention multipath specifier (Ava Chow)0019f61fc5
tests: Test importing of multipath descriptors (Ava Chow)f97d5c137d
wallet, rpc: Allow importdescriptors to import multipath descriptors (Ava Chow)32dcbca3fb
rpc: Allow importmulti to import multipath descriptors correctly (Ava Chow)64dfe3ce4b
wallet: Move internal to be per key when importing (Ava Chow)1692245525
tests: Multipath descriptors for scantxoutset and deriveaddresses (Ava Chow)cddc0ba9a9
rpc: Have deriveaddresses derive receiving and change (Ava Chow)360456cd22
tests: Multipath descriptors for getdescriptorinfo (Ava Chow)a90eee444c
tests: Add unit tests for multipath descriptors (Ava Chow)1bbf46e2da
descriptors: Change Parse to return vector of descriptors (Ava Chow)0d640c6f02
descriptors: Have ParseKeypath handle multipath specifiers (Ava Chow)a5f39b1034
descriptors: Change ParseScript to return vector of descriptors (Ava Chow)0d55deae15
descriptors: Add DescriptorImpl::Clone (Ava Chow)7e86541f72
descriptors: Add PubkeyProvider::Clone (Ava Chow) Pull request description: It is convenient to have a descriptor which specifies both receiving and change addresses in a single string. However, as discussed in https://github.com/bitcoin/bitcoin/issues/17190#issuecomment-895515768, it is not feasible to use a generic multipath specification like BIP 88 due to combinatorial blow up and that it would result in unexpected descriptors. To resolve that problem, this PR proposes a targeted solution which allows only a single pair of 2 derivation indexes to be inserted in the place of a single derivation index. So instead of two descriptor `wpkh(xpub.../0/0/*)` and `wpkh(xpub.../0/1/*)` to represent receive and change addresses, this could be written as `wpkh(xpub.../0/<0;1>/*)`. The multipath specifier is of the form `<NUM;NUM>`. Each `NUM` can have its own hardened specifier, e.g. `<0;1h>` is valid. The multipath specifier can also only appear in one path index in the derivation path. This results in the parser returning two descriptors. The first descriptor uses the first `NUM` in all pairs present, and the second uses the second `NUM`. In our implementation, if a multipath descriptor is not provided, a pair is still returned, but the second element is just `nullptr`. The wallet will not output the multipath descriptors (yet). Furthermore, when a multipath descriptor is imported, it is expanded to the two descriptors and each imported on its own, with the second descriptor being implicitly for internal (change) addresses. There is no change to how the wallet stores or outputs descriptors (yet). Note that the path specifier is different from what was proposed. It uses angle brackets and the semicolon because these are unused characters available in the character set and I wanted to avoid conflicts with characters already in use in descriptors. Closes #17190 ACKs for top commit: darosior: re-ACKa0abcbd382
mjdietzx: reACKa0abcbd382
pythcoiner: reACKa0abcbd
furszy: Code review ACKa0abcbd
glozow: light code review ACKa0abcbd382
Tree-SHA512: 84ea40b3fd1b762194acd021cae018c2f09b98e595f5e87de5c832c265cfe8a6d0bc4dae25785392fa90db0f6301ddf9aea787980a29c74f81d04b711ac446c2
37 lines
2.1 KiB
C++
37 lines
2.1 KiB
C++
// Copyright (c) 2019-2022 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <bench/bench.h>
|
|
#include <key.h>
|
|
#include <script/descriptor.h>
|
|
#include <script/script.h>
|
|
#include <script/signingprovider.h>
|
|
|
|
#include <cassert>
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
static void ExpandDescriptor(benchmark::Bench& bench)
|
|
{
|
|
ECC_Context ecc_context{};
|
|
|
|
const auto desc_str = "sh(wsh(multi(16,03669b8afcec803a0d323e9a17f3ea8e68e8abe5a278020a929adbec52421adbd0,0260b2003c386519fc9eadf2b5cf124dd8eea4c4e68d5e154050a9346ea98ce600,0362a74e399c39ed5593852a30147f2959b56bb827dfa3e60e464b02ccf87dc5e8,0261345b53de74a4d721ef877c255429961b7e43714171ac06168d7e08c542a8b8,02da72e8b46901a65d4374fe6315538d8f368557dda3a1dcf9ea903f3afe7314c8,0318c82dd0b53fd3a932d16e0ba9e278fcc937c582d5781be626ff16e201f72286,0297ccef1ef99f9d73dec9ad37476ddb232f1238aff877af19e72ba04493361009,02e502cfd5c3f972fe9a3e2a18827820638f96b6f347e54d63deb839011fd5765d,03e687710f0e3ebe81c1037074da939d409c0025f17eb86adb9427d28f0f7ae0e9,02c04d3a5274952acdbc76987f3184b346a483d43be40874624b29e3692c1df5af,02ed06e0f418b5b43a7ec01d1d7d27290fa15f75771cb69b642a51471c29c84acd,036d46073cbb9ffee90473f3da429abc8de7f8751199da44485682a989a4bebb24,02f5d1ff7c9029a80a4e36b9a5497027ef7f3e73384a4a94fbfe7c4e9164eec8bc,02e41deffd1b7cce11cde209a781adcffdabd1b91c0ba0375857a2bfd9302419f3,02d76625f7956a7fc505ab02556c23ee72d832f1bac391bcd2d3abce5710a13d06,0399eb0a5487515802dc14544cf10b3666623762fbed2ec38a3975716e2c29c232)))";
|
|
const std::pair<int64_t, int64_t> range = {0, 1000};
|
|
FlatSigningProvider provider;
|
|
std::string error;
|
|
auto descs = Parse(desc_str, provider, error);
|
|
|
|
bench.run([&] {
|
|
for (int i = range.first; i <= range.second; ++i) {
|
|
std::vector<CScript> scripts;
|
|
bool success = descs[0]->Expand(i, provider, scripts, provider);
|
|
assert(success);
|
|
}
|
|
});
|
|
}
|
|
|
|
BENCHMARK(ExpandDescriptor, benchmark::PriorityLevel::HIGH);
|