-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4752 from iron-fish/staging
Staging -> Master
- Loading branch information
Showing
173 changed files
with
7,372 additions
and
2,759 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "ironfish", | ||
"version": "1.19.0", | ||
"version": "1.20.0", | ||
"description": "CLI for running and interacting with an Iron Fish node", | ||
"author": "Iron Fish <[email protected]> (https://ironfish.network)", | ||
"main": "build/src/index.js", | ||
|
@@ -62,8 +62,8 @@ | |
"@aws-sdk/client-s3": "3", | ||
"@aws-sdk/client-secrets-manager": "3", | ||
"@aws-sdk/s3-request-presigner": "3", | ||
"@ironfish/rust-nodejs": "1.16.0", | ||
"@ironfish/sdk": "1.19.0", | ||
"@ironfish/rust-nodejs": "1.17.0", | ||
"@ironfish/sdk": "1.20.0", | ||
"@oclif/core": "1.23.1", | ||
"@oclif/plugin-help": "5.1.12", | ||
"@oclif/plugin-not-found": "2.3.1", | ||
|
This file contains 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
This file contains 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
This file contains 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
136 changes: 136 additions & 0 deletions
136
ironfish-cli/src/commands/wallet/multisig/account/create.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
import { ACCOUNT_SCHEMA_VERSION, Base64JsonEncoder } from '@ironfish/sdk' | ||
import { CliUx, Flags } from '@oclif/core' | ||
import { IronfishCommand } from '../../../../command' | ||
import { RemoteFlags } from '../../../../flags' | ||
|
||
export class MultisigCreate extends IronfishCommand { | ||
static description = `Create a set of multisig accounts from identities` | ||
static hidden = true | ||
|
||
static flags = { | ||
...RemoteFlags, | ||
name: Flags.string({ | ||
char: 'n', | ||
description: 'Name to use for the coordinator', | ||
}), | ||
identity: Flags.string({ | ||
char: 'i', | ||
description: 'Identity of a participant', | ||
multiple: true, | ||
}), | ||
minSigners: Flags.integer({ | ||
char: 'm', | ||
description: 'Minimum number of signers to meet signing threshold', | ||
}), | ||
importCoordinator: Flags.boolean({ | ||
char: 'c', | ||
default: true, | ||
description: 'Import the coordinator as a view-only account after creating key packages', | ||
}), | ||
} | ||
|
||
async start(): Promise<void> { | ||
const { flags } = await this.parse(MultisigCreate) | ||
|
||
let identities = flags.identity | ||
if (!identities || identities.length < 2) { | ||
const input = await CliUx.ux.prompt('Enter the identities separated by commas', { | ||
required: true, | ||
}) | ||
identities = input.split(',') | ||
|
||
if (identities.length < 2) { | ||
this.error('Minimum number of identities must be at least 2') | ||
} | ||
} | ||
identities = identities.map((i) => i.trim()) | ||
|
||
let minSigners = flags.minSigners | ||
if (!minSigners) { | ||
const input = await CliUx.ux.prompt('Enter the number of minimum signers', { | ||
required: true, | ||
}) | ||
minSigners = parseInt(input) | ||
if (isNaN(minSigners) || minSigners < 2) { | ||
this.error('Minimum number of signers must be at least 2') | ||
} | ||
} | ||
|
||
const name = | ||
flags.name?.trim() ?? | ||
(await CliUx.ux.prompt('Enter the name for the coordinator', { required: true })) | ||
|
||
const client = await this.sdk.connectRpc() | ||
|
||
const response = await client.wallet.multisig.createTrustedDealerKeyPackage({ | ||
minSigners, | ||
participants: identities.map((identity) => ({ identity })), | ||
}) | ||
|
||
const chainResponse = await client.chain.getChainInfo() | ||
const hash = Buffer.from(chainResponse.content.currentBlockIdentifier.hash, 'hex') | ||
const sequence = Number(chainResponse.content.currentBlockIdentifier.index) | ||
const createdAt = { | ||
hash, | ||
sequence, | ||
} | ||
|
||
if (flags.importCoordinator) { | ||
this.log() | ||
CliUx.ux.action.start('Importing the coordinator as a view-only account') | ||
|
||
await client.wallet.importAccount({ | ||
account: { | ||
name, | ||
version: ACCOUNT_SCHEMA_VERSION, | ||
createdAt: { | ||
hash: createdAt.hash.toString('hex'), | ||
sequence: createdAt.sequence, | ||
}, | ||
spendingKey: null, | ||
viewKey: response.content.viewKey, | ||
incomingViewKey: response.content.incomingViewKey, | ||
outgoingViewKey: response.content.outgoingViewKey, | ||
publicAddress: response.content.publicAddress, | ||
proofAuthorizingKey: response.content.proofAuthorizingKey, | ||
multisigKeys: { | ||
publicKeyPackage: response.content.publicKeyPackage, | ||
}, | ||
}, | ||
}) | ||
|
||
CliUx.ux.action.stop() | ||
} | ||
|
||
const encoder = new Base64JsonEncoder() | ||
|
||
for (const [i, keyPackage] of response.content.keyPackages.entries()) { | ||
this.log('\n') | ||
this.log(`Account ${i + 1}`) | ||
this.log(`Identity ${keyPackage.identity}`) | ||
this.log('----------------') | ||
const accountStr = encoder.encode({ | ||
name: `${name}-${i}`, | ||
version: ACCOUNT_SCHEMA_VERSION, | ||
createdAt, | ||
spendingKey: null, | ||
viewKey: response.content.viewKey, | ||
incomingViewKey: response.content.incomingViewKey, | ||
outgoingViewKey: response.content.outgoingViewKey, | ||
publicAddress: response.content.publicAddress, | ||
proofAuthorizingKey: response.content.proofAuthorizingKey, | ||
multisigKeys: { | ||
identity: keyPackage.identity, | ||
keyPackage: keyPackage.keyPackage, | ||
publicKeyPackage: response.content.publicKeyPackage, | ||
}, | ||
}) | ||
this.log(accountStr) | ||
} | ||
|
||
this.log() | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
ironfish-cli/src/commands/wallet/multisig/create-signature-share.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
import { CliUx, Flags } from '@oclif/core' | ||
import { IronfishCommand } from '../../../command' | ||
import { RemoteFlags } from '../../../flags' | ||
import { longPrompt } from '../../../utils/longPrompt' | ||
|
||
export class CreateSignatureShareCommand extends IronfishCommand { | ||
static description = `Creates a signature share for a participant for a given transaction` | ||
static hidden = true | ||
|
||
static flags = { | ||
...RemoteFlags, | ||
account: Flags.string({ | ||
char: 'f', | ||
description: 'The account from which the signature share will be created', | ||
required: false, | ||
}), | ||
signingPackage: Flags.string({ | ||
char: 's', | ||
description: 'The signing package for which the signature share will be created', | ||
required: false, | ||
}), | ||
signerIdentity: Flags.string({ | ||
char: 'i', | ||
description: | ||
'The identity of the participants that will sign the transaction (may be specified multiple times to add multiple signers)', | ||
required: true, | ||
multiple: true, | ||
}), | ||
confirm: Flags.boolean({ | ||
default: false, | ||
description: 'Confirm creating signature share without confirming', | ||
}), | ||
} | ||
|
||
async start(): Promise<void> { | ||
const { flags } = await this.parse(CreateSignatureShareCommand) | ||
let signingPackage = flags.signingPackage?.trim() | ||
|
||
if (!signingPackage) { | ||
signingPackage = await longPrompt('Enter the signing package: ') | ||
} | ||
|
||
if (!flags.confirm) { | ||
const confirmed = await CliUx.ux.confirm('Confirm new signature share creation (Y/N)') | ||
if (!confirmed) { | ||
this.error('Creating signature share aborted') | ||
} | ||
} | ||
|
||
const client = await this.sdk.connectRpc() | ||
const signatureShareResponse = await client.wallet.multisig.createSignatureShare({ | ||
account: flags.account, | ||
signingPackage, | ||
}) | ||
|
||
this.log('Signing Share:\n') | ||
this.log(signatureShareResponse.content.signatureShare) | ||
} | ||
} |
Oops, something went wrong.