Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/hardware-ledger/src/LedgerKeyAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ export class LedgerKeyAgent extends KeyAgentBase {
* Ledger has certain limitations due to which it cannot sign arbitrary combination of all transaction features.
* The mode specifies which use-case the user want to use and triggers additional validation on `tx` field.
*/
// eslint-disable-next-line complexity
static getSigningMode(tx: Transaction): TransactionSigningMode {
if (tx.certificates) {
for (const cert of tx.certificates) {
Expand All @@ -726,7 +727,11 @@ export class LedgerKeyAgent extends KeyAgentBase {
* VotingProcedures: We are currently supporting only keyHash and scriptHash voter types in voting procedures.
* To sign tx with keyHash and scriptHash voter type we have to use PLUTUS_TRANSACTION signing mode
*/
if (tx.collateralInputs || LedgerKeyAgent.isKeyHashOrScriptHashVoter(tx.votingProcedures)) {
if (
tx.collateralInputs ||
LedgerKeyAgent.isKeyHashOrScriptHashVoter(tx.votingProcedures) ||
(tx.referenceInputs && tx.referenceInputs.length > 0)
) {
return TransactionSigningMode.PLUTUS_TRANSACTION;
}

Expand Down
43 changes: 43 additions & 0 deletions packages/hardware-ledger/test/LedgerKeyAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,49 @@ describe('LedgerKeyAgent', () => {
expect(LedgerKeyAgent.getSigningMode(tx)).toEqual(Ledger.TransactionSigningMode.PLUTUS_TRANSACTION);
});

it('can detect plutus transaction signing mode if there is a reference input', async () => {
const tx: Ledger.Transaction = {
fee: 10n,
includeNetworkId: false,
inputs: [
{
outputIndex: 0,
path: [util.harden(CardanoKeyConst.PURPOSE), util.harden(CardanoKeyConst.COIN_TYPE), util.harden(0), 1, 0],
txHashHex: '0f3abbc8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56fe0e78f19d9d5'
}
],
network: {
networkId: Ledger.Networks.Testnet.networkId,
protocolMagic: 999
},
outputs: [
{
amount: 10n,
datumHashHex: '0f3abbc8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56fe0e78f19d9d5',
destination: {
params: {
addressHex:
'009493315cd92eb5d8c4304e67b7e16ae36d61d34502694657811a2c8e32c728d3861e164cab28cb8f006448139c8f1740ffb8e7aa9e5232dc'
},
type: Ledger.TxOutputDestinationType.THIRD_PARTY
},
format: Ledger.TxOutputFormat.ARRAY_LEGACY
}
],
referenceInputs: [
{
outputIndex: 0,
path: [util.harden(CardanoKeyConst.PURPOSE), util.harden(CardanoKeyConst.COIN_TYPE), util.harden(0), 1, 0],
txHashHex: '0f3abbc8fc19c2e61bab6059bf8a466e6e754833a08a62a6c56fe0e78f19d9d5'
}
],
ttl: 1000,
validityIntervalStart: 100
};

expect(LedgerKeyAgent.getSigningMode(tx)).toEqual(Ledger.TransactionSigningMode.PLUTUS_TRANSACTION);
});

it('can detect multisig transaction signing mode', async () => {
const tx: Ledger.Transaction = {
certificates: [
Expand Down
Loading