diff options
Diffstat (limited to 'src/ark/validate.js')
| -rw-r--r-- | src/ark/validate.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ark/validate.js b/src/ark/validate.js index d80ba50..f7aecb9 100644 --- a/src/ark/validate.js +++ b/src/ark/validate.js @@ -22,11 +22,13 @@ const fail = (msg) => { throw new VtxoValidationError(msg); }; // chain: an object with getTxHex(txid) -> hex|null and tipHeight() -> number, // plus getTxStatus(txid) -> {confirmed, block_height} (esplora semantics) -export async function validateVtxo(vtxo, { serverPubkey, chain, expectPubkeys }) { +// allowPolicies: acceptable policy types (default plain pubkey only; lightning +// flows pass ['serverHtlcSend'] / ['serverHtlcRecv'] for their HTLC vtxos) +export async function validateVtxo(vtxo, { serverPubkey, chain, expectPubkeys, allowPolicies = ['pubkey'] }) { const serverHex = hex.encode(serverPubkey); // -- structural -- - if (vtxo.policy.type !== 'pubkey') fail(`unsupported policy: ${vtxo.policy.type}`); + if (!allowPolicies.includes(vtxo.policy.type)) fail(`unsupported policy: ${vtxo.policy.type}`); if (vtxo.serverPubkey !== serverHex) fail('vtxo server pubkey does not match ours'); if (expectPubkeys && !expectPubkeys.includes(vtxo.policy.userPubkey)) { fail('vtxo not paid to one of our keys'); |
