diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..fb67e3d5 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +18.7.0 diff --git a/README.md b/README.md index af8c419d..966d152f 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ cardano-hw-cli address key-gen --path PATH Derivation path to the key we want to sign with. --verification-key-file FILE Output filepath of the verification key. --hw-signing-file FILE Output filepath of the hardware wallet signing file. +--derivation-type TYPE Derivation type - currently applies only to Trezor. Options: LEDGER, ICARUS or ICARUS_TREZOR (default). ``` Arguments can be specified multiple times for bulk export. @@ -39,6 +40,7 @@ cardano-hw-cli transaction sign --change-output-key-file FILE Input filepath of the hardware wallet signing file (so hw cli can match the keys of the change address, if present, and let the device hide it). --mainnet | --testnet-magic NATURAL Use the mainnet magic id or specify testnet magic id. --out-file FILE Output filepath of the Tx. +--derivation-type TYPE Derivation type - currently applies only to Trezor. Options: LEDGER, ICARUS or ICARUS_TREZOR (default). ``` ## Witness transaction @@ -50,6 +52,7 @@ cardano-hw-cli transaction witness --change-output-key-file FILE Input filepath of the hardware wallet signing file (so hw cli can match the keys of the change address, if present, and let the device hide it). --mainnet | --testnet-magic NATURAL Use the mainnet magic id or specify testnet magic id. --out-file FILE Output filepath of the witness (one or more witness files can be specified). +--derivation-type TYPE Derivation type - currently applies only to Trezor. Options: LEDGER, ICARUS or ICARUS_TREZOR (default). ``` ## Validate raw transaction @@ -102,16 +105,18 @@ cardano-hw-cli address show --payment-path PAYMENTPATH Payment derivation path. --staking-path STAKINGPATH Stake derivation path. --address-file ADDRESS Input filepath of the address. +--derivation-type TYPE Derivation type - currently applies only to Trezor. Options: LEDGER, ICARUS or ICARUS_TREZOR (default). ``` ## Issue operational certificate ``` cardano-hw-cli node issue-op-cert ---kes-verification-key-file FILE Input filepath of the file with KES vkey. ---operational-certificate-issue-counter FILE Input filepath of the file with certificate counter. ---kes-period UINT64 Kes period for the certificate. ---out-file FILE Output filepath for node certificate. ---hw-signing-file FILE Input filepath of the hardware wallet signing file. +--kes-verification-key-file FILE Input filepath of the file with KES vkey. +--operational-certificate-issue-counter FILE Input filepath of the issue counter file. This option is DEPRECATED. Please use --operational-certificate-issue-counter-file instead. +--operational-certificate-issue-counter-file FILE Input filepath of the file with certificate counter. +--kes-period UINT64 Kes period for the certificate. +--out-file FILE Output filepath for node certificate. +--hw-signing-file FILE Input filepath of the hardware wallet signing file. ``` ## Catalyst voting registration @@ -124,6 +129,7 @@ cardano-hw-cli catalyst voting-key-registration-metadata --nonce NONCE Current slot number. --reward-address-signing-key FILE Input filepath of the reward address signing files. --metadata-cbor-out-file FILE Output filepath of metadata cbor. +--derivation-type TYPE Derivation type - currently applies only to Trezor. Options: LEDGER, ICARUS or ICARUS_TREZOR (default). ``` see [Catalyst voting registration example](docs/catalyst-voting-registration-example.md) @@ -131,8 +137,9 @@ see [Catalyst voting registration example](docs/catalyst-voting-registration-exa ## Policy id generation ``` cardano-hw-cli transaction policyid ---script-file Path to a native script file ---hw-signing-file Input filepath of the hardware wallet signing file +--script-file Path to a native script file +--hw-signing-file Input filepath of the hardware wallet signing file +--derivation-type TYPE Derivation type - currently applies only to Trezor. Options: LEDGER, ICARUS or ICARUS_TREZOR (default). ``` see [Policy id](docs/token-minting.md#policy-id) diff --git a/docs/pool-registration.md b/docs/pool-registration.md index 05aabacb..d6709076 100644 --- a/docs/pool-registration.md +++ b/docs/pool-registration.md @@ -70,7 +70,7 @@ This step creates an operational certificate. It is required for running the blo cardano-hw-cli node issue-op-cert \ --kes-verification-key-file kes.vkey \ --hw-signing-file cold.hwsfile \ ---operational-certificate-issue-counter cold.counter \ +--operational-certificate-issue-counter-file cold.counter \ --kes-period 99 \ --out-file node.cert ``` diff --git a/package.json b/package.json index eb9265b5..b4191f93 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cardano-hw-cli", - "version": "1.11.0", + "version": "1.12.0", "commit": "e07e140a937052390b9fb4c58e4d65c3fad76eef", "engines": { "node": "18.7.0" @@ -46,7 +46,7 @@ "bignumber": "^1.1.0", "borc": "^2.1.2", "cardano-crypto.js": "^5.3.6-rc.6", - "cardano-hw-interop-lib": "^1.1.0", + "cardano-hw-interop-lib": "^1.1.1", "cbor": "^7.0.4", "lodash": "^4.17.21", "rw": "1.3.3" diff --git a/scripts/autocomplete.sh b/scripts/autocomplete.sh index 1f760a73..71935cd1 100644 --- a/scripts/autocomplete.sh +++ b/scripts/autocomplete.sh @@ -26,19 +26,19 @@ _cardano_hw_cli_completions() ;; *) if [ "${COMP_WORDS[1]}" = "address" ] && [ "${COMP_WORDS[2]}" = "key-gen" ]; then - COMPREPLY=( $(compgen -W "--path --hw-signing-file --verification-key-file" -- "${COMP_WORDS[-1]}") ) + COMPREPLY=( $(compgen -W "--path --hw-signing-file --verification-key-file --derivation-type" -- "${COMP_WORDS[-1]}") ) fi if [ "${COMP_WORDS[2]}" = "show" ]; then - COMPREPLY=( $(compgen -W "--payment-path --staking-path --address-file" -- "${COMP_WORDS[-1]}") ) + COMPREPLY=( $(compgen -W "--payment-path --staking-path --address-file --derivation-type" -- "${COMP_WORDS[-1]}") ) fi if [ "${COMP_WORDS[2]}" = "verification-key" ]; then COMPREPLY=( $(compgen -W "--hw-signing-file --verification-key-file" -- "${COMP_WORDS[-1]}") ) fi if [ "${COMP_WORDS[2]}" = "sign" ] || [ "${COMP_WORDS[2]}" = "witness" ]; then - COMPREPLY=( $(compgen -W "--mainnet --testnet-magic --tx-body-file --hw-signing-file --change-output-key-file --out-file" -- "${COMP_WORDS[-1]}") ) + COMPREPLY=( $(compgen -W "--mainnet --testnet-magic --tx-body-file --hw-signing-file --change-output-key-file --out-file --derivation-type" -- "${COMP_WORDS[-1]}") ) fi if [ "${COMP_WORDS[2]}" = "policyid" ]; then - COMPREPLY=( $(compgen -W "--script-file --hw-signing-file" -- "${COMP_WORDS[-1]}") ) + COMPREPLY=( $(compgen -W "--script-file --hw-signing-file --derivation-type" -- "${COMP_WORDS[-1]}") ) fi if [ "${COMP_WORDS[2]}" = "validate-raw" ]; then COMPREPLY=( $(compgen -W "--tx-body-file" -- "${COMP_WORDS[-1]}") ) @@ -56,10 +56,10 @@ _cardano_hw_cli_completions() COMPREPLY=( $(compgen -W "--path --hw-signing-file --cold-verification-key-file --operational-certificate-issue-counter-file" -- "${COMP_WORDS[-1]}") ) fi if [ "${COMP_WORDS[2]}" = "issue-op-cert" ]; then - COMPREPLY=( $(compgen -W "--kes-verification-key-file --kes-period --operational-certificate-issue-counter --hw-signing-file --out-file" -- "${COMP_WORDS[-1]}") ) + COMPREPLY=( $(compgen -W "--kes-verification-key-file --kes-period --operational-certificate-issue-counter-file --hw-signing-file --out-file" -- "${COMP_WORDS[-1]}") ) fi if [ "${COMP_WORDS[2]}" = "voting-key-registration-metadata" ]; then - COMPREPLY=( $(compgen -W "--mainnet --testnet-magic --vote-public-key --reward-address --stake-signing-key --nonce --reward-address-signing-key --metadata-cbor-out-file" -- "${COMP_WORDS[-1]}") ) + COMPREPLY=( $(compgen -W "--mainnet --testnet-magic --vote-public-key --reward-address --stake-signing-key --nonce --reward-address-signing-key --metadata-cbor-out-file --derivation-type" -- "${COMP_WORDS[-1]}") ) fi ;; esac diff --git a/src/command-parser/parserConfig.ts b/src/command-parser/parserConfig.ts index cdb2195f..ba56d831 100644 --- a/src/command-parser/parserConfig.ts +++ b/src/command-parser/parserConfig.ts @@ -11,8 +11,18 @@ import { parseVotePubFile, parseScriptHashHex, parseNativeScriptFile, + parseDerivationType, } from './parsers' +const derivationTypeArg = { + '--derivation-type': { + required: false, + type: (name?: string) => parseDerivationType(name), + dest: 'derivationType', + help: 'Derivation type - currently applies only to Trezor. Options: LEDGER, ICARUS or ICARUS_TREZOR (default).', + }, +} + const keyGenArgs = { '--path': { required: true, @@ -33,6 +43,7 @@ const keyGenArgs = { dest: 'verificationKeyFiles', help: 'Output filepath of the hardware wallet signing file.', }, + ...derivationTypeArg, } const nodeKeyGenArgs = { @@ -103,6 +114,7 @@ const txSigningArgs = { type: (path: string) => parseHwSigningFile(path), help: 'Input filepath of change output file.', }, + ...derivationTypeArg, } const opCertSigningArgs = { @@ -118,10 +130,15 @@ const opCertSigningArgs = { type: (kesPeriod: string) => BigInt(kesPeriod), help: 'KES period.', }, - '--operational-certificate-issue-counter': { - required: true, - dest: 'issueCounterFile', - help: 'Input filepath of the issue counter file.', + '_mutually-exclusive-group-required-operational-certificate-issue-counter': { + '--operational-certificate-issue-counter': { + dest: 'issueCounterFile', + help: 'Input filepath of the issue counter file. This option is DEPRECATED. Please use --operational-certificate-issue-counter-file instead.', + }, + '--operational-certificate-issue-counter-file': { + dest: 'issueCounterFile', + help: 'Input filepath of the issue counter file.', + }, }, '--hw-signing-file': { dest: 'hwSigningFileData', @@ -205,6 +222,7 @@ export const parserConfig = { dest: 'address', help: 'Input filepath of the address.', }, + ...derivationTypeArg, }, }, 'transaction': { @@ -230,6 +248,7 @@ export const parserConfig = { type: (path: string) => parseHwSigningFile(path), help: 'Input filepath of the hardware wallet signing file.', }, + ...derivationTypeArg, }, 'witness': { ...txSigningArgs, @@ -337,6 +356,7 @@ export const parserConfig = { dest: 'outFile', help: 'Output metadata cbor filepath.', }, + ...derivationTypeArg, }, }, } diff --git a/src/command-parser/parsers.ts b/src/command-parser/parsers.ts index be36f397..0e7b7a17 100644 --- a/src/command-parser/parsers.ts +++ b/src/command-parser/parsers.ts @@ -7,12 +7,19 @@ import { txTypeToCardanoEra, } from '../constants' import { - isBIP32Path, isCborHex, isHwSigningData, isRawTxFileData, isTxFileData, isVotePublicKeyHex, + isBIP32Path, + isCborHex, + isDerivationType, + isHwSigningData, + isRawTxFileData, + isTxFileData, + isVotePublicKeyHex, } from '../guards' import { Errors } from '../errors' import { Address, BIP32Path, + DerivationType, HwSigningData, HwSigningType, NativeScript, @@ -267,3 +274,11 @@ export const parseNativeScriptFile = (path: string): NativeScript => { return parseNativeScriptData(data) } + +export const parseDerivationType = ( + name?: string, +): DerivationType | undefined => { + if (!name) return undefined + if (isDerivationType(name)) return name + throw Error(Errors.InvalidDerivationTypeError) +} diff --git a/src/commandExecutor.ts b/src/commandExecutor.ts index eaa4c9ac..a3eaabe1 100644 --- a/src/commandExecutor.ts +++ b/src/commandExecutor.ts @@ -1,6 +1,6 @@ import * as InteropLib from 'cardano-hw-interop-lib' import TransportNodeHid from '@ledgerhq/hw-transport-node-hid-noevents' -import { CryptoProvider } from './crypto-providers/types' +import { CryptoProvider, SigningParameters } from './crypto-providers/types' import { constructTxFileOutput, constructHwSigningKeyOutput, @@ -81,10 +81,12 @@ const CommandExecutor = async () => { } const createSigningKeyFile = async ( - { paths, hwSigningFiles, verificationKeyFiles }: ParsedAddressKeyGenArguments, + { + paths, hwSigningFiles, verificationKeyFiles, derivationType, + }: ParsedAddressKeyGenArguments, ) => { validateKeyGenInputs(paths, hwSigningFiles, verificationKeyFiles) - const xPubKeys = await cryptoProvider.getXPubKeys(paths) + const xPubKeys = await cryptoProvider.getXPubKeys(paths, derivationType) xPubKeys.forEach((xPubKey, i) => writeOutputData( hwSigningFiles[i], constructHwSigningKeyOutput(xPubKey, paths[i]), @@ -125,7 +127,7 @@ const CommandExecutor = async () => { const txBody = (rawTx?.body ?? tx?.body)! const era = (args.rawTxFileData?.era ?? args.txFileData?.era)! - const signingParameters = { + const signingParameters: SigningParameters = { signingMode: determineSigningMode(txBody, args.hwSigningFileData), rawTx, tx, @@ -133,6 +135,7 @@ const CommandExecutor = async () => { hwSigningFileData: args.hwSigningFileData, network: args.network, era, + derivationType: args.derivationType, } validateSigning(signingParameters) @@ -147,6 +150,7 @@ const CommandExecutor = async () => { args.nativeScript, args.hwSigningFileData, NativeScriptDisplayFormat.POLICY_ID, + args.derivationType, ) // eslint-disable-next-line no-console @@ -171,7 +175,7 @@ const CommandExecutor = async () => { const txBody = (rawTx?.body ?? tx?.body)! const era = (args.rawTxFileData?.era ?? args.txFileData?.era)! - const signingParameters = { + const signingParameters: SigningParameters = { signingMode: determineSigningMode(txBody, args.hwSigningFileData), rawTx, tx, @@ -179,6 +183,7 @@ const CommandExecutor = async () => { hwSigningFileData: args.hwSigningFileData, network: args.network, era, + derivationType: args.derivationType, } validateWitnessing(signingParameters) const { @@ -271,6 +276,7 @@ const CommandExecutor = async () => { args.votePublicKey, args.network, args.nonce, + args.derivationType, ) writeCbor(args.outFile, Buffer.from(votingRegistrationMetaData, 'hex') as Cbor) diff --git a/src/crypto-providers/ledgerCryptoProvider.ts b/src/crypto-providers/ledgerCryptoProvider.ts index 5d28a29c..fef79d43 100644 --- a/src/crypto-providers/ledgerCryptoProvider.ts +++ b/src/crypto-providers/ledgerCryptoProvider.ts @@ -33,9 +33,6 @@ import { } from './types' import { findSigningPathForKeyHash, - getSigningPath, - PathTypes, - classifyPath, getAddressAttributes, ipv4ToString, ipv6ToString, @@ -48,6 +45,8 @@ import { rewardAccountToStakeCredential, areAddressParamsAllowed, pathEquals, + classifyPath, + PathTypes, } from './util' const { bech32 } = require('cardano-crypto.js') @@ -104,18 +103,13 @@ export const LedgerCryptoProvider: (transport: Transport) => Promise { - const pathToUse = (signingMode === SigningMode.POOL_REGISTRATION_AS_OWNER) - ? null // inputs are required to be given without path in this case - : path if (input.index > Number.MAX_SAFE_INTEGER) { throw Error(Errors.InvalidInputError) } return { - path: pathToUse, + path: null, // all payment paths are added added as additionalWitnessRequests txHashHex: input.transactionId.toString('hex'), outputIndex: Number(input.index), } @@ -531,13 +525,12 @@ export const LedgerCryptoProvider: (transport: Transport) => Promise { if (collateralInput.index > Number.MAX_SAFE_INTEGER) { throw Error(Errors.InvalidCollateralInputError) } return { - path, + path: null, // all payment paths are added added as additionalWitnessRequests txHashHex: collateralInput.transactionId.toString('hex'), outputIndex: Number(collateralInput.index), } @@ -560,13 +553,15 @@ export const LedgerCryptoProvider: (transport: Transport) => Promise ( - // Even though Plutus txs might require additional payment/stake signatures, Plutus scripts + // Payment signing files are always added here, so that the inputs are witnessed. + // Even though Plutus txs might require additional stake signatures, Plutus scripts // don't see signatures directly - they can only access requiredSigners, and their witnesses // are gathered above. - [...mintSigningFiles, ...multisigSigningFiles].map((f) => f.path) + [...paymentSigningFiles, ...mintSigningFiles, ...multisigSigningFiles].map((f) => f.path) ) const createWitnesses = ( @@ -581,8 +576,6 @@ export const LedgerCryptoProvider: (transport: Transport) => Promise classifyPath(path) === PathTypes.PATH_WALLET_SPENDING_KEY_BYRON - const witnessesWithKeys = ledgerWitnesses.map((witness) => { const { pubKey, chainCode } = splitXPubKeyCborHex( getSigningFileDataByPath(witness.path as BIP32Path).cborXPubKeyHex, @@ -596,7 +589,7 @@ export const LedgerCryptoProvider: (transport: Transport) => Promise isByronPath(witness.path), + (witness) => classifyPath(witness.path) === PathTypes.PATH_WALLET_SPENDING_KEY_BYRON, ) return { @@ -644,10 +637,7 @@ export const LedgerCryptoProvider: (transport: Transport) => Promise prepareInput(signingMode, input, getSigningPath(paymentSigningFiles, i)), - ) + const inputs = body.inputs.map(prepareInput) const outputs = body.outputs.map( (output) => prepareOutput(output, network, changeOutputFiles, signingMode), ) @@ -668,14 +658,7 @@ export const LedgerCryptoProvider: (transport: Transport) => Promise prepareCollateralInput( - // first `inputs.length` signing files were assigned to inputs, - // assign the following `collaterals.length` signing files to collateral inputs - collateralInput, - getSigningPath(paymentSigningFiles, inputs.length + i), - ), - ) + const collateralInputs = body.collateralInputs?.map(prepareCollateralInput) const requiredSigners = body.requiredSigners?.map( (requiredSigner) => prepareRequiredSigner( requiredSigner, @@ -687,11 +670,13 @@ export const LedgerCryptoProvider: (transport: Transport) => Promise prepareInput(signingMode, referenceInput, null), - ) + const referenceInputs = body.referenceInputs?.map(prepareInput) - const additionalWitnessRequests = prepareAdditionalWitnessRequests(mintSigningFiles, multisigSigningFiles) + const additionalWitnessRequests = prepareAdditionalWitnessRequests( + paymentSigningFiles, + mintSigningFiles, + multisigSigningFiles, + ) const response = await ledger.signTransaction({ signingMode: signingModeToLedgerType(signingMode), diff --git a/src/crypto-providers/trezorCryptoProvider.ts b/src/crypto-providers/trezorCryptoProvider.ts index 7019d69a..c7998bc1 100644 --- a/src/crypto-providers/trezorCryptoProvider.ts +++ b/src/crypto-providers/trezorCryptoProvider.ts @@ -31,13 +31,13 @@ import { XPubKeyHex, NativeScriptType, ParsedShowAddressArguments, + DerivationType, } from '../types' import { encodeAddress, filterSigningFiles, findSigningPathForKeyHash, getAddressAttributes, - getSigningPath, ipv4ToString, ipv6ToString, getAddressParameters, @@ -99,9 +99,26 @@ const TrezorCryptoProvider: () => Promise = async () => { await initTrezorConnect() + const derivationTypeToTrezorType = ( + derivationType?: DerivationType, + ): TrezorEnums.CardanoDerivationType | undefined => { + switch (derivationType) { + case undefined: + return undefined + case DerivationType.LEDGER: + return TrezorEnums.CardanoDerivationType.LEDGER + case DerivationType.ICARUS: + return TrezorEnums.CardanoDerivationType.ICARUS + case DerivationType.ICARUS_TREZOR: + return TrezorEnums.CardanoDerivationType.ICARUS_TREZOR + default: + throw Error(Errors.Unreachable) + } + } + const showAddress = async ( { - paymentPath, paymentScriptHash, stakingPath, stakingScriptHash, address, + paymentPath, paymentScriptHash, stakingPath, stakingScriptHash, address, derivationType, }: ParsedShowAddressArguments, ): Promise => { const { addressType, networkId, protocolMagic } = getAddressAttributes(address) @@ -116,6 +133,7 @@ const TrezorCryptoProvider: () => Promise = async () => { }, networkId, protocolMagic, + derivationType: derivationTypeToTrezorType(derivationType), showOnTrezor: true, }) @@ -124,11 +142,15 @@ const TrezorCryptoProvider: () => Promise = async () => { } } - const getXPubKeys = async (paths: BIP32Path[]): Promise => { + const getXPubKeys = async ( + paths: BIP32Path[], + derivationType?: DerivationType, + ): Promise => { const { payload } = await TrezorConnect.cardanoGetPublicKey({ bundle: paths.map((path) => ({ path, showOnTrezor: true, + derivationType: derivationTypeToTrezorType(derivationType), })), }) @@ -144,13 +166,12 @@ const TrezorCryptoProvider: () => Promise = async () => { const prepareInput = ( input: TxTypes.TransactionInput, - path: BIP32Path | null, ): TrezorTypes.CardanoInput => { if (input.index > Number.MAX_SAFE_INTEGER) { throw Error(Errors.InvalidInputError) } return { - path: path || undefined, + path: undefined, // all payment paths are added added as additionalWitnessRequests prev_hash: input.transactionId.toString('hex'), prev_index: Number(input.index), } @@ -433,13 +454,12 @@ const TrezorCryptoProvider: () => Promise = async () => { const prepareCollateralInput = ( collateralInput: TxTypes.TransactionInput, - path: BIP32Path | null, ): TrezorTypes.CardanoCollateralInput => { if (collateralInput.index > Number.MAX_SAFE_INTEGER) { throw Error(Errors.InvalidCollateralInputError) } return { - path: path || undefined, + path: undefined, // all payment paths are added as added additionalWitnessRequests prev_hash: collateralInput.transactionId.toString('hex'), prev_index: Number(collateralInput.index), } @@ -456,13 +476,15 @@ const TrezorCryptoProvider: () => Promise = async () => { } const prepareAdditionalWitnessRequests = ( + paymentSigningFiles: HwSigningData[], mintSigningFiles: HwSigningData[], multisigSigningFiles: HwSigningData[], ) => ( - // Even though Plutus txs might require additional payment/stake signatures, Plutus scripts + // Payment signing files are always added here, so that the inputs are witnessed. + // Even though Plutus txs might require additional stake signatures, Plutus scripts // don't see signatures directly - they can only access requiredSigners, and their witnesses // are gathered above. - [...mintSigningFiles, ...multisigSigningFiles].map((f) => f.path) + [...paymentSigningFiles, ...mintSigningFiles, ...multisigSigningFiles].map((f) => f.path) ) const createWitnesses = ( @@ -532,17 +554,14 @@ const TrezorCryptoProvider: () => Promise = async () => { changeOutputFiles: HwSigningData[], ): Promise => { const { - signingMode, rawTx, tx, txBodyHashHex, hwSigningFileData, network, + signingMode, rawTx, tx, txBodyHashHex, hwSigningFileData, network, derivationType, } = params const body = (rawTx?.body ?? tx?.body)! const { paymentSigningFiles, stakeSigningFiles, mintSigningFiles, multisigSigningFiles, } = filterSigningFiles(hwSigningFileData) - const inputs = body.inputs.map( - // assign first `inputs.length` signing files to inputs - (input, i) => prepareInput(input, getSigningPath(paymentSigningFiles, i)), - ) + const inputs = body.inputs.map(prepareInput) const outputs = body.outputs.map( (output) => prepareOutput(output, network, changeOutputFiles, signingMode), ) @@ -558,14 +577,7 @@ const TrezorCryptoProvider: () => Promise = async () => { const auxiliaryData = prepareAuxiliaryDataHashHex(body.auxiliaryDataHash) const mint = body.mint ? prepareTokenBundle(body.mint, true) : undefined const scriptDataHash = prepareScriptDataHash(body.scriptDataHash) - const collateralInputs = body.collateralInputs?.map( - (collateralInput, i) => prepareCollateralInput( - // first `inputs.length` signing files were assigned to inputs, - // assign the following `collaterals.length` signing files to collateral inputs - collateralInput, - getSigningPath(paymentSigningFiles, inputs.length + i), - ), - ) + const collateralInputs = body.collateralInputs?.map(prepareCollateralInput) const requiredSigners = body.requiredSigners?.map( (requiredSigner) => prepareRequiredSigner( requiredSigner, @@ -577,9 +589,13 @@ const TrezorCryptoProvider: () => Promise = async () => { ? prepareOutput(body.collateralReturnOutput, network, changeOutputFiles, signingMode) : undefined const totalCollateral = body.totalCollateral !== undefined ? `${body.totalCollateral}` : undefined - const referenceInputs = body.referenceInputs?.map((referenceInput) => prepareInput(referenceInput, null)) + const referenceInputs = body.referenceInputs?.map(prepareInput) - const additionalWitnessRequests = prepareAdditionalWitnessRequests(mintSigningFiles, multisigSigningFiles) + const additionalWitnessRequests = prepareAdditionalWitnessRequests( + paymentSigningFiles, + mintSigningFiles, + multisigSigningFiles, + ) const request: TrezorTypes.CardanoSignTransaction = { signingMode: signingModeToTrezorType(signingMode), @@ -602,6 +618,7 @@ const TrezorCryptoProvider: () => Promise = async () => { collateralReturn, totalCollateral, referenceInputs, + derivationType: derivationTypeToTrezorType(derivationType), } const response = await TrezorConnect.cardanoSignTransaction(request) @@ -702,6 +719,7 @@ const TrezorCryptoProvider: () => Promise = async () => { votePublicKeyHex: VotePublicKeyHex, network: Network, nonce: BigInt, + derivationType?: DerivationType, ): Promise => { const { data: address } : { data: Buffer } = bech32.decode(rewardAddressBech32) const addressParams = getAddressParameters(rewardAddressSigningFiles, address, network) @@ -714,7 +732,10 @@ const TrezorCryptoProvider: () => Promise = async () => { const trezorAuxData = prepareVoteAuxiliaryData(hwStakeSigningFile, votePublicKeyHex, addressParams, nonce) const dummyTx = prepareDummyTx(network, trezorAuxData) - const response = await TrezorConnect.cardanoSignTransaction(dummyTx) + const response = await TrezorConnect.cardanoSignTransaction({ + ...dummyTx, + derivationType: derivationTypeToTrezorType(derivationType), + }) if (!response.success) { throw Error(response.payload.error) } @@ -809,10 +830,12 @@ const TrezorCryptoProvider: () => Promise = async () => { nativeScript: NativeScript, signingFiles: HwSigningData[], displayFormat: NativeScriptDisplayFormat, + derivationType?: DerivationType, ): Promise => { const response = await TrezorConnect.cardanoGetNativeScriptHash({ script: nativeScriptToTrezorTypes(nativeScript, signingFiles), displayFormat: nativeScriptDisplayFormatToTrezorType(displayFormat), + derivationType: derivationTypeToTrezorType(derivationType), }) if (!response.success) { throw Error(response.payload.error) diff --git a/src/crypto-providers/types.ts b/src/crypto-providers/types.ts index dad4c0cf..464a3bd1 100644 --- a/src/crypto-providers/types.ts +++ b/src/crypto-providers/types.ts @@ -16,6 +16,7 @@ import { NativeScriptDisplayFormat, ParsedShowAddressArguments, CardanoEra, + DerivationType, } from '../types' export enum SigningMode { @@ -34,6 +35,7 @@ export type SigningParameters = { hwSigningFileData: HwSigningData[], network: Network, era: CardanoEra, + derivationType?: DerivationType, } export type CryptoProvider = { @@ -49,7 +51,10 @@ export type CryptoProvider = { params: SigningParameters, changeOutputFiles: HwSigningData[], ) => Promise, - getXPubKeys: (paths: BIP32Path[]) => Promise, + getXPubKeys: ( + paths: BIP32Path[], + derivationType?: DerivationType, + ) => Promise, signOperationalCertificate: ( kesVKey: KesVKey, kesPeriod: BigInt, @@ -63,11 +68,13 @@ export type CryptoProvider = { votePublicKeyHex: VotePublicKeyHex, network: Network, nonce: BigInt, + derivationType?: DerivationType, ) => Promise deriveNativeScriptHash: ( nativeScript: NativeScript, signingFiles: HwSigningData[], displayFormat: NativeScriptDisplayFormat, + derivationType?: DerivationType, ) => Promise, } diff --git a/src/crypto-providers/util.ts b/src/crypto-providers/util.ts index 2d40c4c5..89f9c68e 100644 --- a/src/crypto-providers/util.ts +++ b/src/crypto-providers/util.ts @@ -159,17 +159,6 @@ const encodeAddress = (address: Buffer): string => { return bech32.encode(addressPrefix, address) } -const getSigningPath = ( - signingFiles: HwSigningData[], - i: number, -): BIP32Path | null => { - if (signingFiles.length === 0) return null - // in case signingFiles.length < input.length - // we return the first path since all we need is to pass all the paths - // disregarding their order - return signingFiles[i] ? signingFiles[i].path : signingFiles[0].path -} - const filterSigningFiles = ( signingFiles: HwSigningData[], ): { @@ -235,6 +224,10 @@ const extractStakePubKeyFromHwSigningData = (signingFile: HwSigningData): PubKey throw Error(Errors.InternalInvalidTypeError) } +const hasPaymentSigningFile = (signingFiles: HwSigningData[]): boolean => ( + signingFiles.some((signingFile) => signingFile.type === HwSigningType.Payment) +) + const hasMultisigSigningFile = (signingFiles: HwSigningData[]): boolean => ( signingFiles.some((signingFile) => signingFile.type === HwSigningType.MultiSig) ) @@ -262,15 +255,16 @@ const determineSigningMode = ( // signingValidation.ts. if (poolRegistrationCert) { const poolKeyPath = findSigningPathForKeyHash(poolRegistrationCert.poolParams.operator, signingFiles) - return poolKeyPath + const isPaying = hasPaymentSigningFile(signingFiles) + return (poolKeyPath || isPaying) ? SigningMode.POOL_REGISTRATION_AS_OPERATOR : SigningMode.POOL_REGISTRATION_AS_OWNER } - // Collaterals an required signers are allowed only in the PLUTUS signing mode. Note that we have - // to consider PLUTUS signing mode before MULTISIG, because multisig signing files are allowed in - // PLUTUS signing mode, too. - if (txBody.collateralInputs || txBody.requiredSigners) { + // Collaterals are allowed only in the PLUTUS signing mode. Note that we have to consider PLUTUS + // signing mode before MULTISIG, because multisig signing files are allowed in PLUTUS signing + // mode, too. + if (txBody.collateralInputs) { return SigningMode.PLUTUS_TRANSACTION } @@ -565,7 +559,6 @@ export { pathEquals, splitXPubKeyCborHex, validateKeyGenInputs, - getSigningPath, filterSigningFiles, findSigningPathForKeyHash, findSigningPathForKey, diff --git a/src/errors.ts b/src/errors.ts index e775f61b..91364d94 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -9,6 +9,7 @@ const enum Errors { InvalidKesVKeyFileError = 'Invalid KES verification key file', InvalidOpCertIssueCounterFileError = 'Invalid operational certificate issue counter file', InvalidNodeKeyGenInputsError = 'Invalid node key-gen inputs', + InvalidDerivationTypeError = 'Invalid derivation type', TxSerializationMismatchError = 'Tx serialization mismatch', MetadataSerializationMismatchError = 'Metadata serialization mismatch', MissingHwSigningDataAtPathError = 'Can not find hw signing data by path', diff --git a/src/fileWriter.ts b/src/fileWriter.ts index a10efea5..aec8e25e 100644 --- a/src/fileWriter.ts +++ b/src/fileWriter.ts @@ -71,11 +71,12 @@ const constructBIP32PathOutput = (path: BIP32Path): string => path .map((value) => (value >= HARDENED_THRESHOLD ? `${value - HARDENED_THRESHOLD}H` : `${value}`)) .join('/') -const bip32PathLabel = (path: number[]): PathLabel => { +const bip32PathLabel = (path: BIP32Path): PathLabel => { switch (classifyPath(path)) { case PathTypes.PATH_POOL_COLD_KEY: return PathLabel.POOL_COLD + case PathTypes.PATH_WALLET_SPENDING_KEY_BYRON: case PathTypes.PATH_WALLET_SPENDING_KEY_SHELLEY: case PathTypes.PATH_WALLET_SPENDING_KEY_MULTISIG: case PathTypes.PATH_WALLET_MINTING_KEY: @@ -90,19 +91,14 @@ const bip32PathLabel = (path: number[]): PathLabel => { } } -const verificationKeyType = (path: number[]): string => { - const pathType = classifyPath(path) - const isShelleyEnvelope = pathType === PathTypes.PATH_WALLET_ACCOUNT - || pathType === PathTypes.PATH_WALLET_SPENDING_KEY_SHELLEY - || pathType === PathTypes.PATH_WALLET_STAKING_KEY - || pathType === PathTypes.PATH_WALLET_ACCOUNT_MULTISIG - || pathType === PathTypes.PATH_WALLET_SPENDING_KEY_MULTISIG - || pathType === PathTypes.PATH_WALLET_STAKING_KEY_MULTISIG - || pathType === PathTypes.PATH_WALLET_MINTING_KEY - return `${bip32PathLabel(path)}VerificationKey${isShelleyEnvelope ? 'Shelley' : ''}_ed25519` +const verificationKeyType = (path: BIP32Path): string => { + const label = bip32PathLabel(path) + return classifyPath(path) === PathTypes.PATH_WALLET_SPENDING_KEY_BYRON + ? `${label}VerificationKeyByron_ed25519_bip32` + : `${label}VerificationKeyShelley_ed25519` } -const verificationKeyDescription = (path: number[]): string => { +const verificationKeyDescription = (path: BIP32Path): string => { switch (classifyPath(path)) { case PathTypes.PATH_POOL_COLD_KEY: return 'Stake Pool Operator Verification Key' @@ -123,6 +119,8 @@ const verificationKeyDescription = (path: number[]): string => { return 'Mint Verification Key' case PathTypes.PATH_WALLET_SPENDING_KEY_BYRON: + return 'Payment Verification Key' + case PathTypes.PATH_WALLET_ACCOUNT: case PathTypes.PATH_INVALID: default: @@ -144,8 +142,11 @@ const constructVerificationKeyOutput = ( const constructHwSigningKeyOutput = (xPubKey: XPubKeyHex, path: BIP32Path): HwSigningOutput => { const label = bip32PathLabel(path) + const type = classifyPath(path) === PathTypes.PATH_WALLET_SPENDING_KEY_BYRON + ? `${label}HWSigningFileByron_ed25519_bip32` + : `${label}HWSigningFileShelley_ed25519` return { - type: `${label}HWSigningFileShelley_ed25519`, + type, description: `${label} Hardware Signing File`, path: constructBIP32PathOutput(path), cborXPubKeyHex: encodeCbor(Buffer.from(xPubKey, 'hex')).toString('hex'), diff --git a/src/guards.ts b/src/guards.ts index 9d9e9406..fff947fb 100644 --- a/src/guards.ts +++ b/src/guards.ts @@ -18,6 +18,7 @@ import { X_PUB_KEY_HEX_LENGTH, X_PUB_KEY_CBOR_HEX_LENGTH, VOTE_PUBLIC_KEY_HEX_LENGTH, + DerivationType, } from './types' import { decodeCbor } from './util' @@ -86,3 +87,7 @@ export const isXPubKeyCborHex = ( export const isVotePublicKeyHex = ( value: any, ): value is VotePublicKeyHex => typeof value === 'string' && value.length === VOTE_PUBLIC_KEY_HEX_LENGTH * 2 + +export const isDerivationType = ( + value: any, +): value is DerivationType => typeof value === 'string' && value in DerivationType diff --git a/src/types.ts b/src/types.ts index d7256bc8..93f79995 100644 --- a/src/types.ts +++ b/src/types.ts @@ -66,6 +66,17 @@ export type TxFileData = { export type Address = string +/* eslint-disable max-len */ +// Currently, this is used only by Trezor. Relevant docs: +// https://github.com/trezor/trezor-suite/blob/1a0125c9e1d738f5750f935f1aed4d17a37e69ba/docs/packages/connect/methods/cardanoSignTransaction.md#params +// https://github.com/trezor/trezor-firmware/blob/4bed278e80d23077676128eba8cb2478fcd31120/core/src/apps/cardano/README.md#seed-derivation-schemes +/* eslint-enable max-len */ +export enum DerivationType { + LEDGER = 'LEDGER', + ICARUS = 'ICARUS', + ICARUS_TREZOR = 'ICARUS_TREZOR', +} + export type ParsedAppVersionArguments = { command: CommandType.APP_VERSION, } @@ -83,6 +94,7 @@ export type ParsedShowAddressArguments = { stakingPath: BIP32Path, stakingScriptHash: string, address: Address, + derivationType?: DerivationType, } export type ParsedAddressKeyGenArguments = { @@ -90,6 +102,7 @@ export type ParsedAddressKeyGenArguments = { paths: BIP32Path[], hwSigningFiles: string[], verificationKeyFiles: string[], + derivationType?: DerivationType, } export type ParsedVerificationKeyArguments = { @@ -124,6 +137,7 @@ export type ParsedTransactionSignArguments = { hwSigningFileData: HwSigningData[], outFile: string, changeOutputKeyFileData: HwSigningData[], + derivationType?: DerivationType, } export enum NativeScriptType { @@ -159,6 +173,7 @@ export type ParsedTransactionPolicyIdArguments = { command: CommandType.DERIVE_NATIVE_SCRIPT_HASH, nativeScript: NativeScript, hwSigningFileData: HwSigningData[], + derivationType?: DerivationType, } // exctly one of rawTxFileData vs. txFileData should be present @@ -171,6 +186,7 @@ export type ParsedTransactionWitnessArguments = { hwSigningFileData: HwSigningData[], outFiles: string[], changeOutputKeyFileData: HwSigningData[], + derivationType?: DerivationType, } export type ParsedTransactionValidateRawArguments = { @@ -221,6 +237,7 @@ export type ParsedCatalystVotingKeyRegistrationMetadataArguments = { nonce: BigInt, rewardAddressSigningKeyData: HwSigningData[], outFile: string, + derivationType?: DerivationType, } export type ParsedArguments = diff --git a/test/integration/ledger/node/tx.js b/test/integration/ledger/node/tx.js index 28969287..609ec32a 100644 --- a/test/integration/ledger/node/tx.js +++ b/test/integration/ledger/node/tx.js @@ -64,40 +64,40 @@ const transactions = { // de59b913705be59f6aff90df6eccfe4f0f115bc8de8306a77b188642b763ad61 unsignedCborHex: '82a50081825820bc8bf52ea894fb8e442fe3eea628be87d0c9a37baef185b70eb00a5c8a849d3b0001818258390114c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f11241d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a00311cba021a0002c431031a00ac30b105a1581de11d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a000ded3af6', hwSigningFiles: [signingFiles.payment0, signingFiles.stake0], - signedTxCborHex: '83a50081825820bc8bf52ea894fb8e442fe3eea628be87d0c9a37baef185b70eb00a5c8a849d3b0001818258390114c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f11241d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a00311cba021a0002c431031a00ac30b105a1581de11d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a000ded3aa10082825820cd2b047d1a803eee059769cffb3dfd0a4b9327e55bc78aa962d9bd4f720db0b25840501a09efd212efd741574e63e9ff6c701746cac68ddcba3af5ef655ff1e724399adef1eb258ffdb34fd09d7b91c4b2f612bfba083b2debaa87ed93fcf4bc1f0882582066610efd336e1137c525937b76511fbcf2a0e6bcf0d340a67bcb39bc870d85e85840eeb76938fd9676a34ba0710dc27810d087507b3a75ac6f67543b0b22405c927ad9f575a258aa7ed1dd1bbf3d24596315ffba8d630e0a1ea8d105826b865b3808f6', + signedTxCborHex: '83a50081825820bc8bf52ea894fb8e442fe3eea628be87d0c9a37baef185b70eb00a5c8a849d3b0001818258390114c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f11241d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a00311cba021a0002c431031a00ac30b105a1581de11d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a000ded3aa1008282582066610efd336e1137c525937b76511fbcf2a0e6bcf0d340a67bcb39bc870d85e85840eeb76938fd9676a34ba0710dc27810d087507b3a75ac6f67543b0b22405c927ad9f575a258aa7ed1dd1bbf3d24596315ffba8d630e0a1ea8d105826b865b3808825820cd2b047d1a803eee059769cffb3dfd0a4b9327e55bc78aa962d9bd4f720db0b25840501a09efd212efd741574e63e9ff6c701746cac68ddcba3af5ef655ff1e724399adef1eb258ffdb34fd09d7b91c4b2f612bfba083b2debaa87ed93fcf4bc1f08f6', network: 'MAINNET', }, ordinary_CertificateStakingKeyDeregistration: { // 148aa5e66a734657fbe4125ec028b231adf40e9bd426493fadd387453c1ff4bf unsignedCborHex: '82a50081825820de59b913705be59f6aff90df6eccfe4f0f115bc8de8306a77b188642b763ad610001818258390114c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f11241d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a004cbb0a021a0002e630031a00ac352f048182018200581c1d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61cf6', hwSigningFiles: [signingFiles.payment0, signingFiles.stake0], - signedTxCborHex: '83a50081825820de59b913705be59f6aff90df6eccfe4f0f115bc8de8306a77b188642b763ad610001818258390114c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f11241d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a004cbb0a021a0002e630031a00ac352f048182018200581c1d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61ca10082825820cd2b047d1a803eee059769cffb3dfd0a4b9327e55bc78aa962d9bd4f720db0b25840be03013f49435795c02c6fd38057841133c0787fd80cca4a607d0b91ad8bd83f545b95a276f85b4568fdab3db851844cc88d9e77ad2080776fcef6679ec4be0382582066610efd336e1137c525937b76511fbcf2a0e6bcf0d340a67bcb39bc870d85e858405bdfbda835bd3ed18043c399249561159a95d40bd1162bc8288f3319601519f1a7a01fdcca18a3ba598cc300f6f74e9c67dc203d7fb1300b8ce09ab5473ba905f6', + signedTxCborHex: '83a50081825820de59b913705be59f6aff90df6eccfe4f0f115bc8de8306a77b188642b763ad610001818258390114c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f11241d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a004cbb0a021a0002e630031a00ac352f048182018200581c1d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61ca1008282582066610efd336e1137c525937b76511fbcf2a0e6bcf0d340a67bcb39bc870d85e858405bdfbda835bd3ed18043c399249561159a95d40bd1162bc8288f3319601519f1a7a01fdcca18a3ba598cc300f6f74e9c67dc203d7fb1300b8ce09ab5473ba905825820cd2b047d1a803eee059769cffb3dfd0a4b9327e55bc78aa962d9bd4f720db0b25840be03013f49435795c02c6fd38057841133c0787fd80cca4a607d0b91ad8bd83f545b95a276f85b4568fdab3db851844cc88d9e77ad2080776fcef6679ec4be03f6', network: 'MAINNET', }, ordinary_CertificateDelegation: { // a160aea80fa85221810099305045a6a3bc345709eee4d68eb4b7e04f0894a1cb unsignedCborHex: '82a5008182582071b1f4d93070d035b27ce482784617238f75342d7d2da77a97828c9f561bff380001818258390114c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f11241d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a00286a2a021a0002e630031a00ac3962048183028200581c1d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c581c04c60c78417132a195cbb74975346462410f72612952a7c4ade7e438f6', hwSigningFiles: [signingFiles.payment0, signingFiles.stake0], - signedTxCborHex: '83a5008182582071b1f4d93070d035b27ce482784617238f75342d7d2da77a97828c9f561bff380001818258390114c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f11241d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a00286a2a021a0002e630031a00ac3962048183028200581c1d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c581c04c60c78417132a195cbb74975346462410f72612952a7c4ade7e438a10082825820cd2b047d1a803eee059769cffb3dfd0a4b9327e55bc78aa962d9bd4f720db0b2584047d07eb25370e2c90b894aae04de382d49186645f67467e58a1af0ede05e1e00c0baf09dd277dfc7c8f2cd77f014ff120eb823d62f900dd98fd71093740fdd0282582066610efd336e1137c525937b76511fbcf2a0e6bcf0d340a67bcb39bc870d85e858409ed729fd0cd2b44a24aaceb4b0ba5d67c1130d1e6e23fdd8f696d873e4ccd4337aea112323ccdcc12eb9db1d89760dd9577e86e4b722618e997d7d4d1bf9130cf6', + signedTxCborHex: '83a5008182582071b1f4d93070d035b27ce482784617238f75342d7d2da77a97828c9f561bff380001818258390114c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f11241d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a00286a2a021a0002e630031a00ac3962048183028200581c1d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c581c04c60c78417132a195cbb74975346462410f72612952a7c4ade7e438a1008282582066610efd336e1137c525937b76511fbcf2a0e6bcf0d340a67bcb39bc870d85e858409ed729fd0cd2b44a24aaceb4b0ba5d67c1130d1e6e23fdd8f696d873e4ccd4337aea112323ccdcc12eb9db1d89760dd9577e86e4b722618e997d7d4d1bf9130c825820cd2b047d1a803eee059769cffb3dfd0a4b9327e55bc78aa962d9bd4f720db0b2584047d07eb25370e2c90b894aae04de382d49186645f67467e58a1af0ede05e1e00c0baf09dd277dfc7c8f2cd77f014ff120eb823d62f900dd98fd71093740fdd02f6', network: 'MAINNET', }, ordinary_CertificateDelegation_HwsfilesSwappedOrder: { unsignedCborHex: '82a5008182582071b1f4d93070d035b27ce482784617238f75342d7d2da77a97828c9f561bff380001818258390114c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f11241d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a00286a2a021a0002e630031a00ac3962048183028200581c1d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c581c04c60c78417132a195cbb74975346462410f72612952a7c4ade7e438f6', hwSigningFiles: [signingFiles.stake0, signingFiles.payment0], - signedTxCborHex: '83a5008182582071b1f4d93070d035b27ce482784617238f75342d7d2da77a97828c9f561bff380001818258390114c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f11241d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a00286a2a021a0002e630031a00ac3962048183028200581c1d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c581c04c60c78417132a195cbb74975346462410f72612952a7c4ade7e438a10082825820cd2b047d1a803eee059769cffb3dfd0a4b9327e55bc78aa962d9bd4f720db0b2584047d07eb25370e2c90b894aae04de382d49186645f67467e58a1af0ede05e1e00c0baf09dd277dfc7c8f2cd77f014ff120eb823d62f900dd98fd71093740fdd0282582066610efd336e1137c525937b76511fbcf2a0e6bcf0d340a67bcb39bc870d85e858409ed729fd0cd2b44a24aaceb4b0ba5d67c1130d1e6e23fdd8f696d873e4ccd4337aea112323ccdcc12eb9db1d89760dd9577e86e4b722618e997d7d4d1bf9130cf6', + signedTxCborHex: '83a5008182582071b1f4d93070d035b27ce482784617238f75342d7d2da77a97828c9f561bff380001818258390114c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f11241d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a00286a2a021a0002e630031a00ac3962048183028200581c1d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c581c04c60c78417132a195cbb74975346462410f72612952a7c4ade7e438a1008282582066610efd336e1137c525937b76511fbcf2a0e6bcf0d340a67bcb39bc870d85e858409ed729fd0cd2b44a24aaceb4b0ba5d67c1130d1e6e23fdd8f696d873e4ccd4337aea112323ccdcc12eb9db1d89760dd9577e86e4b722618e997d7d4d1bf9130c825820cd2b047d1a803eee059769cffb3dfd0a4b9327e55bc78aa962d9bd4f720db0b2584047d07eb25370e2c90b894aae04de382d49186645f67467e58a1af0ede05e1e00c0baf09dd277dfc7c8f2cd77f014ff120eb823d62f900dd98fd71093740fdd02f6', network: 'MAINNET', }, ordinary_CertificateStakeKeyRegistrationAndDelegation: { // 71b1f4d93070d035b27ce482784617238f75342d7d2da77a97828c9f561bff38 unsignedCborHex: '82a50081825820148aa5e66a734657fbe4125ec028b231adf40e9bd426493fadd387453c1ff4bf0001818258390114c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f11241d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a002b505a021a0002e630031a00ac3809048282008200581c1d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c83028200581c1d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c581c04c60c78417132a195cbb74975346462410f72612952a7c4ade7e438f6', hwSigningFiles: [signingFiles.payment0, signingFiles.stake0], - signedTxCborHex: '83a50081825820148aa5e66a734657fbe4125ec028b231adf40e9bd426493fadd387453c1ff4bf0001818258390114c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f11241d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a002b505a021a0002e630031a00ac3809048282008200581c1d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c83028200581c1d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c581c04c60c78417132a195cbb74975346462410f72612952a7c4ade7e438a10082825820cd2b047d1a803eee059769cffb3dfd0a4b9327e55bc78aa962d9bd4f720db0b25840f0dff23af401202122f8681c1b2c78ec160fdb6b16a8d992ccbe86900e6fc377f0032102eab446ccb0b186f8fe929a11a2d5dfa42bd5505bf6d3e0125ea0210782582066610efd336e1137c525937b76511fbcf2a0e6bcf0d340a67bcb39bc870d85e8584082263d344567e6614f8493dc53fcc7737839bcf57f8566a8cd1e4b98b18704972a8e1784ca4d910986d9e706982a1a51b264b83ef25dfb17388ff23d8e124202f6', + signedTxCborHex: '83a50081825820148aa5e66a734657fbe4125ec028b231adf40e9bd426493fadd387453c1ff4bf0001818258390114c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f11241d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c1a002b505a021a0002e630031a00ac3809048282008200581c1d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c83028200581c1d227aefa4b773149170885aadba30aab3127cc611ddbc4999def61c581c04c60c78417132a195cbb74975346462410f72612952a7c4ade7e438a1008282582066610efd336e1137c525937b76511fbcf2a0e6bcf0d340a67bcb39bc870d85e8584082263d344567e6614f8493dc53fcc7737839bcf57f8566a8cd1e4b98b18704972a8e1784ca4d910986d9e706982a1a51b264b83ef25dfb17388ff23d8e124202825820cd2b047d1a803eee059769cffb3dfd0a4b9327e55bc78aa962d9bd4f720db0b25840f0dff23af401202122f8681c1b2c78ec160fdb6b16a8d992ccbe86900e6fc377f0032102eab446ccb0b186f8fe929a11a2d5dfa42bd5505bf6d3e0125ea02107f6', network: 'MAINNET', }, ordinary_CertificatePoolRetirement: { unsignedCborHex: '82a500818258201af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc00018182582b82d818582183581c9e1c71de652ec8b85fec296f0685ca3988781c94a2e1a5d89d92f45fa0001a0d0c25611a002dd2e802182a030a04818304581cdbfee4665e58c8f8e9b9ff02b17f32e08a42c855476a5d867c2737b7186df6', hwSigningFiles: [signingFiles.payment0, signingFiles.poolCold0], - signedTxCborHex: '83a500818258201af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc00018182582b82d818582183581c9e1c71de652ec8b85fec296f0685ca3988781c94a2e1a5d89d92f45fa0001a0d0c25611a002dd2e802182a030a04818304581cdbfee4665e58c8f8e9b9ff02b17f32e08a42c855476a5d867c2737b7186da10082825820cd2b047d1a803eee059769cffb3dfd0a4b9327e55bc78aa962d9bd4f720db0b25840db9082cd6f6157a201fbf2083e5b0d35ea4809f1ec9e40924ac981a3ee15bd79c0fd839adef0db5545967b3054f78f5df1d09617bd0785cc89c7a6468caafb038258203d7e84dca8b4bc322401a2cc814af7c84d2992a22f99554fe340d7df7910768d58409a45328f1823a683723918313e2a421bf6c3a0e01964930ef9720db5409801d2816df50e5b066d57c427c104a36c6198b97c8192183cf53748f447ccb443aa08f6', + signedTxCborHex: '83a500818258201af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc00018182582b82d818582183581c9e1c71de652ec8b85fec296f0685ca3988781c94a2e1a5d89d92f45fa0001a0d0c25611a002dd2e802182a030a04818304581cdbfee4665e58c8f8e9b9ff02b17f32e08a42c855476a5d867c2737b7186da100828258203d7e84dca8b4bc322401a2cc814af7c84d2992a22f99554fe340d7df7910768d58409a45328f1823a683723918313e2a421bf6c3a0e01964930ef9720db5409801d2816df50e5b066d57c427c104a36c6198b97c8192183cf53748f447ccb443aa08825820cd2b047d1a803eee059769cffb3dfd0a4b9327e55bc78aa962d9bd4f720db0b25840db9082cd6f6157a201fbf2083e5b0d35ea4809f1ec9e40924ac981a3ee15bd79c0fd839adef0db5545967b3054f78f5df1d09617bd0785cc89c7a6468caafb03f6', network: 'MAINNET', }, poolRegistrationAsOwner_NoRelays: { @@ -322,18 +322,18 @@ const transactions = { { key: 0, data: [ - Buffer.from('cd2b047d1a803eee059769cffb3dfd0a4b9327e55bc78aa962d9bd4f720db0b2', 'hex'), - Buffer.from('c049b5045eb0a389bb877a7727323380f646b783e5150dbae85aacee2876124392a574039fadf10573fc4ea795ca1e1796fdacbc4d791af3e9a148c69faac103', 'hex'), + Buffer.from('66610efd336e1137c525937b76511fbcf2a0e6bcf0d340a67bcb39bc870d85e8', 'hex'), + Buffer.from('b18af7c6097430b560a0e6d4234aaf45997b06de14edca32f75b481d403a888b6fd665eeed004cee1d7877eef9c6d303ddd472de8c10e3f8f133a576b0445d05', 'hex'), ], - path: signingFiles.payment0.path, + path: signingFiles.stake0.path, }, { key: 0, data: [ - Buffer.from('66610efd336e1137c525937b76511fbcf2a0e6bcf0d340a67bcb39bc870d85e8', 'hex'), - Buffer.from('b18af7c6097430b560a0e6d4234aaf45997b06de14edca32f75b481d403a888b6fd665eeed004cee1d7877eef9c6d303ddd472de8c10e3f8f133a576b0445d05', 'hex'), + Buffer.from('cd2b047d1a803eee059769cffb3dfd0a4b9327e55bc78aa962d9bd4f720db0b2', 'hex'), + Buffer.from('c049b5045eb0a389bb877a7727323380f646b783e5150dbae85aacee2876124392a574039fadf10573fc4ea795ca1e1796fdacbc4d791af3e9a148c69faac103', 'hex'), ], - path: signingFiles.stake0.path, + path: signingFiles.payment0.path, }, ], }, diff --git a/test/integration/trezor/node/tx.js b/test/integration/trezor/node/tx.js index c7497f69..b39577ac 100644 --- a/test/integration/trezor/node/tx.js +++ b/test/integration/trezor/node/tx.js @@ -21,28 +21,28 @@ const transactions = { // 37942f7997c26a6e7692a29fb382b68b9e485eabe204e2d0ae488d271a6eb3da unsignedCborHex: '82a500818258201d7b25ce20ee92aa96b6fba145e8b4a5efdefa7df8fc225477297cf026efadfa0001818258390180f9e2c88e6c817008f3a812ed889b4a4da8e0bd103f86e7335422aa122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b42771a00323cdc021a0002e595031a00e37f31048183028200581c122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b4277581c04c60c78417132a195cbb74975346462410f72612952a7c4ade7e438f6', hwSigningFiles: [signingFiles.payment0, signingFiles.stake0], - signedTxCborHex: '83a500818258201d7b25ce20ee92aa96b6fba145e8b4a5efdefa7df8fc225477297cf026efadfa0001818258390180f9e2c88e6c817008f3a812ed889b4a4da8e0bd103f86e7335422aa122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b42771a00323cdc021a0002e595031a00e37f31048183028200581c122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b4277581c04c60c78417132a195cbb74975346462410f72612952a7c4ade7e438a100828258205d010cf16fdeff40955633d6c565f3844a288a24967cf6b76acbeb271b4f13c158408c09b9f5aaaae2e07389d6101d5ecc4a2c6c33f87adc4ea4ff2a13b8a9128750ff4e67459d23c35aaff94e19d9be9ca8f5bb51245ebcf0d8c85a1ff45a401907825820bc65be1b0b9d7531778a1317c2aa6de936963c3f9ac7d5ee9e9eda25e0c97c5e5840d2addc046794d2ead623e3835b4edc02eba1502771ef145b5634ff63411751a4b63a7580ac9433914cc5e016bbbd23aced51044c479a39cc463cac235ad10003f6', + signedTxCborHex: '83a500818258201d7b25ce20ee92aa96b6fba145e8b4a5efdefa7df8fc225477297cf026efadfa0001818258390180f9e2c88e6c817008f3a812ed889b4a4da8e0bd103f86e7335422aa122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b42771a00323cdc021a0002e595031a00e37f31048183028200581c122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b4277581c04c60c78417132a195cbb74975346462410f72612952a7c4ade7e438a10082825820bc65be1b0b9d7531778a1317c2aa6de936963c3f9ac7d5ee9e9eda25e0c97c5e5840d2addc046794d2ead623e3835b4edc02eba1502771ef145b5634ff63411751a4b63a7580ac9433914cc5e016bbbd23aced51044c479a39cc463cac235ad100038258205d010cf16fdeff40955633d6c565f3844a288a24967cf6b76acbeb271b4f13c158408c09b9f5aaaae2e07389d6101d5ecc4a2c6c33f87adc4ea4ff2a13b8a9128750ff4e67459d23c35aaff94e19d9be9ca8f5bb51245ebcf0d8c85a1ff45a401907f6', network: 'MAINNET', }, withWithdrawal: { // 4376ea43c3552cb57197a41428fce00e3c2ec9cff7444e50fe9e3750c279549f unsignedCborHex: '82a500818258205c38555bbbec0e95cd59cd7df45195e07af73a8dbd08a246bf87a687765d6c590001818258390180f9e2c88e6c817008f3a812ed889b4a4da8e0bd103f86e7335422aa122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b42771a003aee4b021a0002eb41031a00e37f3105a1581de1122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b427719d08cf6', hwSigningFiles: [signingFiles.payment0, signingFiles.stake0], - signedTxCborHex: '83a500818258205c38555bbbec0e95cd59cd7df45195e07af73a8dbd08a246bf87a687765d6c590001818258390180f9e2c88e6c817008f3a812ed889b4a4da8e0bd103f86e7335422aa122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b42771a003aee4b021a0002eb41031a00e37f3105a1581de1122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b427719d08ca100828258205d010cf16fdeff40955633d6c565f3844a288a24967cf6b76acbeb271b4f13c15840054075f078180eca611201dcf9b6278b2b11389db5a2c841f4e6a5bd62ef6313cfe18c6dd08068878fea764245ed1c63a1e76687899d48849db77c8d9e944e02825820bc65be1b0b9d7531778a1317c2aa6de936963c3f9ac7d5ee9e9eda25e0c97c5e58400b266bfefe1919673e2aa456b123fdd9bc80ef9f6c948bbc2ad53ca58997ff454a8161d1164e1598255864a27c2ecab3734f9af1a753a24ba0275a72741e130af6', + signedTxCborHex: '83a500818258205c38555bbbec0e95cd59cd7df45195e07af73a8dbd08a246bf87a687765d6c590001818258390180f9e2c88e6c817008f3a812ed889b4a4da8e0bd103f86e7335422aa122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b42771a003aee4b021a0002eb41031a00e37f3105a1581de1122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b427719d08ca10082825820bc65be1b0b9d7531778a1317c2aa6de936963c3f9ac7d5ee9e9eda25e0c97c5e58400b266bfefe1919673e2aa456b123fdd9bc80ef9f6c948bbc2ad53ca58997ff454a8161d1164e1598255864a27c2ecab3734f9af1a753a24ba0275a72741e130a8258205d010cf16fdeff40955633d6c565f3844a288a24967cf6b76acbeb271b4f13c15840054075f078180eca611201dcf9b6278b2b11389db5a2c841f4e6a5bd62ef6313cfe18c6dd08068878fea764245ed1c63a1e76687899d48849db77c8d9e944e02f6', network: 'MAINNET', }, withStakingKeyDeregistration: { // b25238a1c60ee9e30dd4ce41af5fa78e2cc4e17346bcc47831a3c98c5945370f unsignedCborHex: '82a500818258204376ea43c3552cb57197a41428fce00e3c2ec9cff7444e50fe9e3750c279549f0001818258390180f9e2c88e6c817008f3a812ed889b4a4da8e0bd103f86e7335422aa122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b42771a0056925e021a0002e06d031a00e37f31048182018200581c122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b4277f6', hwSigningFiles: [signingFiles.payment0, signingFiles.stake0], - signedTxCborHex: '83a500818258204376ea43c3552cb57197a41428fce00e3c2ec9cff7444e50fe9e3750c279549f0001818258390180f9e2c88e6c817008f3a812ed889b4a4da8e0bd103f86e7335422aa122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b42771a0056925e021a0002e06d031a00e37f31048182018200581c122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b4277a100828258205d010cf16fdeff40955633d6c565f3844a288a24967cf6b76acbeb271b4f13c158400741de2b8807e44f9c8fafc75e8fd44190eddd629d31e5093e2f2c8723bb5df3007ea44d0d242b0ba35b24525782ccbd2e1e7c6bca8b29af744ae88fec635c00825820bc65be1b0b9d7531778a1317c2aa6de936963c3f9ac7d5ee9e9eda25e0c97c5e5840efe4b1bbfc0e4ec5aa3b7bb95d61c952bab7f4ab17b99ef197c0b1cb9dafd4b811a1275a56bfac75a1e2e718379487aef49d9f073d132a24ba13491698cef109f6', + signedTxCborHex: '83a500818258204376ea43c3552cb57197a41428fce00e3c2ec9cff7444e50fe9e3750c279549f0001818258390180f9e2c88e6c817008f3a812ed889b4a4da8e0bd103f86e7335422aa122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b42771a0056925e021a0002e06d031a00e37f31048182018200581c122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b4277a10082825820bc65be1b0b9d7531778a1317c2aa6de936963c3f9ac7d5ee9e9eda25e0c97c5e5840efe4b1bbfc0e4ec5aa3b7bb95d61c952bab7f4ab17b99ef197c0b1cb9dafd4b811a1275a56bfac75a1e2e718379487aef49d9f073d132a24ba13491698cef1098258205d010cf16fdeff40955633d6c565f3844a288a24967cf6b76acbeb271b4f13c158400741de2b8807e44f9c8fafc75e8fd44190eddd629d31e5093e2f2c8723bb5df3007ea44d0d242b0ba35b24525782ccbd2e1e7c6bca8b29af744ae88fec635c00f6', network: 'MAINNET', }, withStakeKeyRegistrationAndDelegation: { // 1d7b25ce20ee92aa96b6fba145e8b4a5efdefa7df8fc225477297cf026efadfa unsignedCborHex: '82a50081825820b25238a1c60ee9e30dd4ce41af5fa78e2cc4e17346bcc47831a3c98c5945370f0001818258390180f9e2c88e6c817008f3a812ed889b4a4da8e0bd103f86e7335422aa122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b42771a00352271021a0002eb6d031a00e37f31048282008200581c122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b427783028200581c122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b4277581c04c60c78417132a195cbb74975346462410f72612952a7c4ade7e438f6', hwSigningFiles: [signingFiles.payment0, signingFiles.stake0], - signedTxCborHex: '83a50081825820b25238a1c60ee9e30dd4ce41af5fa78e2cc4e17346bcc47831a3c98c5945370f0001818258390180f9e2c88e6c817008f3a812ed889b4a4da8e0bd103f86e7335422aa122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b42771a00352271021a0002eb6d031a00e37f31048282008200581c122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b427783028200581c122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b4277581c04c60c78417132a195cbb74975346462410f72612952a7c4ade7e438a100828258205d010cf16fdeff40955633d6c565f3844a288a24967cf6b76acbeb271b4f13c158406a111389b6bc7b8a8d4e0473f7d8833a4b9d07c28d7c3070e805e2c9ded76140ba77dee65cf4955557bb04e2b58e1c84113f1d20028612cc5fe8fb8b64614e02825820bc65be1b0b9d7531778a1317c2aa6de936963c3f9ac7d5ee9e9eda25e0c97c5e5840378975f3b728e434471179ed87b8a2041ea478aac2d588ca222a353de3beadae7ecf9c657e62cdb26e9a499dca67fb491386471a119a2b59e17c294ecf732909f6', + signedTxCborHex: '83a50081825820b25238a1c60ee9e30dd4ce41af5fa78e2cc4e17346bcc47831a3c98c5945370f0001818258390180f9e2c88e6c817008f3a812ed889b4a4da8e0bd103f86e7335422aa122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b42771a00352271021a0002eb6d031a00e37f31048282008200581c122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b427783028200581c122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b4277581c04c60c78417132a195cbb74975346462410f72612952a7c4ade7e438a10082825820bc65be1b0b9d7531778a1317c2aa6de936963c3f9ac7d5ee9e9eda25e0c97c5e5840378975f3b728e434471179ed87b8a2041ea478aac2d588ca222a353de3beadae7ecf9c657e62cdb26e9a499dca67fb491386471a119a2b59e17c294ecf7329098258205d010cf16fdeff40955633d6c565f3844a288a24967cf6b76acbeb271b4f13c158406a111389b6bc7b8a8d4e0473f7d8833a4b9d07c28d7c3070e805e2c9ded76140ba77dee65cf4955557bb04e2b58e1c84113f1d20028612cc5fe8fb8b64614e02f6', network: 'MAINNET', }, withMultipleInputsAndOutputs: { @@ -237,18 +237,18 @@ const transactions = { { key: 0, data: [ - Buffer.from('5d010cf16fdeff40955633d6c565f3844a288a24967cf6b76acbeb271b4f13c1', 'hex'), - Buffer.from('09cb0c7dc23f6b0ff1a3a736c4c32662deb18b692e5f7eab91e1e899c0cbd9a6456636ebf953277ee739b022988af58ba7434682493a38c79c52e8da8359e108', 'hex'), + Buffer.from('bc65be1b0b9d7531778a1317c2aa6de936963c3f9ac7d5ee9e9eda25e0c97c5e', 'hex'), + Buffer.from('f92cd0a7a47a97b034ccfa46e899dee01c3241cf23bf1eee1b9469ac1850a9fb5d967b3715ffc70a19ed58c004473f580144ae78bd694661f126dfb746f2e103', 'hex'), ], - path: signingFiles.payment0.path, + path: signingFiles.stake0.path, }, { key: 0, data: [ - Buffer.from('bc65be1b0b9d7531778a1317c2aa6de936963c3f9ac7d5ee9e9eda25e0c97c5e', 'hex'), - Buffer.from('f92cd0a7a47a97b034ccfa46e899dee01c3241cf23bf1eee1b9469ac1850a9fb5d967b3715ffc70a19ed58c004473f580144ae78bd694661f126dfb746f2e103', 'hex'), + Buffer.from('5d010cf16fdeff40955633d6c565f3844a288a24967cf6b76acbeb271b4f13c1', 'hex'), + Buffer.from('09cb0c7dc23f6b0ff1a3a736c4c32662deb18b692e5f7eab91e1e899c0cbd9a6456636ebf953277ee739b022988af58ba7434682493a38c79c52e8da8359e108', 'hex'), ], - path: signingFiles.stake0.path, + path: signingFiles.payment0.path, }, ], }, diff --git a/test/unit/commandParser/commandParser.js b/test/unit/commandParser/commandParser.js index 6005d468..d59571ce 100644 --- a/test/unit/commandParser/commandParser.js +++ b/test/unit/commandParser/commandParser.js @@ -1,7 +1,12 @@ /* eslint-disable max-len */ const assert = require('assert') const { CommandType, parse } = require('../../../src/command-parser/commandParser') -const { CardanoEra, HwSigningType, NativeScriptType } = require('../../../src/types') +const { + CardanoEra, + HwSigningType, + NativeScriptType, + DerivationType, +} = require('../../../src/types') const { cardanoEraToSignedType, NETWORKS } = require('../../../src/constants') const resFolder = 'test/unit/commandParser/res/' @@ -29,6 +34,34 @@ describe('Command parser', () => { stakingPath: undefined, stakingScriptHash: '14c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f1124', address: 'addr1qxq0nckg3ekgzuqg7w5p9mvgnd9ym28qh5grlph8xd2z92sj922xhxkn6twlq2wn4q50q352annk3903tj00h45mgfmsl3s9zt', + derivationType: undefined, + } + assert.deepStrictEqual(parsedArgs, expectedResult) + }) + + it('Should parse address show command with a derivation type set', () => { + const args = pad([ + 'shelley', + 'address', + 'show', + '--payment-path', + '1852H/1815H/0H/0/0', + '--staking-script-hash', + '14c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f1124', + '--address-file', + prefix('payment.addr'), + '--derivation-type', + 'ICARUS', + ]) + const { parsedArgs } = parse(args) + const expectedResult = { + command: CommandType.SHOW_ADDRESS, + paymentPath: [2147485500, 2147485463, 2147483648, 0, 0], + paymentScriptHash: undefined, + stakingPath: undefined, + stakingScriptHash: '14c16d7f43243bd81478e68b9db53a8528fd4fb1078d58d54a7f1124', + address: 'addr1qxq0nckg3ekgzuqg7w5p9mvgnd9ym28qh5grlph8xd2z92sj922xhxkn6twlq2wn4q50q352annk3903tj00h45mgfmsl3s9zt', + derivationType: DerivationType.ICARUS, } assert.deepStrictEqual(parsedArgs, expectedResult) }) @@ -51,6 +84,7 @@ describe('Command parser', () => { paths: [[2147485500, 2147485463, 2147483648, 0, 0]], hwSigningFiles: ['test/unit/commandParser/res/payment.hwsfile'], verificationKeyFiles: ['test/unit/commandParser/res/payment.vkey'], + derivationType: undefined, } assert.deepStrictEqual(parsedArgs, expectedResult) }) @@ -111,6 +145,7 @@ describe('Command parser', () => { ], outFile: 'test/unit/commandParser/res/tx.signed', changeOutputKeyFileData: [], + derivationType: undefined, } assert.deepStrictEqual(parsedArgs, expectedResult) }) @@ -147,6 +182,7 @@ describe('Command parser', () => { }], outFiles: ['test/unit/commandParser/res/witness.out'], changeOutputKeyFileData: [], + derivationType: undefined, } assert.deepStrictEqual(parsedArgs, expectedResult) }) @@ -188,6 +224,7 @@ describe('Command parser', () => { path: [2147485500, 2147485463, 2147483648, 0, 0], cborXPubKeyHex: '5880e0d9c2e5b...7277e7db', }], + derivationType: undefined, } assert.deepStrictEqual(parsedArgs, expectedResult) }) @@ -238,6 +275,7 @@ describe('Command parser', () => { outFile: 'voting_registration.cbor', rewardAddress: 'adr_test1qq2vzmtlgvjrhkq50rngh8d482zj3l20kyrc6kx4ffl3zfqayfawlf9hwv2fzuygt2km5v92kvf8e3s3mk7ynxw77cwq2glhm4', votePublicKey: '3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7', + derivationType: undefined, } assert.deepStrictEqual(parsedArgs, expectedResult) }) @@ -307,6 +345,7 @@ describe('Command parser', () => { ], }, hwSigningFileData: undefined, + derivationType: undefined, } assert.deepStrictEqual(parsedArgs, expectedResult) }) diff --git a/yarn.lock b/yarn.lock index 8ed97066..cf9b21b6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -911,10 +911,10 @@ cardano-crypto.js@^5.3.6-rc.6: borc "^2.1.1" pbkdf2 "^3.0.17" -cardano-hw-interop-lib@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/cardano-hw-interop-lib/-/cardano-hw-interop-lib-1.1.0.tgz#819dacda60c6ffaadeafb36f0331f10f821e6686" - integrity sha512-ltwVMmTNfPudYioXvmnlhPuTEVbSF/AfXScHS1S5p1580xYikEzmVeCyj6U51E9/wBFLUhyGcpPC7Yvf5+8LCQ== +cardano-hw-interop-lib@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/cardano-hw-interop-lib/-/cardano-hw-interop-lib-1.1.1.tgz#b70d4c73374990deda79c3228bdc184dc3dd1c81" + integrity sha512-Qqnka/3J2CS6uk3unjyB3thYpYO/3Mqm8doOwRIrOcyWZMekdtaILxdvrusJblaJ4L+jaxNt/nxdFB4GNMoHnQ== dependencies: blake2b "^2.1.4" cbor "^8.1.0"