Skip to content

Commit

Permalink
fix: add btc change utxo
Browse files Browse the repository at this point in the history
  • Loading branch information
crisdut committed Aug 2, 2023
1 parent 94e009f commit 9df58b2
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/rgb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,21 +811,27 @@ pub async fn full_transfer_asset(
// Get All Bitcoin UTXOs
let mut bitcoin_inputs = vec![];
if let PsbtFeeRequest::Value(fee_amount) = request.fee {
let bitcoin_index = 0;
let bitcoin_indexes = [0, 1];
let mut wallet = wallet.unwrap();
prefetch_resolver_utxos(bitcoin_index, &mut wallet, &mut resolver).await;
prefetch_resolver_utxo_status(bitcoin_index, &mut wallet, &mut resolver).await;

sync_wallet(bitcoin_index, &mut wallet, &mut resolver);

let unspent_utxos = next_utxos(0, wallet, &mut resolver).map_err(|_| {
TransferError::Retrive(
"Esplora".to_string(),
"Retrieve Unspent UTXO unavaliable".to_string(),
)
})?;
let mut all_unspents = vec![];
for bitcoin_index in bitcoin_indexes {
prefetch_resolver_utxos(bitcoin_index, &mut wallet, &mut resolver).await;
prefetch_resolver_utxo_status(bitcoin_index, &mut wallet, &mut resolver).await;

sync_wallet(bitcoin_index, &mut wallet, &mut resolver);

let mut unspent_utxos =
next_utxos(0, wallet.clone(), &mut resolver).map_err(|_| {
TransferError::Retrive(
"Esplora".to_string(),
"Retrieve Unspent UTXO unavaliable".to_string(),
)
})?;

all_unspents.append(&mut unspent_utxos);
}

for utxo in unspent_utxos {
for utxo in all_unspents {
let TerminalPath { app, index } = utxo.derivation.terminal;
let btc_input = PsbtInputRequest {
descriptor: universal_desc.clone(),
Expand Down

0 comments on commit 9df58b2

Please sign in to comment.