butaneprotocol / blaze-cardano

🔥 The hottest transaction building library for Cardano
https://blaze.butane.dev
Apache License 2.0
58 stars 22 forks source link

Tx Builder wont select any inputs if withdrawal amount is enough to balance the transaction #186

Open AngelCastilloB opened 2 months ago

AngelCastilloB commented 2 months ago

Hi, I am building a transaction with the sole purpose of withdrawing rewards:

    const blaze = await getBlazeProvider();
    const tx = blaze.newTransaction();

    // Assume there is an assert to make sure there are rewards.
    tx.addWithdrawal(RewardAccount(account.rewardAddr), delegation.rewards);

    tx.setValidUntil(protocolParameters.slot + TX.invalid_hereafter);

    const changeAddress = Address.fromBech32(account.paymentAddr);

    tx.setChangeAddress(changeAddress);

    const result = await tx.complete();

This results in an error if rewards are enough to cover the fees + minUtxoValue for change output as the transaction doesn't have any inputs. It has an easy fix/workaround (manually specifying an input to be spent etc), but I would expect the tx builder to sort this kind of things for me automatically. I.E if no inputs are required to balance outputs + fee (and no extra inputs are manually specified), pick one input anyways either randomly or following some simple preference heuristic