diff --git a/packages/core/src/Cardano/util/isScriptAddress.ts b/packages/core/src/Cardano/util/isScriptAddress.ts index bda9daaac8f..6244032b4fa 100644 --- a/packages/core/src/Cardano/util/isScriptAddress.ts +++ b/packages/core/src/Cardano/util/isScriptAddress.ts @@ -1,6 +1,10 @@ import { Address, CredentialType, PaymentAddress } from '../Address'; export const isScriptAddress = (address: PaymentAddress): boolean => { + if (!Address.isValidBech32(address)) { + return false; + } + const baseAddress = Address.fromBech32(address).asBase(); const paymentCredential = baseAddress?.getPaymentCredential(); const stakeCredential = baseAddress?.getStakeCredential(); diff --git a/packages/hardware-ledger/src/transformers/txOut.ts b/packages/hardware-ledger/src/transformers/txOut.ts index 27d9aa6414a..cff946f9ff9 100644 --- a/packages/hardware-ledger/src/transformers/txOut.ts +++ b/packages/hardware-ledger/src/transformers/txOut.ts @@ -40,9 +40,15 @@ const toDestination: Transform { }); }); + it('can map a simple txOut to Byron era address', async () => { + const out = toTxOut({ index: 0, isCollateral: false, txOut: byronEraTxOut }, CONTEXT_WITHOUT_KNOWN_ADDRESSES); + + expect(out).toEqual({ + amount: 20_000_000n, + datumHashHex: null, + destination: { + params: { + addressHex: '82d818582183581c54473376651c3d50b7a85055bb2395751e2db78bcb65410e1624989ca0001a73156e8e' + }, + type: Ledger.TxOutputDestinationType.THIRD_PARTY + }, + format: Ledger.TxOutputFormat.ARRAY_LEGACY, + tokenBundle: null + }); + }); + it('can map a simple txOut to owned address', async () => { const out = toTxOut({ index: 0, isCollateral: false, txOut: txOutToOwnedAddress }, CONTEXT_WITH_KNOWN_ADDRESSES); diff --git a/packages/wallet/test/hardware/ledger/LedgerKeyAgent.test.ts b/packages/wallet/test/hardware/ledger/LedgerKeyAgent.test.ts index a409833548e..738cb12cea6 100644 --- a/packages/wallet/test/hardware/ledger/LedgerKeyAgent.test.ts +++ b/packages/wallet/test/hardware/ledger/LedgerKeyAgent.test.ts @@ -183,6 +183,24 @@ describe('LedgerKeyAgent', () => { } } ]; + + const byronOutputs = [ + { + address: Cardano.PaymentAddress('FHnt4NL7yPXtsWVUqTv1Tr1ZSarFUYHS2DFLRUJwtqx8RnpZ8s8JefSYTekFcSF'), + value: { coins: 11_111_111n } + } + ]; + + const byronProps: InitializeTxProps = { + options: { + validityInterval: { + invalidBefore: Cardano.Slot(1), + invalidHereafter: Cardano.Slot(999_999_999) + } + }, + outputs: new Set(byronOutputs) + }; + const props: InitializeTxProps = { options: { validityInterval: { @@ -233,6 +251,13 @@ describe('LedgerKeyAgent', () => { expect(signatures.size).toBe(2); }); + it('successfully signs a transaction with byron address output', async () => { + const { + witness: { signatures } + } = await wallet.finalizeTx({ tx: await wallet.initializeTx(byronProps) }); + expect(signatures.size).toBe(2); + }); + it('successfully signs ADA handle mint transaction', async () => { const cbor = '84a500818258207aa1264bcd0c06f34a49ed1dd7307a2bdec5a97bdeb546498759ad5b8ed42fd5010182a200583930195bde3deacb613b7e9eb6280b14db4e353e475e96d19f3f7a5e2d66195bde3deacb613b7e9eb6280b14db4e353e475e96d19f3f7a5e2d66011a00e4e1c0a2005839003d3246dc0c50ab3c74a8ffdd8068313ff99d341c461a8fe31f416d0a8fba06d60d71edc077cc5ebcb8ff82137afbce68df98271909332348011b000000025106a838021a00029309031a04a07bc6081a04a07a40a0f5f6';