Skip to content

Commit 60fd9f4

Browse files
committed
f
1 parent 0c684a9 commit 60fd9f4

File tree

10 files changed

+221
-246
lines changed

10 files changed

+221
-246
lines changed

src/builder.rs

+9-15
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ use crate::io::sqlite_store::SqliteStore;
1111
use crate::liquidity::LiquiditySource;
1212
use crate::logger::{log_error, log_info, FilesystemLogger, Logger};
1313
use crate::message_handler::NodeCustomMessageHandler;
14+
use crate::payment::payjoin::send::PayjoinSender;
1415
use crate::payment::store::PaymentStore;
1516
use crate::peer_store::PeerStore;
1617
use crate::tx_broadcaster::TransactionBroadcaster;
1718
use crate::types::{
1819
ChainMonitor, ChannelManager, DynStore, GossipSync, Graph, KeysManager, MessageRouter,
19-
OnionMessenger, PayjoinSender, PeerManager,
20+
OnionMessenger, PeerManager,
2021
};
2122
use crate::wallet::Wallet;
2223
use crate::{LogLevel, Node};
@@ -262,10 +263,9 @@ impl NodeBuilder {
262263
}
263264

264265
/// Configures the [`Node`] instance to enable payjoin transactions.
265-
pub fn set_payjoin_config(
266-
&mut self, payjoin_relay: String
267-
) -> Result<&mut Self, BuildError> {
268-
let payjoin_relay = payjoin::Url::parse(&payjoin_relay).map_err(|_| BuildError::InvalidPayjoinConfig)?;
266+
pub fn set_payjoin_config(&mut self, payjoin_relay: String) -> Result<&mut Self, BuildError> {
267+
let payjoin_relay =
268+
payjoin::Url::parse(&payjoin_relay).map_err(|_| BuildError::InvalidPayjoinConfig)?;
269269
self.payjoin_config = Some(PayjoinConfig { payjoin_relay });
270270
Ok(self)
271271
}
@@ -479,12 +479,8 @@ impl ArcedNodeBuilder {
479479
}
480480

481481
/// Configures the [`Node`] instance to enable payjoin transactions.
482-
pub fn set_payjoin_config(
483-
&self, payjoin_relay: String,
484-
) -> Result<(), BuildError> {
485-
self.inner.write().unwrap().set_payjoin_config(
486-
payjoin_relay,
487-
).map(|_| ())
482+
pub fn set_payjoin_config(&self, payjoin_relay: String) -> Result<(), BuildError> {
483+
self.inner.write().unwrap().set_payjoin_config(payjoin_relay).map(|_| ())
488484
}
489485

490486
/// Configures the [`Node`] instance to source its gossip data from the given RapidGossipSync
@@ -1004,10 +1000,8 @@ fn build_with_store_internal(
10041000
let mut payjoin_sender = None;
10051001
if let Some(pj_config) = payjoin_config {
10061002
payjoin_sender = Some(Arc::new(PayjoinSender::new(
1007-
Arc::clone(&logger),
1008-
Arc::clone(&wallet),
1009-
Arc::clone(&tx_broadcaster),
1010-
pj_config.payjoin_relay.clone(),
1003+
Arc::clone(&logger),
1004+
pj_config.payjoin_relay.clone(),
10111005
)));
10121006
}
10131007

src/event.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ pub enum Event {
158158
/// Reason for the failure.
159159
reason: String,
160160
},
161+
/// Failed to send Payjoin transaction.
162+
///
163+
/// This event is emitted when our attempt to send Payjoin transaction fail.
164+
PayjoinPaymentPending {
165+
/// Transaction ID of the successfully sent Payjoin transaction.
166+
txid: bitcoin::Txid,
167+
},
161168
}
162169

163170
impl_writeable_tlv_based_enum!(Event,
@@ -199,12 +206,15 @@ impl_writeable_tlv_based_enum!(Event,
199206
(2, payment_id, required),
200207
(4, claimable_amount_msat, required),
201208
(6, claim_deadline, option),
202-
},
209+
},
203210
(7, PayjoinTxSendSuccess) => {
204211
(0, txid, required),
205212
},
206213
(8, PayjoinTxSendFailed) => {
207214
(0, reason, required),
215+
},
216+
(9, PayjoinPaymentPending) => {
217+
(0, txid, required),
208218
};
209219
);
210220

src/lib.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ pub mod io;
8989
mod liquidity;
9090
mod logger;
9191
mod message_handler;
92-
mod payjoin_sender;
9392
pub mod payment;
9493
mod peer_store;
9594
mod sweep;
@@ -110,6 +109,7 @@ pub use error::Error as NodeError;
110109
use error::Error;
111110

112111
pub use event::Event;
112+
use payment::payjoin::send::PayjoinSender;
113113
pub use types::ChannelConfig;
114114

115115
pub use io::utils::generate_entropy_mnemonic;
@@ -141,7 +141,7 @@ use payment::{
141141
use peer_store::{PeerInfo, PeerStore};
142142
use types::{
143143
Broadcaster, BumpTransactionEventHandler, ChainMonitor, ChannelManager, DynStore, FeeEstimator,
144-
Graph, KeysManager, PayjoinSender, PeerManager, Router, Scorer, Sweeper, Wallet,
144+
Graph, KeysManager, PeerManager, Router, Scorer, Sweeper, Wallet,
145145
};
146146
pub use types::{ChannelDetails, PeerDetails, UserChannelId};
147147

@@ -1082,6 +1082,9 @@ impl Node {
10821082
payjoin_sender.map(Arc::clone),
10831083
Arc::clone(&self.config),
10841084
Arc::clone(&self.event_queue),
1085+
Arc::clone(&self.logger),
1086+
Arc::clone(&self.wallet),
1087+
Arc::clone(&self.tx_broadcaster),
10851088
)
10861089
}
10871090

@@ -1099,6 +1102,9 @@ impl Node {
10991102
payjoin_sender.map(Arc::clone),
11001103
Arc::clone(&self.config),
11011104
Arc::clone(&self.event_queue),
1105+
Arc::clone(&self.logger),
1106+
Arc::clone(&self.wallet),
1107+
Arc::clone(&self.tx_broadcaster),
11021108
))
11031109
}
11041110

src/payjoin_sender.rs

-173
This file was deleted.

src/payment/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
mod bolt11;
44
mod bolt12;
55
mod onchain;
6-
mod payjoin;
6+
pub(crate) mod payjoin;
77
mod spontaneous;
88
pub(crate) mod store;
99

0 commit comments

Comments
 (0)