B1: plm_engine takes the modules without a database (ADR-59)

HD derivation (pure part), PSBT builder, Electrum client/merkle/quorum/scripthash, network
profile, addresses and header checks move to plm_engine; the old stack imports them from
there. A test forbids framework imports in the package.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
davideandClaude Sonnet 5.5 committed 2026-11-16 15:31:47 +01:00
1 parent c9784efa07
commit 3ee60a23da
87 files changed
+290 -260

No files matched your search

+4 -4
View File
@@ -11,7 +11,7 @@ from tests.unit.fake_network import FakeNetwork
from app.db.models import AuditLog, PendingTransaction, Round, RoundConfig, RoundParticipant, User
from app.rounds.scheduler import RoundScheduler, _reserved_payout_outpoints
from app.wallet.hd import derive_pool_address
from app.wallet.psbt_builder import MAX_TX_INPUTS
from plm_engine.psbt_builder import MAX_TX_INPUTS
class FakeListener:
@@ -195,7 +195,7 @@ async def test_trigger_payout_always_carries_a_bump_reserve_to_the_reserve_addre
and the payout spends them all, yet the transaction has three outputs — winner, fee
address, reserve at m/84'/746'/0'/1/0 — and the round records the reserve before the
broadcast. Nothing is created or lost to the satoshi."""
from app.wallet.psbt_builder import estimate_vsize, payout_bump_reserve
from plm_engine.psbt_builder import estimate_vsize, payout_bump_reserve
await _seed_paying_out_round(payout_session_factory)
entries = [{"tx_hash": "34" * 32, "tx_pos": 0, "height": 10, "value": _POOL_AMOUNT_SATS}] # no excess
@@ -208,7 +208,7 @@ async def test_trigger_payout_always_carries_a_bump_reserve_to_the_reserve_addre
round_ = await session.get(Round, 1)
pending = (await session.scalars(select(PendingTransaction))).one()
tx = Transaction.parse(bytes.fromhex(pending.raw_tx_hex))
from app.wallet.plm_network import PLM_MAINNET
from plm_engine.network import PLM_MAINNET
addresses = [o.script_pubkey.address(network=PLM_MAINNET) for o in tx.vout]
assert addresses == [_WINNER_ADDRESS, _FEE_ADDRESS, derive_pool_address()] # reserve = 1/0
@@ -649,7 +649,7 @@ async def test_a_round_without_participants_closes_and_reveals_its_secret(sessio
round_ = await session.get(Round, round_id)
assert round_.status == "closed"
assert round_.server_seed is not None
from app.rounds.draw import server_seed_commitment
from plm_engine.draw import server_seed_commitment
assert server_seed_commitment(round_.server_seed) == round_.server_seed_hash