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    /// Sync the wallet and contracts.
31    #[command(about = "Sync the wallet and contracts.")]
32    Sync,
33}
34
35#[derive(Parser, Clone, Debug)]
36pub struct Offer {
37    #[arg(help = "Generate a contract automatically with peer.")]
38    #[arg(short = 'g', long = "generate", default_value = "false")]
39    pub generate: bool,
40    #[arg(help = "The contract counterparty to send to.")]
41    pub counter_party: String,
42}
43
44#[derive(Clone, Debug, Subcommand)]
45pub enum WalletCommand {
46    #[command(about = "Generate a new, unused address from the wallet.")]
47    NewAddress,
48    #[command(about = "Get the wallet transactions.")]
49    Transactions,
50    #[command(about = "Get the wallet utxos.")]
51    Utxos,
52    #[command(about = "Send a Bitcoin amount to an address")]
53    Send {
54        /// Address to send to.
55        address: String,
56        /// Amount in sats to send to.
57        amount: u64,
58        /// Fee rate in sats/vbyte
59        fee_rate: u64,
60    },
61    #[command(about = "Sync the on-chain wallet.")]
62    Sync,
63}
64
65#[derive(Clone, Debug, Subcommand)]
66pub enum OracleCommand {
67    #[command(about = "Get all known oracle announcements.")]
68    Announcements {
69        #[arg(help = "The announcement id to get.")]
70        event_id: String,
71    },
72    #[command(about = "Create an enum oracle event.")]
73    CreateEnum {
74        #[arg(help = "The maturity of the event.")]
75        maturity: u32,
76        #[arg(help = "The outcomes of the event. Separate by spaces.")]
77        outcomes: Vec<String>,
78    },
79}
80#[derive(Parser, Clone, Debug)]
81pub struct Accept {
82    // The contract id string to accept.
83    pub contract_id: String,
84}
85
86#[derive(Parser, Clone, Debug)]
87pub struct Connect {
88    #[arg(help = "The public key to connect to.")]
89    pub pubkey: String,
90}