From 89c63049e9eb8672a2dc851104fabb56f13acfdb Mon Sep 17 00:00:00 2001 From: Micah Kendall Date: Tue, 16 Jan 2024 22:11:48 +1100 Subject: [PATCH] ada input should not be used in utxo balancing --- src/translucent/tx.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/translucent/tx.ts b/src/translucent/tx.ts index 45f425e..3403306 100644 --- a/src/translucent/tx.ts +++ b/src/translucent/tx.ts @@ -839,11 +839,7 @@ export class Tx { const utxoAdaSearch = [] let i = 0; - for (const utxo of walletUTxOs) { - this.txBuilder.add_utxo( - C.SingleInputBuilder.new(utxo.input(), utxo.output()).payment_key(), - ); - + for (const utxo of walletUTxOs) { const minAda = C.min_ada_required(utxo.output(), C.BigNum.from_str((await this.translucent.provider.getProtocolParameters()).coinsPerUtxoByte.toString())) utxoAdaSearch.push([i, parseFloat(utxo.output().amount().coin().to_str())-parseFloat(minAda.to_str())]) i+=1; @@ -853,6 +849,13 @@ export class Tx { const adaInput = walletUTxOs[utxoAdaSearch[utxoAdaSearch.length-1][0]] this.txBuilder.add_input(C.SingleInputBuilder.new(adaInput.input(), adaInput.output()).payment_key()) + for (const utxo of walletUTxOs) { + if (utxo.to_bytes()!=adaInput.to_bytes()){ + this.txBuilder.add_utxo( + C.SingleInputBuilder.new(utxo.input(), utxo.output()).payment_key(), + ); + }; + }; this.txBuilder.select_utxos(2); {