From 9b26dceb82deee234be79d41b047a57f92a68754 Mon Sep 17 00:00:00 2001 From: NicolasCantu Date: Mon, 3 Feb 2025 16:24:20 +0100 Subject: [PATCH] Add an output to update for pairing process --- src/commit.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/commit.rs b/src/commit.rs index 185187c..09d89c1 100644 --- a/src/commit.rs +++ b/src/commit.rs @@ -323,11 +323,25 @@ fn commit_new_transaction( .ok_or(Error::msg("Wallet not initialized"))? .get_wallet()?; - let recipient = Recipient { + let mut recipients = vec![]; + recipients.push(Recipient { address: sp_wallet.get_client().get_receiving_address(), amount: Amount::from_sat(1000), nb_outputs: 1, - }; + }); + + // If the process is a pairing, we add another output that directly pays the owner of the process + // We can find out simply by looking at the members list + if let Some(member) = lock_members()?.get(&updated_process.get_process_id().unwrap()) { + // We just pick one of the devices of the member at random en pay to it, member can then share the private key between all devices + // For now we take the first address + recipients.push(Recipient { + address: member.get_addresses().iter().next().unwrap().to_string(), + amount: Amount::from_sat(1000), + nb_outputs: 1 + }); + } + // This output is used to generate publicly available public keys without having to go through too many loops let daemon = DAEMON.get().unwrap().lock_anyhow()?; let fee_rate = daemon.estimate_fee(6) @@ -350,7 +364,7 @@ fn commit_new_transaction( vec![mandatory_input], &freezed_utxos, &sp_wallet, - vec![recipient], + recipients, Some(commitment_payload), fee_rate, None,