Skip to content

Commit 7574c0e

Browse files
warmidrisclaude
authored andcommitted
fix: use full contractId as SIP-018 domain name
The Clarity contract derives its domain hash using `current-contract` which serializes as the full principal ("SP....contract-name"). The previous `deriveSip018Domain` extracted only the contract-name segment, producing a domain that would fail on-chain secp256k1 signature verification in force-close disputes and cooperative closes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9ecc60e commit 7574c0e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/stackflow-agent/src/aibtc-adapter.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,17 @@ function deriveSip018Domain(contract) {
163163
return { name: "stackflow", version: "1.0.0" };
164164
}
165165

166-
const [, rawName = contractText] = contractText.split(".");
167-
const name = rawName || "stackflow";
168-
169-
const versionMatch = name.match(/(\d+)-(\d+)-(\d+)$/);
166+
// The Clarity contract defines its domain as:
167+
// { name: (to-ascii? current-contract), version: "0.6.0", chain-id: chain-id }
168+
// `current-contract` serializes as the full principal: "SP....contract-name".
169+
// Use the full contractId as the domain name to match on-chain verification.
170+
const [, contractName = contractText] = contractText.split(".");
171+
const versionMatch = contractName.match(/(\d+)-(\d+)-(\d+)$/);
170172
const version = versionMatch
171173
? `${versionMatch[1]}.${versionMatch[2]}.${versionMatch[3]}`
172174
: "1.0.0";
173175

174-
return { name, version };
176+
return { name: contractText, version };
175177
}
176178

177179
export class AibtcWalletAdapter {

0 commit comments

Comments
 (0)