-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
fixup
Showing
9 changed files
with
98 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,37 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use crate::cli_types::CommandAction; | ||
use crate::{ | ||
cli_types::{CommandAction, WalletContextOptions}, | ||
commands::transaction::commands::is_file_path, | ||
}; | ||
use async_trait::async_trait; | ||
use clap::Parser; | ||
use rooch_types::error::RoochResult; | ||
|
||
#[derive(Debug, Parser)] | ||
pub struct BroadcastTx { | ||
input_file: String, | ||
input: String, | ||
#[clap(flatten)] | ||
pub(crate) context_options: WalletContextOptions, | ||
} | ||
|
||
#[async_trait] | ||
impl CommandAction<String> for BroadcastTx { | ||
async fn execute(self) -> RoochResult<String> { | ||
// Implement broadcast-tx logic here | ||
Ok(format!("Broadcasted transaction from {}", self.input_file)) | ||
let context = self.context_options.build()?; | ||
let client = context.get_client().await?; | ||
|
||
let bytes = if is_file_path(&self.input) { | ||
std::fs::read(self.input)? | ||
} else { | ||
let hex = self.input.strip_prefix("0x").unwrap_or(&self.input); | ||
hex::decode(hex)? | ||
}; | ||
|
||
Ok(client | ||
.rooch | ||
.broadcast_bitcoin_tx(bytes.into(), None) | ||
.await?) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters