cardano-serialization-lib icon indicating copy to clipboard operation
cardano-serialization-lib copied to clipboard

The fees of transactions from multi-sig scripts are incorrect

Open siegfried opened this issue 3 years ago • 3 comments

add_change_if_needed does not calculate the correct fee for transactions sent from multi-sig addresses. Here is an example:

https://cardano-multi-sig-app-testnet.vercel.app/transactions/hKMAgYJYIG6zIwOrIEHX%2Fh05BTO4Nbiul6Mi0acMA7%2FDtzTyGlz6AAGCglg5AOQS%2Buq87qmsRuz8yOT2uBUUMfIJdTZXihGvyK26Uct0D1jECr5YEqIm8eWO56Vsliz7m98Lf%2BFmGgBMS0CCWDkwAzhDIFjpiFvESzSX6Dy%2Fj975rmF1Wi9NpzNBbgM4QyBY6YhbxEs0l%2Bg8v4%2Fe%2Ba5hdVovTaczQW4aAqwmfwIaAAJ%2BwaEBgYIBgoIAWBx%2BTl8kD6qxHrI2g6e3OlNMVjjSxmvlNL4d2k2lggBYHOQS%2Buq87qmsRuz8yOT2uBUUMfIJdTZXihGvyK319g%3D%3D

Here is the error message from the wallet after I got the two signed and clicked Submit Transaction.

{code: 2, info: 'Wallet could not send the tx.', message: '"transaction submit error ShelleyTxValidationError…FeeTooSmallUTxO (Coin 175313) (Coin 163521))))])"'}

Here is the source code of building transaction:

https://github.com/siegfried/cardano-multi-sig-app/blob/14058e0fd1982f074932bf5d83392f96bc289d88/components/transaction.tsx#L275

I assume the reason is that the native script is also required by the calculation? How am I supposed to set that in TransactionBuilder?

This is the page of creating transaction for the multi-sig address:

https://cardano-multi-sig-app-testnet.vercel.app/treasuries/ggGCggBYHH5OXyQPqrEesjaDp7c6U0xWONLGa%2BU0vh3aTaWCAFgc5BL66rzuqaxG7PzI5Pa4FRQx8gl1NleKEa%2FIrQ%3D%3D

siegfried avatar Mar 10 '22 08:03 siegfried

I think the way to add native script to the builder can be improved. To count the verification keys, the native script is required by the TransactionBuilder, but the only available way ATM to include a native script is to mint some assets. The way to add native script can be more general so we can spend coins in a native script.

siegfried avatar Mar 11 '22 06:03 siegfried

Please review the PR. @vsubhuman

siegfried avatar Mar 11 '22 08:03 siegfried

I know it sounds a bit weird, but you can add before the add_change_if_needed the function set_mint with the scripts with an empty Mint object. That way the scripts are getting calculated.

const mint = Mint.new(); const scripts = NativeScripts.new(); scripts.add(multisig.script); txBuilder.set_mint(mint, scripts);

tqueri avatar Apr 12 '22 03:04 tqueri