Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions liana-gui/src/app/state/psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl PsbtState {
self.modal = Some(PsbtModal::Delete(DeleteModal::default()));
}
Message::View(view::Message::Spend(view::SpendTxMessage::SendPayjoin)) => {
let modal = SendPayjoinModal::new();
let modal = SendPayjoinModal;
let cmd = modal.load(daemon);
self.modal = Some(PsbtModal::SendPayjoin(modal));
return cmd;
Expand Down Expand Up @@ -331,15 +331,7 @@ impl PsbtState {
}

#[derive(Default)]
pub struct SendPayjoinModal {
_error: Option<Error>,
}

impl SendPayjoinModal {
pub fn new() -> Self {
Self { _error: None }
}
}
pub struct SendPayjoinModal;

impl Modal for SendPayjoinModal {
fn view<'a>(&'a self, content: Element<'a, view::Message>) -> Element<'a, view::Message> {
Expand Down
3 changes: 0 additions & 3 deletions liana-gui/src/app/state/spend/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ impl Step for DefineSpend {
}

view::CreateSpendMessage::Bip21Edited(i, bip21) => {
log::info!("Bip21Edited: {}", bip21);
if let Some(recipient) = self.recipients.get_mut(i) {
recipient.bip21.value = bip21.clone();
if let Ok(uri) = Uri::try_from(bip21.as_str()) {
Expand All @@ -620,7 +619,6 @@ impl Step for DefineSpend {
);
}
if let Some(amount) = uri.amount {
log::info!("Amount: {}", amount);
recipient.amount.value =
amount.to_string_in(Denomination::Bitcoin);
recipient.update(
Expand Down Expand Up @@ -948,7 +946,6 @@ impl Recipient {
self.label.value = label;
}
view::CreateSpendMessage::Bip21Edited(_, bip21) => {
log::info!("bip21: {}", bip21);
self.bip21.value = bip21;
}
_ => {}
Expand Down
2 changes: 1 addition & 1 deletion liana-gui/src/app/view/psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ pub fn signatures<'a>(
.push(p1_bold("Status"))
.push(icon::circle_check_icon().style(theme::text::payjoin))
.push(
text("Payjoin Proposal Ready")
text("Payjoin Proposal Ready For Signing")
.bold()
.style(theme::text::payjoin),
),
Expand Down
1 change: 0 additions & 1 deletion liana/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ impl HotSigner {
&mut psbt.inputs[i],
i,
)?;
log::info!("Signed input at {}", i);
} else {
self.sign_taproot(
secp,
Expand Down
1 change: 0 additions & 1 deletion lianad/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,6 @@ impl DaemonControl {
// effort basis.
let txid = tx.compute_txid();
if let Some(mut db_psbt) = db_conn.spend_tx(&txid) {
info!("Updating spend: {:?}", txid);
let db_tx = db_psbt.unsigned_tx.clone();
for i in 0..db_tx.input.len() {
if tx
Expand Down
24 changes: 9 additions & 15 deletions lianad/src/payjoin/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,24 @@ impl SessionId {
}

#[derive(Debug)]
pub enum PersisterError {
pub(crate) enum PersisterError {
Serialize(serde_json::Error),
Deserialize(serde_json::Error),
NotFound(String),
}

impl Display for PersisterError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
PersisterError::Serialize(e) => write!(f, "Serialization failed: {e}"),
PersisterError::Deserialize(e) => write!(f, "Deserialization failed: {e}"),
PersisterError::NotFound(key) => write!(f, "Key not found: {key}"),
}
}
}

impl std::error::Error for PersisterError {}

#[derive(Clone)]
pub struct ReceiverPersister {
pub(crate) struct ReceiverPersister {
db: Arc<dyn DatabaseInterface>,
pub session_id: SessionId,
}
Expand Down Expand Up @@ -66,7 +64,6 @@ impl SessionPersister for ReceiverPersister {
event: &Self::SessionEvent,
) -> std::result::Result<(), Self::InternalStorageError> {
let mut db_conn = self.db.connection();
// serilize event
let event_ser = serde_json::to_vec(event).map_err(PersisterError::Serialize)?;
db_conn.save_receiver_session_event(&self.session_id, event_ser);
Ok(())
Expand All @@ -78,11 +75,10 @@ impl SessionPersister for ReceiverPersister {
{
let mut db_conn = self.db.connection();
let events = db_conn.load_receiver_session_events(&self.session_id);
let deserialized_events: Result<Vec<_>, _> = events
let iter = events
.into_iter()
.map(|event| serde_json::from_slice(&event).map_err(PersisterError::Deserialize))
.collect();
Ok(Box::new(deserialized_events?.into_iter()))
.map(|event| serde_json::from_slice(&event).expect("Event to be serialized correctly"));
Ok(Box::new(iter))
}

fn close(&self) -> std::result::Result<(), Self::InternalStorageError> {
Expand All @@ -93,7 +89,7 @@ impl SessionPersister for ReceiverPersister {
}

#[derive(Clone)]
pub struct SenderPersister {
pub(crate) struct SenderPersister {
db: Arc<dyn DatabaseInterface>,
pub session_id: SessionId,
}
Expand Down Expand Up @@ -122,7 +118,6 @@ impl SessionPersister for SenderPersister {
event: &Self::SessionEvent,
) -> std::result::Result<(), Self::InternalStorageError> {
let mut db_conn = self.db.connection();
// serilize event
let event_ser = serde_json::to_vec(event).map_err(PersisterError::Serialize)?;
db_conn.save_sender_session_event(&self.session_id, event_ser);
Ok(())
Expand All @@ -134,11 +129,10 @@ impl SessionPersister for SenderPersister {
{
let mut db_conn = self.db.connection();
let events = db_conn.get_all_sender_session_events(&self.session_id);
let deserialized_events: Result<Vec<_>, _> = events
let iter = events
.into_iter()
.map(|event| serde_json::from_slice(&event).map_err(PersisterError::Deserialize))
.collect();
Ok(Box::new(deserialized_events?.into_iter()))
.map(|event| serde_json::from_slice(&event).expect("Event to be serialized correctly"));
Ok(Box::new(iter))
}

fn close(&self) -> std::result::Result<(), Self::InternalStorageError> {
Expand Down
6 changes: 4 additions & 2 deletions lianad/src/payjoin/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ pub(crate) fn post_request(
.send()
}

/// Optimistically attempt to create witness for all inputs.
/// This method will not fail even if some inputs are not finalized or include invalid partial signatures.
pub(crate) fn finalize_psbt(psbt: &mut Psbt, secp: &secp256k1::Secp256k1<secp256k1::VerifyOnly>) {
let mut witness_utxo_to_clean = vec![];
let mut inputs_to_finalize = vec![];
Expand Down Expand Up @@ -117,8 +119,8 @@ pub(crate) fn finalize_psbt(psbt: &mut Psbt, secp: &secp256k1::Secp256k1<secp256

for index in &inputs_to_finalize {
match psbt.finalize_inp_mut(secp, *index) {
Ok(_) => log::info!("[Payjoin] Finalizing input at: {}", index),
Err(e) => log::warn!("[Payjoin] Failed to finalize input at: {} | {}", index, e),
Ok(_) => log::info!("Finalizing input at: {}", index),
Err(e) => log::warn!("Failed to finalize input at: {} | {}", index, e),
}
}

Expand Down
8 changes: 4 additions & 4 deletions lianad/src/payjoin/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod db;
pub mod helpers;
pub mod receiver;
pub mod sender;
pub(crate) mod db;
pub(crate) mod helpers;
pub(crate) mod receiver;
pub(crate) mod sender;
pub mod types;
2 changes: 1 addition & 1 deletion lianad/src/payjoin/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ fn process_receiver_session(
Ok(())
}

pub fn payjoin_receiver_check(
pub(crate) fn payjoin_receiver_check(
db: &sync::Arc<sync::Mutex<dyn DatabaseInterface>>,
bit: &mut sync::Arc<sync::Mutex<dyn BitcoinInterface>>,
desc: &descriptors::LianaDescriptor,
Expand Down
2 changes: 1 addition & 1 deletion lianad/src/payjoin/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn process_sender_session(
}
}

pub fn payjoin_sender_check(db: &sync::Arc<sync::Mutex<dyn DatabaseInterface>>) {
pub(crate) fn payjoin_sender_check(db: &sync::Arc<sync::Mutex<dyn DatabaseInterface>>) {
let mut db_conn = db.connection();
for session_id in db_conn.get_all_active_sender_session_ids() {
let persister = SenderPersister::from_id(Arc::new(db.clone()), session_id.clone());
Expand Down
Loading