input-output-hk / nami

Nami Wallet is a browser based wallet extension to interact with the Cardano blockchain. Support requests: https://iohk.zendesk.com/hc/en-us/requests/new
https://namiwallet.io
Apache License 2.0
374 stars 168 forks source link

Tx chaining blocked by the way signing of collateral is handled (slight issue only) #856

Open lemmon-714 opened 1 year ago

lemmon-714 commented 1 year ago

Am currently working on using tx-chaining with lucid and nami, which works, up until the specific scenario where I am trying to round-trip over a contract, and only have one utxo carrying enough collateral (which is being consumed in the first tx and therefore not available for collateral in the second one).

What I do to fix this is - for now - keep track of my own changes to the utxo-set which are still pending in the mempool, then modify the getUtxoCore-function in lucid to include that (injecting it from my webapp-code, not actually editing lucid yet). However, once I get to the signing step, the popup says "Signature not possible", which I traced to this function:

export const getSpecificUtxo = async (txHash, txId) => {
  const result = await blockfrostRequest(`/txs/${txHash}/utxos`);
  if (!result || result.error) return null;
  return result.outputs[txId];
};

, issue being that this endpoint does not include the mempool.

This is only a slight issue because if the user has enough txes hanging around, it will most likely work, and if not, it's simple to change that within 1 extra block. But one can imagine situations where that might become ugly, once people start assuming "tx chaining just works" and going wild with it.

An even better solution might be to simply talk to blockfrost instead of bringing it up here, which I will do next. Justifying it still with @alessandrokonrad 's intentions to add it to lucid at some point, maybe this includes relevant info for that.

lemmon-714 commented 1 year ago

Correction: This does not only affect collateral-utxos but of course all user-owned utxos that one wants to chain.