Prepared Send (#596)

Co-authored-by: thesimplekid <tsk@thesimplekid.com>
Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
This commit is contained in:
David Caseria
2025-03-20 07:44:44 -04:00
committed by GitHub
parent c4488ce436
commit db1db86509
24 changed files with 1179 additions and 460 deletions

View File

@@ -1,10 +1,9 @@
use std::io::{self, Write};
use anyhow::{anyhow, Result};
use cdk::amount::SplitTarget;
use cdk::nuts::nut18::TransportType;
use cdk::nuts::{PaymentRequest, PaymentRequestPayload};
use cdk::wallet::{MultiMintWallet, SendKind};
use cdk::wallet::{MultiMintWallet, SendOptions};
use clap::Args;
use nostr_sdk::nips::nip19::Nip19Profile;
use nostr_sdk::{Client as NostrClient, EventBuilder, FromBech32, Keys};
@@ -81,17 +80,16 @@ pub async fn pay_request(
})
.ok_or(anyhow!("No supported transport method found"))?;
let proofs = matching_wallet
.send(
let prepared_send = matching_wallet
.prepare_send(
amount,
None,
None,
&SplitTarget::default(),
&SendKind::default(),
true,
SendOptions {
include_fee: true,
..Default::default()
},
)
.await?
.proofs();
.await?;
let proofs = matching_wallet.send(prepared_send, None).await?.proofs();
let payload = PaymentRequestPayload {
id: payment_request.payment_id.clone(),

View File

@@ -3,10 +3,9 @@ use std::io::Write;
use std::str::FromStr;
use anyhow::{bail, Result};
use cdk::amount::SplitTarget;
use cdk::nuts::{Conditions, CurrencyUnit, PublicKey, SpendingConditions};
use cdk::wallet::types::{SendKind, WalletKey};
use cdk::wallet::MultiMintWallet;
use cdk::wallet::{MultiMintWallet, SendMemo, SendOptions};
use cdk::Amount;
use clap::Args;
@@ -170,16 +169,22 @@ pub async fn send(
(false, None) => SendKind::OnlineExact,
};
let token = wallet
.send(
let prepared_send = wallet
.prepare_send(
token_amount,
sub_command_args.memo.clone(),
conditions,
&SplitTarget::default(),
&send_kind,
sub_command_args.include_fee,
SendOptions {
memo: sub_command_args.memo.clone().map(|memo| SendMemo {
memo,
include_memo: true,
}),
send_kind,
include_fee: sub_command_args.include_fee,
conditions,
..Default::default()
},
)
.await?;
let token = wallet.send(prepared_send, None).await?;
match sub_command_args.v3 {
true => {