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
4 changes: 4 additions & 0 deletions packages/sdk/src/mintlayer-connect-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2449,6 +2449,10 @@ class Client {
})) : [];

const utxos: UtxoEntry[] = data_utxos.filter((item: UtxoEntry) => {
if (!item.utxo) {
return false;
}

// filter out UTXO with type htlc, they have to be added manually
if (item.utxo.type === 'Htlc') {
return false;
Expand Down
34 changes: 34 additions & 0 deletions packages/sdk/tests/transfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,40 @@ test('fails transfer if not enough utxo', async () => {
})).rejects.toThrow('Not enough coin UTXOs');
});

test('transfer ignores account entries without utxo', async () => {
fetchMock.mockIf('https://mojito-api.mintlayer.org/mintlayer/testnet/batch', async () => {
return {
body: JSON.stringify({
results: [[
{
input: {
input_type: 'Account',
account_type: 'DelegationBalance',
amount: {
atoms: '100000000000',
decimal: '1',
},
delegation_id: 'tde1q9gndm5e2d6w33xtm26gppaj29qh52gnxwucnqlq',
nonce: 1,
},
},
...utxos,
]],
}),
};
});

const client = await Client.create({ network: 'testnet', autoRestore: false });
await client.connect();

const result = await client.transfer({
to: 'tmt1q9mfg7d6ul2nt5yhmm7l7r6wwyqkd822rymr83uc',
amount: 10,
});

expect(result).toBe('signed-transaction');
});

test('transfer transfer fee precise', async () => {
const client = await Client.create({ network: 'testnet', autoRestore: false });

Expand Down
Loading