qa: test der paths in PSBT when desc has duplicate signer

This commit is contained in:
Antoine Poinsot 2023-10-24 16:15:52 +02:00
parent 8d213d5e31
commit 2e1c54491e
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304
2 changed files with 41 additions and 0 deletions

View File

@ -156,6 +156,41 @@ def lianad(bitcoind, directory):
lianad.cleanup()
@pytest.fixture
def lianad_same_signer(bitcoind, directory):
"""A simple lianad but the same signer is used for primary and recovery."""
datadir = os.path.join(directory, "lianad")
os.makedirs(datadir, exist_ok=True)
bitcoind_cookie = os.path.join(bitcoind.bitcoin_dir, "regtest", ".cookie")
# We use the same xpub for both paths, but /0/<0;1>/* for the primary and /1/<0;1>/*
# for the recovery.
signer = SingleSigner()
fingerprint = xpub_fingerprint(signer.primary_hd)
xpub = signer.primary_hd.get_xpub()
csv_value = 10
main_desc = Descriptor.from_str(
f"wsh(or_d(pk([{fingerprint}]{xpub}/0/<0;1>/*),and_v(v:pkh([{fingerprint}]{xpub}/1/<0;1>/*),older({csv_value}))))"
)
lianad = Lianad(
datadir,
signer,
main_desc,
bitcoind.rpcport,
bitcoind_cookie,
)
try:
lianad.start()
yield lianad
except Exception:
lianad.cleanup()
raise
lianad.cleanup()
def multi_expression(thresh, keys):
exp = f"multi({thresh},"
for i, key in enumerate(keys):

View File

@ -410,6 +410,12 @@ def test_create_spend(lianad, bitcoind):
assert res_spend_keys.intersection(res_reco_keys) == set()
def test_create_spend_duplicate_signer(lianad_same_signer, bitcoind):
"""Test spend creation (esp. around what bip32 derivations are added to the PSBT) but
with a Liana setup where a single signer is repeated between paths."""
test_create_spend(lianad_same_signer, bitcoind)
def test_list_spend(lianad, bitcoind):
# Start by creating two conflicting Spend PSBTs. The first one will have a change
# output but not the second one.