feat(core): support threshold and key-list keys in account creation - #1088
Open
jmgomezl wants to merge 1 commit into
Open
feat(core): support threshold and key-list keys in account creation#1088jmgomezl wants to merge 1 commit into
jmgomezl wants to merge 1 commit into
Conversation
`create_account_tool` accepts a single `publicKey`, and `KeyList` / threshold keys appear nowhere in core. An agent therefore cannot create any multi-signature account — no treasury, no m-of-n escrow, no shared account with several approvers — even though multi-signature keys are a first-class Hedera primitive. Adds two optional parameters to `createAccountParameters`: - `publicKeys: string[]` — the members of a multi-signature key - `threshold: number` — how many of them must sign (m-of-n) Without a threshold the resulting `KeyList` requires every key; with one it requires any `threshold` of them. `publicKeys` takes precedence over `publicKey`, and when it is supplied the existing mirror-node / operator-key resolution is skipped entirely. The normalised schema already accepted any `Key`, so `HederaBuilder.createAccount` is unchanged. Only public keys cross the tool boundary, so no private key material passes through an LLM's context. Tests: seven unit tests covering key-list without threshold, m-of-n with threshold, precedence over `publicKey`, no mirror-node lookup when keys are supplied, rejection of out-of-range thresholds, and the unchanged single-key fallback; plus three integration tests that create both key shapes on testnet and assert the resulting account key via the mirror node. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Juan Gomez <jmgomezl@unal.edu.co>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1087
What
create_account_toolaccepts a singlepublicKey, andKeyList/ThresholdKeyappear nowhere inpackages/core. An agent therefore cannot create any multi-signature account — no treasury, no m-of-n escrow, no shared account with several approvers — even though multi-signature keys are a first-class Hedera primitive.This adds two optional parameters to
createAccountParameters:publicKeys: string[]threshold?: numberWithout a threshold the resulting
KeyListrequires every key; with one, anythresholdof them suffices.How
HederaParameterNormaliser.buildMultiSigKey()builds theKeyList, validating that a supplied threshold is within1..publicKeys.length.normaliseCreateAccountshort-circuits the single-key resolution whenpublicKeysis present, so no mirror-node lookup happens in that path.createAccountParametersNormalisedalready accepted anyKey, soHederaBuilder.createAccountis unchanged.Why it is safe
Tests
Unit (
create-account-params-normalization.unit.test.ts) — 7 new:key-list without threshold, m-of-n with threshold, precedence over
publicKey, no mirror-node lookup when keys are supplied, rejection of thresholds of 0 and> n, and the unchanged single-key fallback.Integration (
create-account.integration.test.ts) — 3 new: creates both key shapes on testnet and asserts the resulting account key through the mirror node, plus the invalid-threshold path.(
tests/unit/utils/decimals-utils.unit.test.tsfails on a clean checkout ofmainas well — unrelated to this change.)Known limitation
A flat
publicKeys+thresholdcannot express a nested key such asKeyList[ keyA, ThresholdKey(2, [k1,k2,k3]) ]. A recursive schema would cover it but complicates the JSON Schema exposed to LLM tool definitions, so this PR deliberately covers the flat cases first. Happy to explore nesting if you would prefer that shape.Scope
Account creation only. The same gap exists for token admin/supply/freeze keys,
updateAccountand topics — glad to follow up there if this shape is agreeable.