Skip to content

Commit c0abb00

Browse files
committed
Use WithReplyKey new() to generate a sender directly
1 parent 1460d24 commit c0abb00

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

  • payjoin/src/core/send/v2

payjoin/src/core/send/v2/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,7 @@ impl SenderBuilder {
169169
pj_param: PjParam,
170170
psbt_ctx: PsbtContext,
171171
) -> NextStateTransition<SessionEvent, Sender<WithReplyKey>> {
172-
let reply_key = HpkeKeyPair::gen_keypair().0;
173-
let sender = Sender {
174-
state: WithReplyKey,
175-
pj_param: pj_param.clone(),
176-
psbt_ctx: psbt_ctx.clone(),
177-
reply_key: reply_key.clone(),
178-
};
172+
let sender = Sender::new(pj_param, psbt_ctx);
179173
NextStateTransition::success(SessionEvent::Created(Box::new(sender.clone())), sender)
180174
}
181175
}
@@ -261,6 +255,10 @@ impl SendSession {
261255
pub struct WithReplyKey;
262256

263257
impl Sender<WithReplyKey> {
258+
fn new(pj_param: PjParam, psbt_ctx: PsbtContext) -> Self {
259+
Sender { state: WithReplyKey, pj_param, psbt_ctx, reply_key: HpkeKeyPair::gen_keypair().0 }
260+
}
261+
264262
/// Construct serialized Request and Context from a Payjoin Proposal.
265263
///
266264
/// Important: This request must not be retried or reused on failure.

0 commit comments

Comments
 (0)