0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-05 14:06:27 -05:00

Apply label to all scriptPubKeys of imported combo()

This commit is contained in:
Andrew Chow 2022-08-25 15:40:08 -04:00
parent 6b56873b41
commit e664af2976
2 changed files with 12 additions and 8 deletions

View file

@ -3632,11 +3632,15 @@ ScriptPubKeyMan* CWallet::AddWalletDescriptor(WalletDescriptor& desc, const Flat
return nullptr; return nullptr;
} }
if (!internal) {
for (const auto& script : script_pub_keys) {
CTxDestination dest; CTxDestination dest;
if (!internal && ExtractDestination(script_pub_keys.at(0), dest)) { if (ExtractDestination(script, dest)) {
SetAddressBook(dest, label, "receive"); SetAddressBook(dest, label, "receive");
} }
} }
}
}
// Save the descriptor to DB // Save the descriptor to DB
spk_man->WriteDescriptor(); spk_man->WriteDescriptor();

View file

@ -68,7 +68,7 @@ class ToolWalletTest(BitcoinTestFramework):
result = 'unchanged' if new == old else 'increased!' result = 'unchanged' if new == old else 'increased!'
self.log.debug('Wallet file timestamp {}'.format(result)) self.log.debug('Wallet file timestamp {}'.format(result))
def get_expected_info_output(self, name="", transactions=0, keypool=2, address=0): def get_expected_info_output(self, name="", transactions=0, keypool=2, address=0, imported_privs=0):
wallet_name = self.default_wallet_name if name == "" else name wallet_name = self.default_wallet_name if name == "" else name
if self.options.descriptors: if self.options.descriptors:
output_types = 4 # p2pkh, p2sh, segwit, bech32m output_types = 4 # p2pkh, p2sh, segwit, bech32m
@ -83,7 +83,7 @@ class ToolWalletTest(BitcoinTestFramework):
Keypool Size: %d Keypool Size: %d
Transactions: %d Transactions: %d
Address Book: %d Address Book: %d
''' % (wallet_name, keypool * output_types, transactions, address)) ''' % (wallet_name, keypool * output_types, transactions, imported_privs * 3 + address))
else: else:
output_types = 3 # p2pkh, p2sh, segwit. Legacy wallets do not support bech32m. output_types = 3 # p2pkh, p2sh, segwit. Legacy wallets do not support bech32m.
return textwrap.dedent('''\ return textwrap.dedent('''\
@ -97,7 +97,7 @@ class ToolWalletTest(BitcoinTestFramework):
Keypool Size: %d Keypool Size: %d
Transactions: %d Transactions: %d
Address Book: %d Address Book: %d
''' % (wallet_name, keypool, transactions, address * output_types)) ''' % (wallet_name, keypool, transactions, (address + imported_privs) * output_types))
def read_dump(self, filename): def read_dump(self, filename):
dump = OrderedDict() dump = OrderedDict()
@ -219,7 +219,7 @@ class ToolWalletTest(BitcoinTestFramework):
# shasum_before = self.wallet_shasum() # shasum_before = self.wallet_shasum()
timestamp_before = self.wallet_timestamp() timestamp_before = self.wallet_timestamp()
self.log.debug('Wallet file timestamp before calling info: {}'.format(timestamp_before)) self.log.debug('Wallet file timestamp before calling info: {}'.format(timestamp_before))
out = self.get_expected_info_output(address=1) out = self.get_expected_info_output(imported_privs=1)
self.assert_tool_output(out, '-wallet=' + self.default_wallet_name, 'info') self.assert_tool_output(out, '-wallet=' + self.default_wallet_name, 'info')
timestamp_after = self.wallet_timestamp() timestamp_after = self.wallet_timestamp()
self.log.debug('Wallet file timestamp after calling info: {}'.format(timestamp_after)) self.log.debug('Wallet file timestamp after calling info: {}'.format(timestamp_after))
@ -250,7 +250,7 @@ class ToolWalletTest(BitcoinTestFramework):
shasum_before = self.wallet_shasum() shasum_before = self.wallet_shasum()
timestamp_before = self.wallet_timestamp() timestamp_before = self.wallet_timestamp()
self.log.debug('Wallet file timestamp before calling info: {}'.format(timestamp_before)) self.log.debug('Wallet file timestamp before calling info: {}'.format(timestamp_before))
out = self.get_expected_info_output(transactions=1, address=1) out = self.get_expected_info_output(transactions=1, imported_privs=1)
self.assert_tool_output(out, '-wallet=' + self.default_wallet_name, 'info') self.assert_tool_output(out, '-wallet=' + self.default_wallet_name, 'info')
shasum_after = self.wallet_shasum() shasum_after = self.wallet_shasum()
timestamp_after = self.wallet_timestamp() timestamp_after = self.wallet_timestamp()