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
#![allow(clippy::module_name_repetitions)]

mod build;
mod id;
mod sign;
mod submit;

pub use build::Builder as TransactionCommandBuilder;
pub use id::Builder as IdCommandBuilder;
pub use sign::Builder as SignCommandBuilder;
use std::process::Command;
pub use submit::Builder as SubmitCommandBuilder;

pub struct Transaction {
    command: Command,
}

impl Transaction {
    pub fn new(command: Command) -> Self {
        Self { command }
    }

    pub fn id(mut self) -> IdCommandBuilder {
        self.command.arg("txid");
        IdCommandBuilder::new(self.command)
    }

    pub fn sign(mut self) -> SignCommandBuilder {
        self.command.arg("sign");
        SignCommandBuilder::new(self.command)
    }

    pub fn submit(mut self) -> SubmitCommandBuilder {
        self.command.arg("submit");
        SubmitCommandBuilder::new(self.command)
    }

    pub fn build(mut self) -> TransactionCommandBuilder {
        self.command.arg("build");
        TransactionCommandBuilder::new(self.command)
    }
}