// Revocation keys are derived per commitment (simplified here)
function buildToLocalScript(
localPubkey: Uint8Array,
revocationPubkey: Uint8Array,
delay: bigint
) {
// Revocation path: counterparty can punish old state
const revocationPath = Script.encode([
revocationPubkey,
'CHECKSIG'
]);
// Normal path: broadcaster claims after delay
const normalPath = Script.encode([
delay,
'CHECKSEQUENCEVERIFY',
'DROP',
localPubkey,
'CHECKSIG'
]);
// Ark unilateral exit variant
const unilateralPath = Script.encode([
exitDelay,
'CHECKSEQUENCEVERIFY',
'DROP',
delay,
'CHECKSEQUENCEVERIFY',
'DROP',
localPubkey,
'CHECKSIG'
]);
return new VtxoScript([revocationPath, normalPath, unilateralPath]);
}
// Alice's to_local in her commitment
const aliceRevocationPubkey = /* derived from Bob's revocation basepoint */;
const aliceToLocal = buildToLocalScript(alicePubkey, aliceRevocationPubkey, toLocalDelay);