Skip to content

Commit

Permalink
fix: fix utxo selection
Browse files Browse the repository at this point in the history
  • Loading branch information
HinsonSIDAN committed Apr 14, 2024
1 parent 26c7cc8 commit e6bb2bc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sidan-csl-rs"
version = "0.3.5"
version = "0.3.5-beta1"
edition = "2021"
license = "MIT"
description = "Wrapper around the cardano-serialization-lib for easier transaction building, heavily inspired by cardano-cli APIs"
Expand Down
31 changes: 21 additions & 10 deletions rust/src/builder/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,10 @@ impl IMeshTxBuilderCore for MeshTxBuilder {
if customized_tx.is_some() {
self.mesh_tx_builder_body = customized_tx.unwrap();
} else {
if self.tx_in_item.is_some() {
self.queue_input();
}
self.queue_all_last_item();
if !self.extra_inputs.is_empty() {
self.add_utxos_from(self.extra_inputs.clone(), self.selection_threshold);
}
self.queue_all_last_item();
}
self.serialize_tx_body();
self.mesh_csl.tx_builder = build_tx_builder();
Expand Down Expand Up @@ -637,12 +634,26 @@ impl IMeshTxBuilderCore for MeshTxBuilder {
let selected_inputs = select_utxos(extra_inputs, required_assets, threshold.to_string());

for input in selected_inputs {
self.tx_in(
&input.input.tx_hash,
input.input.output_index,
input.output.amount,
&input.output.address,
);
self.mesh_csl.add_tx_in(PubKeyTxIn {
type_: "PubKey".to_string(),
tx_in: TxInParameter {
tx_hash: input.input.tx_hash.clone(),
tx_index: input.input.output_index,
amount: Some(input.output.amount.clone()),
address: Some(input.output.address.clone()),
},
});
self.mesh_tx_builder_body
.inputs
.push(TxIn::PubKeyTxIn(PubKeyTxIn {
type_: "PubKey".to_string(),
tx_in: TxInParameter {
tx_hash: input.input.tx_hash,
tx_index: input.input.output_index,
amount: Some(input.output.amount),
address: Some(input.output.address),
},
}));
}
}

Expand Down

0 comments on commit e6bb2bc

Please sign in to comment.