forked from ordinals/ord
-
Notifications
You must be signed in to change notification settings - Fork 35
/
send.rs
46 lines (35 loc) Β· 929 Bytes
/
send.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use super::*;
#[derive(Debug, Parser)]
pub(crate) struct Send {
#[clap(long)]
address: Address,
#[clap(long)]
ordinal: Ordinal,
}
impl Send {
pub(crate) fn run(self, options: Options) -> Result {
let wallet = Purse::load(&options)?;
let utxo = wallet.find(&options, self.ordinal)?;
let (mut psbt, _details) = {
let mut builder = wallet.wallet.build_tx();
builder
.manually_selected_only()
.fee_absolute(0)
.add_utxo(utxo.outpoint)?
.add_recipient(self.address.script_pubkey(), utxo.txout.value);
builder.finish()?
};
if !wallet.wallet.sign(&mut psbt, SignOptions::default())? {
bail!("Failed to sign transaction.");
}
let tx = psbt.extract_tx();
wallet.blockchain.broadcast(&tx)?;
println!(
"Sent ordinal {} to address {}: {}",
self.ordinal.0,
self.address,
tx.txid()
);
Ok(())
}
}