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
8 changes: 6 additions & 2 deletions modules/sdk-coin-starknet/src/starknet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ export class Starknet extends BaseCoin {
async verifyTransaction(params: VerifyTransactionOptions): Promise<boolean> {
const { txParams, txPrebuild } = params;
const txHex = txPrebuild?.txHex;
if (!txHex) {
throw new Error('txHex is required');

// 0x-prefixed txHex means this is the Starknet transaction hash (signableHex), not the
// full serialized transaction. Recipient verification already happened in prebuildAndSignTransaction
// using serializedTxHex — nothing to verify from a hash alone.
if (!txHex || txHex.startsWith('0x')) {
return true;
}

const explainedTx = await this.explainTransaction({ transactionHex: txHex });
Expand Down
33 changes: 33 additions & 0 deletions modules/sdk-coin-starknet/test/unit/starknet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,37 @@ describe('Starknet', function () {
kp1.pub.should.not.equal(kp2.pub);
});
});

describe('verifyTransaction', () => {
it('should return true when txHex is a 0x-prefixed signableHex (deploy_account, no recipients)', async function () {
// During TSS ECDSA signing, sdk-core passes signableHex (0x-prefixed transaction hash)
// as txHex. It cannot be decoded as internal JSON hex, so verification must short-circuit.
const result = await basecoin.verifyTransaction({
txParams: { recipients: [] },
txPrebuild: { txHex: '0xdeadbeefcafe1234567890abcdef' },
wallet: {} as any,
});
result.should.equal(true);
});

it('should return true when txHex is a 0x-prefixed signableHex (transfer with recipients)', async function () {
// Same signing path for transfers — signableHex is 0x-prefixed, full verification
// is already done in prebuildAndSignTransaction with serializedTxHex.
const result = await basecoin.verifyTransaction({
txParams: { recipients: [{ address: '0xabc', amount: '1000' }] },
txPrebuild: { txHex: '0xdeadbeefcafe1234567890abcdef' },
wallet: {} as any,
});
result.should.equal(true);
});

it('should return true when txHex is absent', async function () {
const result = await basecoin.verifyTransaction({
txParams: { recipients: [] },
txPrebuild: {},
wallet: {} as any,
});
result.should.equal(true);
});
});
});
Loading