New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add utxos
option to Tx.complete
method
#101
Conversation
Is your goal that these UTxOs are definitely used in the Tx or just in the coin selection, but can still be dropped by it? |
In my case, I don't want coin selection dropping any of the specified UTxOs which is why I add them as inputs before passing them to coin selection. Users can still go either route. Simply pass the UTxO set to coin selection without specifying inputs if you don't mind UTxOs getting dropped. |
Okay good. Then you can simply do: let tx = await lucid.newTx().collectFrom([utxo])...
|
Awesome, there's just the issue now of the UTxO set that's passed to coin selection... In the below example, coin selection still adds additional UTxOs (which I do not want to consume)...in the below tx I add 1 input and 1 output...when I look at the completed tx, coin selection has added an additional 3 inputs that are unnecessary, hence why I'd like the option to pass a specific UTxO set directly to coin selection to prevent this from happening. // Fetch wallet UTxOs
const utxos = await lucid.wallet.getUtxos();
// Add 1 input and 1 output, complete tx with coin selection
const tx = await lucid.newTx()
.collectFrom([utxos[0]])
.payToAddress(receiver, { lovelace: 2000000n })
.complete({ coinSelection: true })
// Read completed Tx...
console.log(tx.txComplete.to_js_value());
/**
inputs: [
{
transaction_id: '2806f9e18fc0e12cc5fa43498e953329e96111e1a4394c209d2853cbbad10c27',
index: '0'
},
{
transaction_id: 'edfdb3849e0d9ebc38f55a5cb02ffeaa2f21ea097956a3b187c2ab4f3be74d0a',
index: '0'
},
{
transaction_id: '3ecf6f2142dcd8acfb25b67463030e35994649ef9e672dba7c60f13581aaa22a',
index: '0'
},
{
transaction_id: '2f94eb98fab223ada8a2de0225d23e7f54a4ce0576629dd79ed755d224072f9b',
index: '0'
}
] */ Another solution would be for Bottom line - for my use case, I don't want coin selection adding additional inputs. This may be a niche use case which doesn't require native support, I'll let you make that call - in that case, I will just hack around it. |
I'm not sure if I totally got it, but if you don't want the coin selection to ever run and you know upfront already what UTxOs you want to consume, then simply set |
Ah, that seems to work - thanks so much man. |
Functionality is available |
I'm still learning the ins and outs of this lib and the serialization lib so this may not be necessary...
I'd like to control the utxo set that is passed to the coin selection algorithm during
Tx.complete()
. Currently, if coinSelection is enabled duringTx.complete()
it will fetch the entire utxo set from the wallet by default. I'd like the option to pass specific a specific utxo set instead.I imagine there is another way to do this - but this approach does work. I'll note that support for "single utxo" transactions would need to be added as well, the method below requires at least 2 utxos to work (this is because the add_inputs_from method is being used).