@aztec/cli 6.0.0-nightly.20260722 → 6.0.0-nightly.20260724
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/cmds/validator_keys/index.d.ts +1 -1
- package/dest/cmds/validator_keys/index.d.ts.map +1 -1
- package/dest/cmds/validator_keys/index.js +6 -6
- package/dest/cmds/validator_keys/new.d.ts +2 -1
- package/dest/cmds/validator_keys/new.d.ts.map +1 -1
- package/dest/cmds/validator_keys/new.js +21 -5
- package/dest/cmds/validator_keys/set_funding_account.d.ts +14 -0
- package/dest/cmds/validator_keys/set_funding_account.d.ts.map +1 -0
- package/dest/cmds/validator_keys/set_funding_account.js +37 -0
- package/dest/cmds/validator_keys/shared.d.ts +15 -2
- package/dest/cmds/validator_keys/shared.d.ts.map +1 -1
- package/dest/cmds/validator_keys/shared.js +34 -0
- package/dest/cmds/validator_keys/utils.d.ts +12 -2
- package/dest/cmds/validator_keys/utils.d.ts.map +1 -1
- package/dest/cmds/validator_keys/utils.js +34 -0
- package/package.json +30 -30
- package/src/cmds/validator_keys/index.ts +30 -4
- package/src/cmds/validator_keys/new.ts +22 -1
- package/src/cmds/validator_keys/set_funding_account.ts +55 -0
- package/src/cmds/validator_keys/shared.ts +37 -1
- package/src/cmds/validator_keys/utils.ts +44 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { LogFn } from '@aztec/foundation/log';
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
export declare function injectCommands(program: Command, log: LogFn): Command;
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jbWRzL3ZhbGlkYXRvcl9rZXlzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRW5ELE9BQU8sRUFBRSxPQUFPLEVBQVUsTUFBTSxXQUFXLENBQUM7QUFLNUMsd0JBQWdCLGNBQWMsQ0FBQyxPQUFPLEVBQUUsT0FBTyxFQUFFLEdBQUcsRUFBRSxLQUFLLFdBOEsxRCJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAK5C,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAK5C,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,WA8K1D"}
|
|
@@ -6,18 +6,18 @@ export function injectCommands(program, log) {
|
|
|
6
6
|
'valKeys',
|
|
7
7
|
'valkeys'
|
|
8
8
|
]).description('Manage validator keystores for node operators');
|
|
9
|
-
group.command('new').summary('Generate a new validator keystore JSON').description('Generates a new validator keystore with ETH secp256k1 accounts and optional BLS accounts').option('--data-dir <path>', 'Directory to store keystore(s). Defaults to ~/.aztec/keystore').option('--file <name>', 'Keystore file name. Defaults to key1.json (or keyN.json if key1.json exists)').option('--count <N>', 'Number of validators to generate', parseOptionalInteger).option('--publisher-count <N>', 'Number of publisher accounts per validator (default 0)', (value)=>parseOptionalInteger(value, 0)).option('--publishers <privateKeys>', 'Comma-separated list of publisher private keys for all validators.', (value)=>value.split(',').map((key)=>key.trim())).option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation').option('--passphrase <str>', 'Optional passphrase for mnemonic').option('--account-index <N>', 'Base account index for ETH/BLS derivation', parseOptionalInteger).option('--address-index <N>', 'Base address index for ETH/BLS derivation', parseOptionalInteger).option('--coinbase <address>', 'Coinbase ETH address to use when proposing. Defaults to attester address.', parseEthereumAddress)
|
|
10
|
-
// .option('--funding-account <privateKey|address>', 'ETH private key (or address for remote signer setup) to fund publishers')
|
|
11
|
-
.option('--remote-signer <url>', 'Default remote signer URL for accounts in this file').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`).addOption(new Option('--password <str>', 'Shared password for writing ETH JSON V3 and BLS EIP-2335 keystore files').env('AZTEC_KEYSTORE_PASSWORD')).option('--password-file <path>', 'File containing the shared password for writing keystore files').addOption(new Option('--eth-password <str>', 'Password for writing ETH JSON V3 keystore files').env('AZTEC_ETH_KEYSTORE_PASSWORD')).option('--eth-password-file <path>', 'File containing the password for writing ETH JSON V3 keystore files').addOption(new Option('--bls-password <str>', 'Password for writing BLS EIP-2335 keystore files').env('AZTEC_BLS_KEYSTORE_PASSWORD')).option('--bls-password-file <path>', 'File containing the password for writing BLS EIP-2335 keystore files').option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)').option('--json', 'Echo resulting JSON to stdout').option('--staker-output', 'Generate a single staker output JSON file with an array of validator entries').option('--gse-address <address>', 'GSE contract address (required with --staker-output)', parseEthereumAddress).option('--l1-rpc-urls <urls>', 'L1 RPC URLs (comma-separated, required with --staker-output)', (value)=>value.split(',')).option('-c, --l1-chain-id <number>', 'L1 chain ID (required with --staker-output)', (value)=>parseInt(value), 31337).requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress).action(async (options)=>{
|
|
9
|
+
group.command('new').summary('Generate a new validator keystore JSON').description('Generates a new validator keystore with ETH secp256k1 accounts and optional BLS accounts').option('--data-dir <path>', 'Directory to store keystore(s). Defaults to ~/.aztec/keystore').option('--file <name>', 'Keystore file name. Defaults to key1.json (or keyN.json if key1.json exists)').option('--count <N>', 'Number of validators to generate', parseOptionalInteger).option('--publisher-count <N>', 'Number of publisher accounts per validator (default 0)', (value)=>parseOptionalInteger(value, 0)).option('--publishers <privateKeys>', 'Comma-separated list of publisher private keys for all validators.', (value)=>value.split(',').map((key)=>key.trim())).option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation').option('--passphrase <str>', 'Optional passphrase for mnemonic').option('--account-index <N>', 'Base account index for ETH/BLS derivation', parseOptionalInteger).option('--address-index <N>', 'Base address index for ETH/BLS derivation', parseOptionalInteger).option('--coinbase <address>', 'Coinbase ETH address to use when proposing. Defaults to attester address.', parseEthereumAddress).option('--funding-account <privateKey|address>', 'ETH funding account used to top up publisher EOAs. Provide a private key, or an address together with --remote-signer.').option('--remote-signer <url>', 'Default remote signer URL for accounts in this file').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`).addOption(new Option('--password <str>', 'Shared password for writing ETH JSON V3 and BLS EIP-2335 keystore files').env('AZTEC_KEYSTORE_PASSWORD')).option('--password-file <path>', 'File containing the shared password for writing keystore files').addOption(new Option('--eth-password <str>', 'Password for writing ETH JSON V3 keystore files').env('AZTEC_ETH_KEYSTORE_PASSWORD')).option('--eth-password-file <path>', 'File containing the password for writing ETH JSON V3 keystore files').addOption(new Option('--bls-password <str>', 'Password for writing BLS EIP-2335 keystore files').env('AZTEC_BLS_KEYSTORE_PASSWORD')).option('--bls-password-file <path>', 'File containing the password for writing BLS EIP-2335 keystore files').option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)').option('--json', 'Echo resulting JSON to stdout').option('--staker-output', 'Generate a single staker output JSON file with an array of validator entries').option('--gse-address <address>', 'GSE contract address (required with --staker-output)', parseEthereumAddress).option('--l1-rpc-urls <urls>', 'L1 RPC URLs (comma-separated, required with --staker-output)', (value)=>value.split(',')).option('-c, --l1-chain-id <number>', 'L1 chain ID (required with --staker-output)', (value)=>parseInt(value), 31337).requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress).action(async (options)=>{
|
|
12
10
|
const { newValidatorKeystore } = await import('./new.js');
|
|
13
11
|
await newValidatorKeystore(options, log);
|
|
14
12
|
});
|
|
15
|
-
group.command('add').summary('Augment an existing validator keystore JSON').description('Adds attester/publisher/BLS entries to an existing keystore using the same flags as new').argument('<existing>', 'Path to existing keystore JSON').option('--data-dir <path>', 'Directory where keystore(s) live. (default: ~/.aztec/keystore)').option('--file <name>', 'Override output file name. (default: key<N>.json)').option('--count <N>', 'Number of validators to add. (default: 1)', parseOptionalInteger).option('--publisher-count <N>', 'Number of publisher accounts per validator (default 0)', (value)=>parseOptionalInteger(value, 0)).option('--publishers <privateKeys>', 'Comma-separated list of publisher private keys for all validators.', (value)=>value.split(',').map((key)=>key.trim())).option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation').option('--passphrase <str>', 'Optional passphrase for mnemonic').option('--account-index <N>', 'Base account index for ETH/BLS derivation', parseOptionalInteger).option('--address-index <N>', 'Base address index for ETH/BLS derivation', parseOptionalInteger).option('--coinbase <address>', 'Coinbase ETH address to use when proposing. Defaults to attester address.', parseEthereumAddress)
|
|
16
|
-
// .option('--funding-account <privateKey|address>', 'ETH private key (or address for remote signer setup) to fund publishers')
|
|
17
|
-
.option('--remote-signer <url>', 'Default remote signer URL for accounts in this file').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`).option('--empty', 'Generate an empty skeleton without keys').option('--password <str>', 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed').option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)').option('--json', 'Echo resulting JSON to stdout').requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress).action(async (existing, options)=>{
|
|
13
|
+
group.command('add').summary('Augment an existing validator keystore JSON').description('Adds attester/publisher/BLS entries to an existing keystore using the same flags as new').argument('<existing>', 'Path to existing keystore JSON').option('--data-dir <path>', 'Directory where keystore(s) live. (default: ~/.aztec/keystore)').option('--file <name>', 'Override output file name. (default: key<N>.json)').option('--count <N>', 'Number of validators to add. (default: 1)', parseOptionalInteger).option('--publisher-count <N>', 'Number of publisher accounts per validator (default 0)', (value)=>parseOptionalInteger(value, 0)).option('--publishers <privateKeys>', 'Comma-separated list of publisher private keys for all validators.', (value)=>value.split(',').map((key)=>key.trim())).option('--mnemonic <mnemonic>', 'Mnemonic for ETH/BLS derivation').option('--passphrase <str>', 'Optional passphrase for mnemonic').option('--account-index <N>', 'Base account index for ETH/BLS derivation', parseOptionalInteger).option('--address-index <N>', 'Base address index for ETH/BLS derivation', parseOptionalInteger).option('--coinbase <address>', 'Coinbase ETH address to use when proposing. Defaults to attester address.', parseEthereumAddress).option('--remote-signer <url>', 'Default remote signer URL for accounts in this file').option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', (value)=>parseHex(value, 32)).option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`).option('--empty', 'Generate an empty skeleton without keys').option('--password <str>', 'Password for writing keystore files (ETH JSON V3 and BLS EIP-2335). Empty string allowed').option('--encrypted-keystore-dir <dir>', 'Output directory for encrypted keystore file(s)').option('--json', 'Echo resulting JSON to stdout').requiredOption('--fee-recipient <address>', 'Aztec address that will receive fees', parseAztecAddress).action(async (existing, options)=>{
|
|
18
14
|
const { addValidatorKeys } = await import('./add.js');
|
|
19
15
|
await addValidatorKeys(existing, options, log);
|
|
20
16
|
});
|
|
17
|
+
group.command('set-funding-account').summary('Set the funding account of an existing keystore').description('Sets the keystore-level ETH funding account used to top up publisher EOAs, replacing any existing one').argument('<existing>', 'Path to existing keystore JSON').argument('<privateKey|address>', 'Funding account: a private key, or an address (needs --remote-signer unless the keystore already defines one)').option('--remote-signer <url>', 'Remote signer URL for the funding account (required with an address unless the keystore already defines one)').option('--password <str>', 'Password for writing the funding key as an encrypted ETH JSON V3 file. Empty string allowed').option('--encrypted-keystore-dir <dir>', 'Output directory for the encrypted funding key file').option('--json', 'Echo resulting JSON to stdout').action(async (existing, fundingAccount, options)=>{
|
|
18
|
+
const { setFundingAccount } = await import('./set_funding_account.js');
|
|
19
|
+
await setFundingAccount(existing, fundingAccount, options, log);
|
|
20
|
+
});
|
|
21
21
|
group.command('staker').summary('Generate staking JSON from keystore').description('Reads a validator keystore and outputs staking data with BLS public keys for each attester (skips mnemonics)').requiredOption('--from <keystore>', 'Path to keystore JSON file').option('--password <password>', 'Password for decrypting encrypted keystores (if not specified in keystore file)').requiredOption('--gse-address <address>', 'GSE contract address', parseEthereumAddress).option('--l1-rpc-urls <urls>', 'L1 RPC URLs (comma-separated)', (value)=>value.split(','), [
|
|
22
22
|
'http://localhost:8545'
|
|
23
23
|
]).option('-c, --l1-chain-id <number>', 'L1 chain ID', (value)=>parseInt(value), 31337).option('--output <file>', 'Output file path (if not specified, JSON is written to stdout)').action(async (options)=>{
|
|
@@ -24,6 +24,7 @@ export type NewValidatorKeystoreOptions = {
|
|
|
24
24
|
json?: boolean;
|
|
25
25
|
feeRecipient: AztecAddress;
|
|
26
26
|
coinbase?: EthAddress;
|
|
27
|
+
fundingAccount?: string;
|
|
27
28
|
remoteSigner?: string;
|
|
28
29
|
stakerOutput?: boolean;
|
|
29
30
|
gseAddress?: EthAddress;
|
|
@@ -31,4 +32,4 @@ export type NewValidatorKeystoreOptions = {
|
|
|
31
32
|
l1ChainId?: number;
|
|
32
33
|
};
|
|
33
34
|
export declare function newValidatorKeystore(options: NewValidatorKeystoreOptions, log: LogFn): Promise<void>;
|
|
34
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
35
|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ckIsZUFBZSxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ3pCLFdBQVcsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUNyQixlQUFlLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDekIsb0JBQW9CLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDOUIsSUFBSSxDQUFDLEVBQUUsT0FBTyxDQUFDO0lBQ2YsWUFBWSxFQUFFLFlBQVksQ0FBQztJQUMzQixRQUFRLENBQUMsRUFBRSxVQUFVLENBQUM7SUFDdEIsY0FBYyxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ3hCLFlBQVksQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUN0QixZQUFZLENBQUMsRUFBRSxPQUFPLENBQUM7SUFDdkIsVUFBVSxDQUFDLEVBQUUsVUFBVSxDQUFDO0lBQ3hCLFNBQVMsQ0FBQyxFQUFFLE1BQU0sRUFBRSxDQUFDO0lBQ3JCLFNBQVMsQ0FBQyxFQUFFLE1BQU0sQ0FBQztDQUNwQixDQUFDO0FBa0ZGLHdCQUFzQixvQkFBb0IsQ0FBQyxPQUFPLEVBQUUsMkJBQTJCLEVBQUUsR0FBRyxFQUFFLEtBQUssaUJBc0wxRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/new.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/new.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM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|
@@ -5,10 +5,10 @@ import { wordlist } from '@scure/bip39/wordlists/english.js';
|
|
|
5
5
|
import { readFile, writeFile } from 'fs/promises';
|
|
6
6
|
import { basename, dirname, join } from 'path';
|
|
7
7
|
import { createPublicClient, fallback, http } from 'viem';
|
|
8
|
-
import { generateMnemonic, mnemonicToAccount } from 'viem/accounts';
|
|
9
|
-
import { buildValidatorEntries, logValidatorSummaries, maybePrintJson, resolveKeystoreOutputPath, writeBlsBn254ToFile, writeEthJsonV3ToFile, writeKeystoreFile } from './shared.js';
|
|
8
|
+
import { generateMnemonic, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
|
|
9
|
+
import { buildValidatorEntries, encryptFundingAccountToFile, logValidatorSummaries, maybePrintJson, resolveFundingAccount, resolveKeystoreOutputPath, writeBlsBn254ToFile, writeEthJsonV3ToFile, writeKeystoreFile } from './shared.js';
|
|
10
10
|
import { processAttesterAccounts } from './staker.js';
|
|
11
|
-
import { validateBlsPathOptions, validatePublisherOptions, validateRemoteSignerOptions, validateStakerOutputOptions } from './utils.js';
|
|
11
|
+
import { validateBlsPathOptions, validateFundingAccountOptions, validatePublisherOptions, validateRemoteSignerOptions, validateStakerOutputOptions } from './utils.js';
|
|
12
12
|
function validatePassword(password, source) {
|
|
13
13
|
if (password.length === 0) {
|
|
14
14
|
throw new Error(`${source} cannot be empty`);
|
|
@@ -79,7 +79,9 @@ export async function newValidatorKeystore(options, log) {
|
|
|
79
79
|
validatePublisherOptions(options);
|
|
80
80
|
// validate remote signer options
|
|
81
81
|
validateRemoteSignerOptions(options);
|
|
82
|
-
|
|
82
|
+
// validate funding account option
|
|
83
|
+
validateFundingAccountOptions(options);
|
|
84
|
+
const { dataDir, file, count, publisherCount = 0, publishers, json, coinbase, fundingAccount, accountIndex = 0, addressIndex = 0, feeRecipient, remoteSigner, blsPath, ikm, mnemonic: _mnemonic, password: passwordOption, passwordFile, ethPassword: ethPasswordOption, ethPasswordFile, blsPassword: blsPasswordOption, blsPasswordFile, encryptedKeystoreDir, stakerOutput, gseAddress, l1RpcUrls, l1ChainId } = options;
|
|
83
85
|
const { ethPassword, blsPassword } = await resolvePasswords({
|
|
84
86
|
password: passwordOption,
|
|
85
87
|
passwordFile,
|
|
@@ -113,6 +115,7 @@ export async function newValidatorKeystore(options, log) {
|
|
|
113
115
|
coinbase,
|
|
114
116
|
remoteSigner
|
|
115
117
|
});
|
|
118
|
+
let resolvedFundingAccount = fundingAccount ? resolveFundingAccount(fundingAccount, remoteSigner) : undefined;
|
|
116
119
|
// If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
|
|
117
120
|
if (shouldEncryptKeystores) {
|
|
118
121
|
const encryptedKeystoreOutDir = encryptedKeystoreDir && encryptedKeystoreDir.length > 0 ? encryptedKeystoreDir : keystoreOutDir;
|
|
@@ -124,10 +127,19 @@ export async function newValidatorKeystore(options, log) {
|
|
|
124
127
|
outDir: encryptedKeystoreOutDir,
|
|
125
128
|
password: blsPassword
|
|
126
129
|
});
|
|
130
|
+
if (resolvedFundingAccount) {
|
|
131
|
+
resolvedFundingAccount = await encryptFundingAccountToFile(resolvedFundingAccount, {
|
|
132
|
+
outDir: encryptedKeystoreOutDir,
|
|
133
|
+
password: ethPassword
|
|
134
|
+
});
|
|
135
|
+
}
|
|
127
136
|
}
|
|
128
137
|
const keystore = {
|
|
129
138
|
schemaVersion: 1,
|
|
130
|
-
validators
|
|
139
|
+
validators,
|
|
140
|
+
...resolvedFundingAccount ? {
|
|
141
|
+
fundingAccount: resolvedFundingAccount
|
|
142
|
+
} : {}
|
|
131
143
|
};
|
|
132
144
|
await writeKeystoreFile(outputPath, keystore);
|
|
133
145
|
// Generate staker outputs if requested
|
|
@@ -185,6 +197,10 @@ export async function newValidatorKeystore(options, log) {
|
|
|
185
197
|
// print a concise summary of public keys (addresses and BLS pubkeys) if no --json options was selected
|
|
186
198
|
if (!json) {
|
|
187
199
|
logValidatorSummaries(log, summaries);
|
|
200
|
+
if (fundingAccount) {
|
|
201
|
+
const funderAddress = fundingAccount.length === 66 ? privateKeyToAccount(fundingAccount).address : fundingAccount;
|
|
202
|
+
log(`funding account: ${funderAddress}`);
|
|
203
|
+
}
|
|
188
204
|
}
|
|
189
205
|
if (mnemonic && remoteSigner && !json) {
|
|
190
206
|
for(let i = 0; i < validatorCount; i++){
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
export type SetFundingAccountOptions = {
|
|
3
|
+
remoteSigner?: string;
|
|
4
|
+
password?: string;
|
|
5
|
+
encryptedKeystoreDir?: string;
|
|
6
|
+
json?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Sets the top-level funding account of an existing keystore, replacing any previous one. The
|
|
10
|
+
* account may be a private key, or an address paired with a remote signer URL. With a password,
|
|
11
|
+
* a plaintext key is encrypted to an ETH JSON V3 file and stored as a { path, password } reference.
|
|
12
|
+
*/
|
|
13
|
+
export declare function setFundingAccount(existing: string, fundingAccount: string, options: SetFundingAccountOptions, log: LogFn): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2V0X2Z1bmRpbmdfYWNjb3VudC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NtZHMvdmFsaWRhdG9yX2tleXMvc2V0X2Z1bmRpbmdfYWNjb3VudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQVVuRCxNQUFNLE1BQU0sd0JBQXdCLEdBQUc7SUFDckMsWUFBWSxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ3RCLFFBQVEsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUNsQixvQkFBb0IsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUM5QixJQUFJLENBQUMsRUFBRSxPQUFPLENBQUM7Q0FDaEIsQ0FBQztBQUVGOzs7O0dBSUc7QUFDSCx3QkFBc0IsaUJBQWlCLENBQ3JDLFFBQVEsRUFBRSxNQUFNLEVBQ2hCLGNBQWMsRUFBRSxNQUFNLEVBQ3RCLE9BQU8sRUFBRSx3QkFBd0IsRUFDakMsR0FBRyxFQUFFLEtBQUssaUJBNEJYIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set_funding_account.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/set_funding_account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAUnD,MAAM,MAAM,wBAAwB,GAAG;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,wBAAwB,EACjC,GAAG,EAAE,KAAK,iBA4BX"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { loadKeystoreFile } from '@aztec/node-keystore/loader';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
4
|
+
import { encryptFundingAccountToFile, maybePrintJson, resolveFundingAccount, writeKeystoreFile } from './shared.js';
|
|
5
|
+
import { validateFundingAccountOptions } from './utils.js';
|
|
6
|
+
/**
|
|
7
|
+
* Sets the top-level funding account of an existing keystore, replacing any previous one. The
|
|
8
|
+
* account may be a private key, or an address paired with a remote signer URL. With a password,
|
|
9
|
+
* a plaintext key is encrypted to an ETH JSON V3 file and stored as a { path, password } reference.
|
|
10
|
+
*/ export async function setFundingAccount(existing, fundingAccount, options, log) {
|
|
11
|
+
const { remoteSigner, password, encryptedKeystoreDir, json } = options;
|
|
12
|
+
const keystore = loadKeystoreFile(existing);
|
|
13
|
+
const validated = {
|
|
14
|
+
fundingAccount,
|
|
15
|
+
remoteSigner
|
|
16
|
+
};
|
|
17
|
+
validateFundingAccountOptions(validated, !!keystore.remoteSigner);
|
|
18
|
+
let resolved = resolveFundingAccount(validated.fundingAccount, remoteSigner);
|
|
19
|
+
if (password !== undefined) {
|
|
20
|
+
const outDir = encryptedKeystoreDir && encryptedKeystoreDir.length > 0 ? encryptedKeystoreDir : dirname(existing);
|
|
21
|
+
resolved = await encryptFundingAccountToFile(resolved, {
|
|
22
|
+
outDir,
|
|
23
|
+
password
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (keystore.fundingAccount) {
|
|
27
|
+
log('Replacing existing funding account in keystore');
|
|
28
|
+
}
|
|
29
|
+
keystore.fundingAccount = resolved;
|
|
30
|
+
await writeKeystoreFile(existing, keystore);
|
|
31
|
+
if (!json) {
|
|
32
|
+
const value = validated.fundingAccount;
|
|
33
|
+
const funderAddress = value.length === 66 ? privateKeyToAccount(value).address : value;
|
|
34
|
+
log(`Set funding account ${funderAddress} in ${existing}`);
|
|
35
|
+
}
|
|
36
|
+
maybePrintJson(log, !!json, keystore);
|
|
37
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
3
|
import type { EthAccount, EthPrivateKey, ValidatorKeyStore } from '@aztec/node-keystore/types';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -28,6 +28,14 @@ export declare function withValidatorIndex(path: string, accountIndex?: number,
|
|
|
28
28
|
*/
|
|
29
29
|
export declare function computeBlsPublicKeyCompressed(privateKeyHex: string): Promise<string>;
|
|
30
30
|
export declare function deriveEthAttester(mnemonic: string, baseAccountIndex: number, addressIndex: number, remoteSigner?: string): EthAccount | EthPrivateKey;
|
|
31
|
+
/**
|
|
32
|
+
* Resolve a `--funding-account` value into a keystore `EthAccount`. A 66-char value is a private key
|
|
33
|
+
* (used verbatim). A 42-char value is an address: with an explicit `remoteSigner` URL it becomes an
|
|
34
|
+
* `{ address, remoteSignerUrl }` pair; without one it is stored as a bare address that falls back to
|
|
35
|
+
* the keystore-level remote signer at runtime. Callers must validate the value first (see
|
|
36
|
+
* `validateFundingAccountOptions`).
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveFundingAccount(fundingAccount: string, remoteSigner?: string): EthAccount;
|
|
31
39
|
export declare function buildValidatorEntries(input: BuildValidatorsInput): Promise<{
|
|
32
40
|
validators: ValidatorKeyStore[];
|
|
33
41
|
summaries: ValidatorSummary[];
|
|
@@ -60,9 +68,14 @@ export declare function writeBlsBn254ToFile(validators: ValidatorKeyStore[], opt
|
|
|
60
68
|
}): Promise<void>;
|
|
61
69
|
/** Writes an Ethereum JSON V3 keystore using ethers, returns absolute path */
|
|
62
70
|
export declare function writeEthJsonV3Keystore(outDir: string, fileNameBase: string, password: string, privateKeyHex: string): Promise<string>;
|
|
71
|
+
/** Encrypt a plaintext funding-account key to a JSON V3 file, replacing it with a { path, password } reference. */
|
|
72
|
+
export declare function encryptFundingAccountToFile(account: EthAccount, options: {
|
|
73
|
+
outDir: string;
|
|
74
|
+
password: string;
|
|
75
|
+
}): Promise<EthAccount>;
|
|
63
76
|
/** Replace plaintext ETH keys in validators with { path, password } pointing to JSON V3 files. */
|
|
64
77
|
export declare function writeEthJsonV3ToFile(validators: ValidatorKeyStore[], options: {
|
|
65
78
|
outDir: string;
|
|
66
79
|
password: string;
|
|
67
80
|
}): Promise<void>;
|
|
68
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
81
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2hhcmVkLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNl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BQU0sQ0FBQztJQUFDLFFBQVEsRUFBRSxNQUFNLENBQUE7Q0FBRSxHQUM1QyxPQUFPLENBQUMsSUFBSSxDQUFDLENBeUNmIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/shared.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/shared.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AA2DhE,MAAM,MAAM,gBAAgB,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEvG,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,GAAE,MAAU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AAM,CAAA;CAAE,GAC9D,OAAO,CAAC,IAAI,CAAC,CAwBf;AAED,8EAA8E;AAC9E,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,CAAC,CAOjB;AAeD,mHAAmH;AACnH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC5C,OAAO,CAAC,UAAU,CAAC,CAErB;AAED,kGAAkG;AAClG,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,iBAAiB,EAAE,EAC/B,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC5C,OAAO,CAAC,IAAI,CAAC,CAyCf"}
|
|
@@ -3,6 +3,7 @@ import { asyncPool } from '@aztec/foundation/async-pool';
|
|
|
3
3
|
import { deriveBlsPrivateKey } from '@aztec/foundation/crypto/bls';
|
|
4
4
|
import { createBn254Keystore } from '@aztec/foundation/crypto/bls/bn254_keystore';
|
|
5
5
|
import { computeBn254G1PublicKeyCompressed } from '@aztec/foundation/crypto/bn254';
|
|
6
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
7
|
import { Wallet } from '@ethersproject/wallet';
|
|
7
8
|
import { constants as fsConstants, mkdirSync } from 'fs';
|
|
8
9
|
import { access, writeFile } from 'fs/promises';
|
|
@@ -94,6 +95,22 @@ export function deriveEthAttester(mnemonic, baseAccountIndex, addressIndex, remo
|
|
|
94
95
|
remoteSignerUrl: remoteSigner
|
|
95
96
|
} : '0x' + Buffer.from(acct.getHdKey().privateKey).toString('hex');
|
|
96
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Resolve a `--funding-account` value into a keystore `EthAccount`. A 66-char value is a private key
|
|
100
|
+
* (used verbatim). A 42-char value is an address: with an explicit `remoteSigner` URL it becomes an
|
|
101
|
+
* `{ address, remoteSignerUrl }` pair; without one it is stored as a bare address that falls back to
|
|
102
|
+
* the keystore-level remote signer at runtime. Callers must validate the value first (see
|
|
103
|
+
* `validateFundingAccountOptions`).
|
|
104
|
+
*/ export function resolveFundingAccount(fundingAccount, remoteSigner) {
|
|
105
|
+
if (fundingAccount.length === 66) {
|
|
106
|
+
return fundingAccount;
|
|
107
|
+
}
|
|
108
|
+
const address = EthAddress.fromString(fundingAccount);
|
|
109
|
+
return remoteSigner ? {
|
|
110
|
+
address,
|
|
111
|
+
remoteSignerUrl: remoteSigner
|
|
112
|
+
} : address;
|
|
113
|
+
}
|
|
97
114
|
export async function buildValidatorEntries(input) {
|
|
98
115
|
const { validatorCount, publisherCount = 0, publishers, accountIndex, baseAddressIndex, mnemonic, ikm, blsPath, feeRecipient, coinbase, remoteSigner } = input;
|
|
99
116
|
const summaries = [];
|
|
@@ -275,6 +292,23 @@ export function maybePrintJson(log, jsonFlag, obj) {
|
|
|
275
292
|
});
|
|
276
293
|
return outPath;
|
|
277
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* If `account` is a plaintext ETH private key, encrypt it to a JSON V3 file and return a
|
|
297
|
+
* { path, password } reference; otherwise return it unchanged.
|
|
298
|
+
*/ async function maybeEncryptEthAccount(account, label, options) {
|
|
299
|
+
if (typeof account === 'string' && account.startsWith('0x') && account.length === 66) {
|
|
300
|
+
const fileBase = `${label}_${account.slice(2, 10)}`;
|
|
301
|
+
const p = await writeEthJsonV3Keystore(options.outDir, fileBase, options.password, account);
|
|
302
|
+
return {
|
|
303
|
+
path: p,
|
|
304
|
+
password: options.password
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
return account;
|
|
308
|
+
}
|
|
309
|
+
/** Encrypt a plaintext funding-account key to a JSON V3 file, replacing it with a { path, password } reference. */ export async function encryptFundingAccountToFile(account, options) {
|
|
310
|
+
return await maybeEncryptEthAccount(account, 'funding', options);
|
|
311
|
+
}
|
|
278
312
|
/** Replace plaintext ETH keys in validators with { path, password } pointing to JSON V3 files. */ export async function writeEthJsonV3ToFile(validators, options) {
|
|
279
313
|
const tasks = [];
|
|
280
314
|
const maybeQueueEncryptEth = (account, label, setEncryptedAccount)=>{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
export declare const defaultBlsPath = "m/12381/3600/0/0/0";
|
|
3
3
|
export declare function validateBlsPathOptions(options: {
|
|
4
4
|
count?: number;
|
|
@@ -22,4 +22,14 @@ export declare function validatePublisherOptions(options: {
|
|
|
22
22
|
publishers?: string[];
|
|
23
23
|
publisherCount?: number;
|
|
24
24
|
}): void;
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Validates and normalizes the `--funding-account` option in place. The value may be a private key
|
|
27
|
+
* (used as a local signer) or an ETH address. An address needs a remote signer to sign funding txs:
|
|
28
|
+
* either `--remote-signer`, or a keystore that already defines one (pass `hasKeystoreRemoteSigner`),
|
|
29
|
+
* which a bare address inherits at runtime.
|
|
30
|
+
*/
|
|
31
|
+
export declare function validateFundingAccountOptions(options: {
|
|
32
|
+
fundingAccount?: string;
|
|
33
|
+
remoteSigner?: string;
|
|
34
|
+
}, hasKeystoreRemoteSigner?: boolean): void;
|
|
35
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jbWRzL3ZhbGlkYXRvcl9rZXlzL3V0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUkzRCxlQUFPLE1BQU0sY0FBYyx1QkFBdUIsQ0FBQztBQUVuRC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@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/cmds/validator_keys/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI3D,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,QAWA;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IACnD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,QAeA;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,QAMhG;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,QAwBnG;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE;IAAE,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EAC3D,uBAAuB,UAAQ,QAiChC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
1
2
|
import { ethPrivateKeySchema } from '@aztec/node-keystore/schemas';
|
|
2
3
|
export const defaultBlsPath = 'm/12381/3600/0/0/0';
|
|
3
4
|
export function validateBlsPathOptions(options) {
|
|
@@ -50,3 +51,36 @@ export function validatePublisherOptions(options) {
|
|
|
50
51
|
options.publishers = normalizedKeys;
|
|
51
52
|
}
|
|
52
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Validates and normalizes the `--funding-account` option in place. The value may be a private key
|
|
56
|
+
* (used as a local signer) or an ETH address. An address needs a remote signer to sign funding txs:
|
|
57
|
+
* either `--remote-signer`, or a keystore that already defines one (pass `hasKeystoreRemoteSigner`),
|
|
58
|
+
* which a bare address inherits at runtime.
|
|
59
|
+
*/ export function validateFundingAccountOptions(options, hasKeystoreRemoteSigner = false) {
|
|
60
|
+
if (!options.fundingAccount) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
let value = options.fundingAccount.trim();
|
|
64
|
+
if (!value.startsWith('0x')) {
|
|
65
|
+
value = '0x' + value;
|
|
66
|
+
}
|
|
67
|
+
if (value.length === 66) {
|
|
68
|
+
try {
|
|
69
|
+
ethPrivateKeySchema.parse(value);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
throw new Error(`Invalid funding account private key: ${error instanceof Error ? error.message : String(error)}`);
|
|
72
|
+
}
|
|
73
|
+
} else if (value.length === 42) {
|
|
74
|
+
try {
|
|
75
|
+
EthAddress.fromString(value);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
throw new Error(`Invalid funding account address: ${error instanceof Error ? error.message : String(error)}`);
|
|
78
|
+
}
|
|
79
|
+
if (!options.remoteSigner && !hasKeystoreRemoteSigner) {
|
|
80
|
+
throw new Error('--funding-account as an address requires --remote-signer, or a keystore that already defines a remote signer');
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
throw new Error('Invalid funding account: expected a 32-byte private key or a 20-byte address');
|
|
84
|
+
}
|
|
85
|
+
options.fundingAccount = value;
|
|
86
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/cli",
|
|
3
|
-
"version": "6.0.0-nightly.
|
|
3
|
+
"version": "6.0.0-nightly.20260724",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./contracts": "./dest/cmds/contracts/index.js",
|
|
@@ -77,23 +77,23 @@
|
|
|
77
77
|
]
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@aztec/accounts": "6.0.0-nightly.
|
|
81
|
-
"@aztec/archiver": "6.0.0-nightly.
|
|
82
|
-
"@aztec/aztec.js": "6.0.0-nightly.
|
|
83
|
-
"@aztec/constants": "6.0.0-nightly.
|
|
84
|
-
"@aztec/entrypoints": "6.0.0-nightly.
|
|
85
|
-
"@aztec/ethereum": "6.0.0-nightly.
|
|
86
|
-
"@aztec/foundation": "6.0.0-nightly.
|
|
87
|
-
"@aztec/l1-artifacts": "6.0.0-nightly.
|
|
88
|
-
"@aztec/node-keystore": "6.0.0-nightly.
|
|
89
|
-
"@aztec/node-lib": "6.0.0-nightly.
|
|
90
|
-
"@aztec/p2p": "6.0.0-nightly.
|
|
91
|
-
"@aztec/protocol-contracts": "6.0.0-nightly.
|
|
92
|
-
"@aztec/sequencer-client": "6.0.0-nightly.
|
|
93
|
-
"@aztec/slasher": "6.0.0-nightly.
|
|
94
|
-
"@aztec/stdlib": "6.0.0-nightly.
|
|
95
|
-
"@aztec/wallets": "6.0.0-nightly.
|
|
96
|
-
"@aztec/world-state": "6.0.0-nightly.
|
|
80
|
+
"@aztec/accounts": "6.0.0-nightly.20260724",
|
|
81
|
+
"@aztec/archiver": "6.0.0-nightly.20260724",
|
|
82
|
+
"@aztec/aztec.js": "6.0.0-nightly.20260724",
|
|
83
|
+
"@aztec/constants": "6.0.0-nightly.20260724",
|
|
84
|
+
"@aztec/entrypoints": "6.0.0-nightly.20260724",
|
|
85
|
+
"@aztec/ethereum": "6.0.0-nightly.20260724",
|
|
86
|
+
"@aztec/foundation": "6.0.0-nightly.20260724",
|
|
87
|
+
"@aztec/l1-artifacts": "6.0.0-nightly.20260724",
|
|
88
|
+
"@aztec/node-keystore": "6.0.0-nightly.20260724",
|
|
89
|
+
"@aztec/node-lib": "6.0.0-nightly.20260724",
|
|
90
|
+
"@aztec/p2p": "6.0.0-nightly.20260724",
|
|
91
|
+
"@aztec/protocol-contracts": "6.0.0-nightly.20260724",
|
|
92
|
+
"@aztec/sequencer-client": "6.0.0-nightly.20260724",
|
|
93
|
+
"@aztec/slasher": "6.0.0-nightly.20260724",
|
|
94
|
+
"@aztec/stdlib": "6.0.0-nightly.20260724",
|
|
95
|
+
"@aztec/wallets": "6.0.0-nightly.20260724",
|
|
96
|
+
"@aztec/world-state": "6.0.0-nightly.20260724",
|
|
97
97
|
"@ethersproject/wallet": "^5.8.0",
|
|
98
98
|
"@iarna/toml": "^2.2.5",
|
|
99
99
|
"@libp2p/peer-id-factory": "^3.0.4",
|
|
@@ -107,9 +107,9 @@
|
|
|
107
107
|
"viem": "npm:@aztec/viem@2.38.2"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
|
-
"@aztec/aztec-node": "6.0.0-nightly.
|
|
111
|
-
"@aztec/kv-store": "6.0.0-nightly.
|
|
112
|
-
"@aztec/telemetry-client": "6.0.0-nightly.
|
|
110
|
+
"@aztec/aztec-node": "6.0.0-nightly.20260724",
|
|
111
|
+
"@aztec/kv-store": "6.0.0-nightly.20260724",
|
|
112
|
+
"@aztec/telemetry-client": "6.0.0-nightly.20260724",
|
|
113
113
|
"@jest/globals": "^30.0.0",
|
|
114
114
|
"@types/jest": "^30.0.0",
|
|
115
115
|
"@types/lodash.chunk": "^4.2.9",
|
|
@@ -126,15 +126,15 @@
|
|
|
126
126
|
"typescript": "^5.3.3"
|
|
127
127
|
},
|
|
128
128
|
"peerDependencies": {
|
|
129
|
-
"@aztec/accounts": "6.0.0-nightly.
|
|
130
|
-
"@aztec/bb-prover": "6.0.0-nightly.
|
|
131
|
-
"@aztec/ethereum": "6.0.0-nightly.
|
|
132
|
-
"@aztec/l1-artifacts": "6.0.0-nightly.
|
|
133
|
-
"@aztec/noir-contracts.js": "6.0.0-nightly.
|
|
134
|
-
"@aztec/noir-protocol-circuits-types": "6.0.0-nightly.
|
|
135
|
-
"@aztec/noir-test-contracts.js": "6.0.0-nightly.
|
|
136
|
-
"@aztec/protocol-contracts": "6.0.0-nightly.
|
|
137
|
-
"@aztec/stdlib": "6.0.0-nightly.
|
|
129
|
+
"@aztec/accounts": "6.0.0-nightly.20260724",
|
|
130
|
+
"@aztec/bb-prover": "6.0.0-nightly.20260724",
|
|
131
|
+
"@aztec/ethereum": "6.0.0-nightly.20260724",
|
|
132
|
+
"@aztec/l1-artifacts": "6.0.0-nightly.20260724",
|
|
133
|
+
"@aztec/noir-contracts.js": "6.0.0-nightly.20260724",
|
|
134
|
+
"@aztec/noir-protocol-circuits-types": "6.0.0-nightly.20260724",
|
|
135
|
+
"@aztec/noir-test-contracts.js": "6.0.0-nightly.20260724",
|
|
136
|
+
"@aztec/protocol-contracts": "6.0.0-nightly.20260724",
|
|
137
|
+
"@aztec/stdlib": "6.0.0-nightly.20260724"
|
|
138
138
|
},
|
|
139
139
|
"files": [
|
|
140
140
|
"dest",
|
|
@@ -33,8 +33,10 @@ export function injectCommands(program: Command, log: LogFn) {
|
|
|
33
33
|
'Coinbase ETH address to use when proposing. Defaults to attester address.',
|
|
34
34
|
parseEthereumAddress,
|
|
35
35
|
)
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
.option(
|
|
37
|
+
'--funding-account <privateKey|address>',
|
|
38
|
+
'ETH funding account used to top up publisher EOAs. Provide a private key, or an address together with --remote-signer.',
|
|
39
|
+
)
|
|
38
40
|
.option('--remote-signer <url>', 'Default remote signer URL for accounts in this file')
|
|
39
41
|
.option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
|
|
40
42
|
.option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`)
|
|
@@ -99,8 +101,6 @@ export function injectCommands(program: Command, log: LogFn) {
|
|
|
99
101
|
'Coinbase ETH address to use when proposing. Defaults to attester address.',
|
|
100
102
|
parseEthereumAddress,
|
|
101
103
|
)
|
|
102
|
-
// TODO: add funding account back in when implemented
|
|
103
|
-
// .option('--funding-account <privateKey|address>', 'ETH private key (or address for remote signer setup) to fund publishers')
|
|
104
104
|
.option('--remote-signer <url>', 'Default remote signer URL for accounts in this file')
|
|
105
105
|
.option('--ikm <hex>', 'Initial keying material for BLS (alternative to mnemonic)', value => parseHex(value, 32))
|
|
106
106
|
.option('--bls-path <path>', `EIP-2334 path (default ${defaultBlsPath})`)
|
|
@@ -117,6 +117,32 @@ export function injectCommands(program: Command, log: LogFn) {
|
|
|
117
117
|
await addValidatorKeys(existing, options, log);
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
+
group
|
|
121
|
+
.command('set-funding-account')
|
|
122
|
+
.summary('Set the funding account of an existing keystore')
|
|
123
|
+
.description(
|
|
124
|
+
'Sets the keystore-level ETH funding account used to top up publisher EOAs, replacing any existing one',
|
|
125
|
+
)
|
|
126
|
+
.argument('<existing>', 'Path to existing keystore JSON')
|
|
127
|
+
.argument(
|
|
128
|
+
'<privateKey|address>',
|
|
129
|
+
'Funding account: a private key, or an address (needs --remote-signer unless the keystore already defines one)',
|
|
130
|
+
)
|
|
131
|
+
.option(
|
|
132
|
+
'--remote-signer <url>',
|
|
133
|
+
'Remote signer URL for the funding account (required with an address unless the keystore already defines one)',
|
|
134
|
+
)
|
|
135
|
+
.option(
|
|
136
|
+
'--password <str>',
|
|
137
|
+
'Password for writing the funding key as an encrypted ETH JSON V3 file. Empty string allowed',
|
|
138
|
+
)
|
|
139
|
+
.option('--encrypted-keystore-dir <dir>', 'Output directory for the encrypted funding key file')
|
|
140
|
+
.option('--json', 'Echo resulting JSON to stdout')
|
|
141
|
+
.action(async (existing: string, fundingAccount: string, options) => {
|
|
142
|
+
const { setFundingAccount } = await import('./set_funding_account.js');
|
|
143
|
+
await setFundingAccount(existing, fundingAccount, options, log);
|
|
144
|
+
});
|
|
145
|
+
|
|
120
146
|
group
|
|
121
147
|
.command('staker')
|
|
122
148
|
.summary('Generate staking JSON from keystore')
|
|
@@ -9,12 +9,14 @@ import { wordlist } from '@scure/bip39/wordlists/english.js';
|
|
|
9
9
|
import { readFile, writeFile } from 'fs/promises';
|
|
10
10
|
import { basename, dirname, join } from 'path';
|
|
11
11
|
import { createPublicClient, fallback, http } from 'viem';
|
|
12
|
-
import { generateMnemonic, mnemonicToAccount } from 'viem/accounts';
|
|
12
|
+
import { generateMnemonic, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
15
|
buildValidatorEntries,
|
|
16
|
+
encryptFundingAccountToFile,
|
|
16
17
|
logValidatorSummaries,
|
|
17
18
|
maybePrintJson,
|
|
19
|
+
resolveFundingAccount,
|
|
18
20
|
resolveKeystoreOutputPath,
|
|
19
21
|
writeBlsBn254ToFile,
|
|
20
22
|
writeEthJsonV3ToFile,
|
|
@@ -23,6 +25,7 @@ import {
|
|
|
23
25
|
import { processAttesterAccounts } from './staker.js';
|
|
24
26
|
import {
|
|
25
27
|
validateBlsPathOptions,
|
|
28
|
+
validateFundingAccountOptions,
|
|
26
29
|
validatePublisherOptions,
|
|
27
30
|
validateRemoteSignerOptions,
|
|
28
31
|
validateStakerOutputOptions,
|
|
@@ -51,6 +54,7 @@ export type NewValidatorKeystoreOptions = {
|
|
|
51
54
|
json?: boolean;
|
|
52
55
|
feeRecipient: AztecAddress;
|
|
53
56
|
coinbase?: EthAddress;
|
|
57
|
+
fundingAccount?: string;
|
|
54
58
|
remoteSigner?: string;
|
|
55
59
|
stakerOutput?: boolean;
|
|
56
60
|
gseAddress?: EthAddress;
|
|
@@ -147,6 +151,8 @@ export async function newValidatorKeystore(options: NewValidatorKeystoreOptions,
|
|
|
147
151
|
validatePublisherOptions(options);
|
|
148
152
|
// validate remote signer options
|
|
149
153
|
validateRemoteSignerOptions(options);
|
|
154
|
+
// validate funding account option
|
|
155
|
+
validateFundingAccountOptions(options);
|
|
150
156
|
|
|
151
157
|
const {
|
|
152
158
|
dataDir,
|
|
@@ -156,6 +162,7 @@ export async function newValidatorKeystore(options: NewValidatorKeystoreOptions,
|
|
|
156
162
|
publishers,
|
|
157
163
|
json,
|
|
158
164
|
coinbase,
|
|
165
|
+
fundingAccount,
|
|
159
166
|
accountIndex = 0,
|
|
160
167
|
addressIndex = 0,
|
|
161
168
|
feeRecipient,
|
|
@@ -213,17 +220,26 @@ export async function newValidatorKeystore(options: NewValidatorKeystoreOptions,
|
|
|
213
220
|
remoteSigner,
|
|
214
221
|
});
|
|
215
222
|
|
|
223
|
+
let resolvedFundingAccount = fundingAccount ? resolveFundingAccount(fundingAccount, remoteSigner) : undefined;
|
|
224
|
+
|
|
216
225
|
// If password provided, write ETH JSON V3 and BLS BN254 keystores and replace plaintext
|
|
217
226
|
if (shouldEncryptKeystores) {
|
|
218
227
|
const encryptedKeystoreOutDir =
|
|
219
228
|
encryptedKeystoreDir && encryptedKeystoreDir.length > 0 ? encryptedKeystoreDir : keystoreOutDir;
|
|
220
229
|
await writeEthJsonV3ToFile(validators, { outDir: encryptedKeystoreOutDir, password: ethPassword });
|
|
221
230
|
await writeBlsBn254ToFile(validators, { outDir: encryptedKeystoreOutDir, password: blsPassword });
|
|
231
|
+
if (resolvedFundingAccount) {
|
|
232
|
+
resolvedFundingAccount = await encryptFundingAccountToFile(resolvedFundingAccount, {
|
|
233
|
+
outDir: encryptedKeystoreOutDir,
|
|
234
|
+
password: ethPassword,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
222
237
|
}
|
|
223
238
|
|
|
224
239
|
const keystore = {
|
|
225
240
|
schemaVersion: 1,
|
|
226
241
|
validators,
|
|
242
|
+
...(resolvedFundingAccount ? { fundingAccount: resolvedFundingAccount } : {}),
|
|
227
243
|
};
|
|
228
244
|
|
|
229
245
|
await writeKeystoreFile(outputPath, keystore);
|
|
@@ -285,6 +301,11 @@ export async function newValidatorKeystore(options: NewValidatorKeystoreOptions,
|
|
|
285
301
|
// print a concise summary of public keys (addresses and BLS pubkeys) if no --json options was selected
|
|
286
302
|
if (!json) {
|
|
287
303
|
logValidatorSummaries(log, summaries);
|
|
304
|
+
if (fundingAccount) {
|
|
305
|
+
const funderAddress =
|
|
306
|
+
fundingAccount.length === 66 ? privateKeyToAccount(fundingAccount as `0x${string}`).address : fundingAccount;
|
|
307
|
+
log(`funding account: ${funderAddress}`);
|
|
308
|
+
}
|
|
288
309
|
}
|
|
289
310
|
|
|
290
311
|
if (mnemonic && remoteSigner && !json) {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
import { loadKeystoreFile } from '@aztec/node-keystore/loader';
|
|
3
|
+
import type { KeyStore } from '@aztec/node-keystore/types';
|
|
4
|
+
|
|
5
|
+
import { dirname } from 'path';
|
|
6
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
7
|
+
|
|
8
|
+
import { encryptFundingAccountToFile, maybePrintJson, resolveFundingAccount, writeKeystoreFile } from './shared.js';
|
|
9
|
+
import { validateFundingAccountOptions } from './utils.js';
|
|
10
|
+
|
|
11
|
+
export type SetFundingAccountOptions = {
|
|
12
|
+
remoteSigner?: string;
|
|
13
|
+
password?: string;
|
|
14
|
+
encryptedKeystoreDir?: string;
|
|
15
|
+
json?: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Sets the top-level funding account of an existing keystore, replacing any previous one. The
|
|
20
|
+
* account may be a private key, or an address paired with a remote signer URL. With a password,
|
|
21
|
+
* a plaintext key is encrypted to an ETH JSON V3 file and stored as a { path, password } reference.
|
|
22
|
+
*/
|
|
23
|
+
export async function setFundingAccount(
|
|
24
|
+
existing: string,
|
|
25
|
+
fundingAccount: string,
|
|
26
|
+
options: SetFundingAccountOptions,
|
|
27
|
+
log: LogFn,
|
|
28
|
+
) {
|
|
29
|
+
const { remoteSigner, password, encryptedKeystoreDir, json } = options;
|
|
30
|
+
|
|
31
|
+
const keystore: KeyStore = loadKeystoreFile(existing);
|
|
32
|
+
|
|
33
|
+
const validated = { fundingAccount, remoteSigner };
|
|
34
|
+
validateFundingAccountOptions(validated, !!keystore.remoteSigner);
|
|
35
|
+
|
|
36
|
+
let resolved = resolveFundingAccount(validated.fundingAccount!, remoteSigner);
|
|
37
|
+
if (password !== undefined) {
|
|
38
|
+
const outDir = encryptedKeystoreDir && encryptedKeystoreDir.length > 0 ? encryptedKeystoreDir : dirname(existing);
|
|
39
|
+
resolved = await encryptFundingAccountToFile(resolved, { outDir, password });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (keystore.fundingAccount) {
|
|
43
|
+
log('Replacing existing funding account in keystore');
|
|
44
|
+
}
|
|
45
|
+
keystore.fundingAccount = resolved;
|
|
46
|
+
|
|
47
|
+
await writeKeystoreFile(existing, keystore);
|
|
48
|
+
|
|
49
|
+
if (!json) {
|
|
50
|
+
const value = validated.fundingAccount!;
|
|
51
|
+
const funderAddress = value.length === 66 ? privateKeyToAccount(value as `0x${string}`).address : value;
|
|
52
|
+
log(`Set funding account ${funderAddress} in ${existing}`);
|
|
53
|
+
}
|
|
54
|
+
maybePrintJson(log, !!json, keystore as unknown as Record<string, any>);
|
|
55
|
+
}
|
|
@@ -3,7 +3,7 @@ import { asyncPool } from '@aztec/foundation/async-pool';
|
|
|
3
3
|
import { deriveBlsPrivateKey } from '@aztec/foundation/crypto/bls';
|
|
4
4
|
import { createBn254Keystore } from '@aztec/foundation/crypto/bls/bn254_keystore';
|
|
5
5
|
import { computeBn254G1PublicKeyCompressed } from '@aztec/foundation/crypto/bn254';
|
|
6
|
-
import
|
|
6
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
7
|
import type { LogFn } from '@aztec/foundation/log';
|
|
8
8
|
import type { EthAccount, EthPrivateKey, ValidatorKeyStore } from '@aztec/node-keystore/types';
|
|
9
9
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -125,6 +125,21 @@ export function deriveEthAttester(
|
|
|
125
125
|
: (('0x' + Buffer.from(acct.getHdKey().privateKey!).toString('hex')) as EthPrivateKey);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Resolve a `--funding-account` value into a keystore `EthAccount`. A 66-char value is a private key
|
|
130
|
+
* (used verbatim). A 42-char value is an address: with an explicit `remoteSigner` URL it becomes an
|
|
131
|
+
* `{ address, remoteSignerUrl }` pair; without one it is stored as a bare address that falls back to
|
|
132
|
+
* the keystore-level remote signer at runtime. Callers must validate the value first (see
|
|
133
|
+
* `validateFundingAccountOptions`).
|
|
134
|
+
*/
|
|
135
|
+
export function resolveFundingAccount(fundingAccount: string, remoteSigner?: string): EthAccount {
|
|
136
|
+
if (fundingAccount.length === 66) {
|
|
137
|
+
return fundingAccount as EthPrivateKey;
|
|
138
|
+
}
|
|
139
|
+
const address = EthAddress.fromString(fundingAccount);
|
|
140
|
+
return remoteSigner ? ({ address, remoteSignerUrl: remoteSigner } as EthAccount) : address;
|
|
141
|
+
}
|
|
142
|
+
|
|
128
143
|
export async function buildValidatorEntries(input: BuildValidatorsInput) {
|
|
129
144
|
const {
|
|
130
145
|
validatorCount,
|
|
@@ -330,6 +345,27 @@ export async function writeEthJsonV3Keystore(
|
|
|
330
345
|
return outPath;
|
|
331
346
|
}
|
|
332
347
|
|
|
348
|
+
/**
|
|
349
|
+
* If `account` is a plaintext ETH private key, encrypt it to a JSON V3 file and return a
|
|
350
|
+
* { path, password } reference; otherwise return it unchanged.
|
|
351
|
+
*/
|
|
352
|
+
async function maybeEncryptEthAccount(account: any, label: string, options: { outDir: string; password: string }) {
|
|
353
|
+
if (typeof account === 'string' && account.startsWith('0x') && account.length === 66) {
|
|
354
|
+
const fileBase = `${label}_${account.slice(2, 10)}`;
|
|
355
|
+
const p = await writeEthJsonV3Keystore(options.outDir, fileBase, options.password, account);
|
|
356
|
+
return { path: p, password: options.password };
|
|
357
|
+
}
|
|
358
|
+
return account;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/** Encrypt a plaintext funding-account key to a JSON V3 file, replacing it with a { path, password } reference. */
|
|
362
|
+
export async function encryptFundingAccountToFile(
|
|
363
|
+
account: EthAccount,
|
|
364
|
+
options: { outDir: string; password: string },
|
|
365
|
+
): Promise<EthAccount> {
|
|
366
|
+
return (await maybeEncryptEthAccount(account, 'funding', options)) as EthAccount;
|
|
367
|
+
}
|
|
368
|
+
|
|
333
369
|
/** Replace plaintext ETH keys in validators with { path, password } pointing to JSON V3 files. */
|
|
334
370
|
export async function writeEthJsonV3ToFile(
|
|
335
371
|
validators: ValidatorKeyStore[],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import { ethPrivateKeySchema } from '@aztec/node-keystore/schemas';
|
|
3
3
|
import type { EthPrivateKey } from '@aztec/node-keystore/types';
|
|
4
4
|
|
|
@@ -79,3 +79,46 @@ export function validatePublisherOptions(options: { publishers?: string[]; publi
|
|
|
79
79
|
options.publishers = normalizedKeys as EthPrivateKey[];
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Validates and normalizes the `--funding-account` option in place. The value may be a private key
|
|
85
|
+
* (used as a local signer) or an ETH address. An address needs a remote signer to sign funding txs:
|
|
86
|
+
* either `--remote-signer`, or a keystore that already defines one (pass `hasKeystoreRemoteSigner`),
|
|
87
|
+
* which a bare address inherits at runtime.
|
|
88
|
+
*/
|
|
89
|
+
export function validateFundingAccountOptions(
|
|
90
|
+
options: { fundingAccount?: string; remoteSigner?: string },
|
|
91
|
+
hasKeystoreRemoteSigner = false,
|
|
92
|
+
) {
|
|
93
|
+
if (!options.fundingAccount) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
let value = options.fundingAccount.trim();
|
|
98
|
+
if (!value.startsWith('0x')) {
|
|
99
|
+
value = '0x' + value;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (value.length === 66) {
|
|
103
|
+
try {
|
|
104
|
+
ethPrivateKeySchema.parse(value);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
throw new Error(`Invalid funding account private key: ${error instanceof Error ? error.message : String(error)}`);
|
|
107
|
+
}
|
|
108
|
+
} else if (value.length === 42) {
|
|
109
|
+
try {
|
|
110
|
+
EthAddress.fromString(value);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
throw new Error(`Invalid funding account address: ${error instanceof Error ? error.message : String(error)}`);
|
|
113
|
+
}
|
|
114
|
+
if (!options.remoteSigner && !hasKeystoreRemoteSigner) {
|
|
115
|
+
throw new Error(
|
|
116
|
+
'--funding-account as an address requires --remote-signer, or a keystore that already defines a remote signer',
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
throw new Error('Invalid funding account: expected a 32-byte private key or a 20-byte address');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
options.fundingAccount = value;
|
|
124
|
+
}
|