Merge branch 'main' into wt/t_49b7c2b1
Some checks failed
ci / sdk (pull_request) Successful in 1m8s
android-ci / android (pull_request) Has been cancelled
ci / test (pull_request) Successful in 4m3s

This commit is contained in:
sirius 2026-09-15 21:50:53 +00:00
commit 3a17a564d3
9 changed files with 461 additions and 173 deletions

View file

@ -520,6 +520,57 @@ impl Node {
self.try_send(&onion, friend_pk, &prekey, &pt).await
}
/// Sign an invoice with this node's identity key.
///
/// The signing half of [`Self::pay_invoice`], for callers that build the
/// frame themselves (the Android SDK). The ed25519 secret never leaves the
/// node: it is signed with here and not handed out. `amount_atomic` is
/// piconero; `address` must be a valid Monero address; `memo` may be empty.
pub fn sign_invoice(
&self,
amount_atomic: &str,
address: &str,
memo: &str,
) -> Result<pay::Invoice, String> {
let k = self.keys()?;
pay::sign_invoice(&k.identity_sk, amount_atomic, address, memo, unix_now())
.map_err(|e| e.to_string())
}
/// Sign a receipt for a transfer that already happened: the signing half of
/// [`Self::tip`]. Same key discipline as [`Self::sign_invoice`].
pub fn sign_receipt(
&self,
txid: &str,
amount_atomic: &str,
address: &str,
) -> Result<pay::Receipt, String> {
let k = self.keys()?;
pay::sign_receipt(&k.identity_sk, txid, amount_atomic, address, unix_now())
.map_err(|e| e.to_string())
}
/// Sign a tip frame (receipt + memo) for a transfer that already happened.
/// This signs only — it does not move funds; that is [`Self::tip`].
pub fn sign_tip(
&self,
txid: &str,
amount_atomic: &str,
address: &str,
memo: &str,
) -> Result<pay::Tip, String> {
let k = self.keys()?;
pay::sign_tip(
&k.identity_sk,
txid,
amount_atomic,
address,
memo,
unix_now(),
)
.map_err(|e| e.to_string())
}
/// Invoice to receive. Wallet subaddress if up, else self_profile.xmr_addr.
pub async fn pay_invoice(
&self,
@ -528,9 +579,7 @@ impl Node {
memo: &str,
) -> Result<(), String> {
let address = self.invoice_address().await?;
let k = self.keys()?;
let inv = pay::sign_invoice(&k.identity_sk, atomic, &address, memo, unix_now())
.map_err(|e| e.to_string())?;
let inv = self.sign_invoice(atomic, &address, memo)?;
let pt = pay::encode_invoice(&inv);
self.send_once(friend_pk, &pt).await?;
let store = self.store.lock().map_err(|e| e.to_string())?;
@ -579,12 +628,9 @@ impl Node {
.transfer(&address, amount)
.await
.map_err(|e| e.to_string())?;
let k = self.keys()?;
let rcp = pay::sign_receipt(&k.identity_sk, &txid, atomic, &address, unix_now())
.map_err(|e| e.to_string())?;
let rcp = self.sign_receipt(&txid, atomic, &address)?;
let rcp_pt = pay::encode_receipt(&rcp);
let tip = pay::sign_tip(&k.identity_sk, &txid, atomic, &address, _memo, unix_now())
.map_err(|e| e.to_string())?;
let tip = self.sign_tip(&txid, atomic, &address, _memo)?;
let tip_pt = pay::encode_tip(&tip);
self.send_once(friend_pk, &rcp_pt).await?;
self.send_once(friend_pk, &tip_pt).await?;