mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
953b6706f4
c7b7e0a69265946aecc885be911c7650911ba2e3 tests: Make only desc wallets for wallet_multwallet.py --descriptors (Andrew Chow) d4b67ad214ada7645c4ce2d5ec336fe5c3f7f7ca Avoid creating legacy wallets in wallet_importdescriptors.py (Andrew Chow) 6c9c12bf87f95066acc28ea2270a00196eb77703 Update feature_backwards_compatibility for descriptor wallets (Andrew Chow) 9a4c631e1c00eb1661c000978b133d7aa0226290 Update wallet_labels.py to not require descriptors=False (Andrew Chow) 242aed7cc1d003e8fed574bbebd19c7e54e23402 tests: Add a --legacy-wallet that is mutually exclusive with --descriptors (Andrew Chow) 388053e1722632c2e485c56a444bc75cf0152188 Disable some tests for tool_wallet when descriptors (Andrew Chow) 47d3243160fdec7e464cfb8f869be7f5d4ee25fe Make raw multisig tests legacy wallet only in rpc_rawtransaction.py (Andrew Chow) 59d3da5bce4ebd9c2291d8f201a53ee087938b21 Do addmultisigaddress tests in legacy wallet mode in wallet_address_types.py (Andrew Chow) 25bc5dccbfd52691adca6edd418dd54290300c28 Use importdescriptors when in descriptor wallet mode in wallet_createwallet.py (Andrew Chow) 0bd1860300b13b12a25d330ba3a93ff2d13aa379 Avoid dumpprivkey and watchonly behavior in rpc_signrawtransaction.py (Andrew Chow) 08067aebfd7e838e6ce6b030c31a69422260fc6f Add script equivalent of functions in address.py (Andrew Chow) 86968882a8a26312a7af29c572313c4aff488c11 Add descriptor wallet output to tool_wallet.py (Andrew Chow) 3457679870e8eff2a7d14fe59a479692738c48b6 Use separate watchonly wallet for multisig in feature_nulldummy.py (Andrew Chow) a42652ec10c733a5bf37e418e45d4841f54331b4 Move import and watchonly tests to be legacy wallet only in wallet_balance.py (Andrew Chow) 4b871909d6e4a51888e062d322bf53263deda15e Use importdescriptors for descriptor wallets in wallet_bumpfee.py (Andrew Chow) c2711e4230d9a423ead24f6609691fb338b1d26b Avoid dumpprivkey in wallet_listsinceblock.py (Andrew Chow) 553dbf9af4dea96e6a3e79bba9607003342029bd Make import tests in wallet_listtransactions.py legacy wallet only (Andrew Chow) dc81418fd01021070f3f66bab5fee1484456691a Use a separate watchonly wallet in rpc_fundrawtransaction.py (Andrew Chow) a357111047411f18c156cd34a002a38430f2901c Update wallet_importprunedfunds to avoid dumpprivkey (Andrew Chow) Pull request description: I went through all the tests and checked whether they passed with descriptor wallets. This partially informed some changes in #16528. Some tests needed changes to work with descriptor wallets. These were primarily due to import and watchonly behavior. There are some tests and test cases that only test legacy wallet behavior so those tests won't be run with descriptor wallets. This PR updates more tests to have to the `--descriptors` switch in `test_runner.py`. Additionally a mutually exclusive `--legacy-wallet` option has been added to force legacy wallets. This does nothing currently but will be useful in the future when descriptor wallets are the default. For the tests that rely on legacy wallet behavior, this option is being set so that we don't forget in the future. Those tests are `feature_segwit.py`, `wallet_watchonly.py`, `wallet_implicitsegwit.py`, `wallet_import_with_label.py`, and `wallet_import_with_label.py`. If you invert the `--descriptors`/`--legacy-wallet` default so that descriptor wallets are the default, all tests (besides the legacy wallet specific ones) will pass. ACKs for top commit: MarcoFalke: review ACK c7b7e0a69265946aecc885be911c7650911ba2e3 🎿 laanwj: ACK c7b7e0a69265946aecc885be911c7650911ba2e3 Tree-SHA512: 2f4e87815005d1d0a2543ea7947f7cd7593d8cf5312228ef85f8e096f19739b225769961943049cb44f6f07a35b8de988e2246ab9aca5bb5a0b2e62694d5637d
58 lines
2.4 KiB
Python
Executable File
58 lines
2.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2019 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
"""Useful Script constants and utils."""
|
|
from test_framework.script import CScript, hash160, OP_DUP, OP_HASH160, OP_CHECKSIG, OP_EQUAL, OP_EQUALVERIFY
|
|
from test_framework.util import hex_str_to_bytes
|
|
|
|
# To prevent a "tx-size-small" policy rule error, a transaction has to have a
|
|
# size of at least 83 bytes (MIN_STANDARD_TX_SIZE in
|
|
# src/policy/policy.h). Considering a Tx with the smallest possible single
|
|
# input (blank, empty scriptSig), and with an output omitting the scriptPubKey,
|
|
# we get to a minimum size of 60 bytes:
|
|
#
|
|
# Tx Skeleton: 4 [Version] + 1 [InCount] + 1 [OutCount] + 4 [LockTime] = 10 bytes
|
|
# Blank Input: 32 [PrevTxHash] + 4 [Index] + 1 [scriptSigLen] + 4 [SeqNo] = 41 bytes
|
|
# Output: 8 [Amount] + 1 [scriptPubKeyLen] = 9 bytes
|
|
#
|
|
# Hence, the scriptPubKey of the single output has to have a size of at
|
|
# least 23 bytes, which corresponds to the size of a P2SH scriptPubKey.
|
|
# The following script constant consists of a single push of 22 bytes of 'a':
|
|
# <PUSH_22> <22-bytes of 'a'>
|
|
# resulting in a 23-byte size. It should be used whenever (small) fake
|
|
# scriptPubKeys are needed, to guarantee that the minimum transaction size is
|
|
# met.
|
|
DUMMY_P2SH_SCRIPT = CScript([b'a' * 22])
|
|
DUMMY_2_P2SH_SCRIPT = CScript([b'b' * 22])
|
|
|
|
def keyhash_to_p2pkh_script(hash, main = False):
|
|
assert len(hash) == 20
|
|
return CScript([OP_DUP, OP_HASH160, hash, OP_EQUALVERIFY, OP_CHECKSIG])
|
|
|
|
def scripthash_to_p2sh_script(hash, main = False):
|
|
assert len(hash) == 20
|
|
return CScript([OP_HASH160, hash, OP_EQUAL])
|
|
|
|
def key_to_p2pkh_script(key, main = False):
|
|
key = check_key(key)
|
|
return keyhash_to_p2pkh_script(hash160(key), main)
|
|
|
|
def script_to_p2sh_script(script, main = False):
|
|
script = check_script(script)
|
|
return scripthash_to_p2sh_script(hash160(script), main)
|
|
|
|
def check_key(key):
|
|
if isinstance(key, str):
|
|
key = hex_str_to_bytes(key) # Assuming this is hex string
|
|
if isinstance(key, bytes) and (len(key) == 33 or len(key) == 65):
|
|
return key
|
|
assert False
|
|
|
|
def check_script(script):
|
|
if isinstance(script, str):
|
|
script = hex_str_to_bytes(script) # Assuming this is hex string
|
|
if isinstance(script, bytes) or isinstance(script, CScript):
|
|
return script
|
|
assert False
|