This commit is contained in:
Felix
2024-06-07 08:26:45 +00:00
parent 672006fe63
commit d0e1c23773
2 changed files with 12 additions and 2 deletions

View File

@ -46,6 +46,15 @@ fn bytes_to_base91(input: &[u8; 32]) -> String {
encoded_robohash encoded_robohash
} }
impl OfferType {
pub fn value(&self) -> u64 {
match self {
OfferType::Buy(value) => *value,
OfferType::Sell(value) => *value,
}
}
}
impl CliSettings { impl CliSettings {
fn get_user_input(prompt: &str) -> String { fn get_user_input(prompt: &str) -> String {
let mut buffer = String::new(); let mut buffer = String::new();

View File

@ -1,5 +1,6 @@
use anyhow::Result; use anyhow::Result;
use bdk::{database::MemoryDatabase, wallet::coin_selection::BranchAndBoundCoinSelection, Wallet}; use bdk::{database::MemoryDatabase, wallet::coin_selection::BranchAndBoundCoinSelection, Wallet};
use serde::de::value;
use crate::communication::api::OfferCreationResponse; use crate::communication::api::OfferCreationResponse;
use crate::wallet::TraderSettings; use crate::wallet::TraderSettings;
@ -23,8 +24,8 @@ impl Bond {
let (psbt, details) = { let (psbt, details) = {
let mut builder = wallet.build_tx(); let mut builder = wallet.build_tx();
builder builder
.coin_selection(BranchAndBoundCoinSelection::new(10000)) .coin_selection(BranchAndBoundCoinSelection::new(trader_input.trade_type.value()))
.add_recipient(send_to.script_pubkey(), 50_000) .add_recipient(bond_target.locking_address, bond_target.locking_amount)
.enable_rbf() .enable_rbf()
.do_not_spend_change() .do_not_spend_change()
.fee_rate(FeeRate::from_sat_per_vb(5.0)); .fee_rate(FeeRate::from_sat_per_vb(5.0));