ddk_node/
cli_opts.rs

1use clap::{Parser, Subcommand};
2
3#[derive(Debug, Clone, Subcommand)]
4pub enum CliCommand {
5    /// Gets information about the DDK instance
6    Info,
7    /// Pass a contract input to send an offer
8    OfferContract(Offer),
9    /// Retrieve the offers that ddk-node has received.
10    Offers,
11    /// Accept a DLC offer with the contract id string.
12    AcceptOffer(Accept),
13    /// List contracts.
14    Contracts,
15    #[command(about = "Get the wallet balance.")]
16    Balance,
17    /// Wallet commands
18    #[clap(subcommand)]
19    Wallet(WalletCommand),
20    /// Interface with the oracle
21    #[clap(subcommand)]
22    Oracle(OracleCommand),
23    /// Get the peers connected to the node.
24    Peers,
25    /// Connect to another DDK node.
26    Connect {
27        #[arg(help = "The counter party to connect to. <PUBKEY>@<HOST>")]
28        connect_string: String,
29    },
30}
31
32#[derive(Parser, Clone, Debug)]
33pub struct Offer {
34    #[arg(help = "Generate a contract automatically with peer.")]
35    #[arg(short = 'g', long = "generate", default_value = "false")]
36    pub generate: bool,
37    #[arg(help = "The contract counterparty to send to.")]
38    pub counter_party: String,
39}
40
41#[derive(Clone, Debug, Subcommand)]
42pub enum WalletCommand {
43    #[command(about = "Generate a new, unused address from the wallet.")]
44    NewAddress,
45    #[command(about = "Get the wallet transactions.")]
46    Transactions,
47    #[command(about = "Get the wallet utxos.")]
48    Utxos,
49    #[command(about = "Send a Bitcoin amount to an address")]
50    Send {
51        /// Address to send to.
52        address: String,
53        /// Amount in sats to send to.
54        amount: u64,
55        /// Fee rate in sats/vbyte
56        fee_rate: u64,
57    },
58    #[command(about = "Sync the on-chain wallet.")]
59    Sync,
60}
61
62#[derive(Clone, Debug, Subcommand)]
63pub enum OracleCommand {
64    #[command(about = "Get all known oracle announcements.")]
65    Announcements,
66}
67
68#[derive(Parser, Clone, Debug)]
69pub struct Accept {
70    // The contract id string to accept.
71    pub contract_id: String,
72}
73
74#[derive(Parser, Clone, Debug)]
75pub struct Connect {
76    #[arg(help = "The public key to connect to.")]
77    pub pubkey: String,
78}