imports for offline signing
This commit is contained in:
@@ -9,14 +9,16 @@ use cosmrs::tx::Msg;
|
||||
use cosmrs::{tx, AccountId, Coin, Denom};
|
||||
use bip39;
|
||||
|
||||
pub async fn offline_sign() -> Vec<u8> {
|
||||
pub async fn offline_sign(mnemonic: &String, to: &String) -> Vec<u8> {
|
||||
|
||||
// TODO load most of this from config file, take address and mnemonic from function args, take address and mnemonic from function args. in V2 take chain-id and tx-type as well
|
||||
// TODO load most of this from config file. in V2 take chain-id and tx-type as well
|
||||
let prefix = "n";
|
||||
let denom: Denom = "unym".parse().unwrap();
|
||||
let signer_mnemonic: bip39::Mnemonic = "<SOME MNEMONIC>".parse().unwrap();
|
||||
let signer_mnemonic: bip39::Mnemonic = mnemonic.parse().unwrap();
|
||||
// let signer_mnemonic: bip39::Mnemonic = "<SOME MNEMONIC>".parse().unwrap();
|
||||
let validator = "https://qwerty-validator.qa.nymte.ch";
|
||||
let to_address: AccountId = "n19kdst4srf76xgwe55jg32mpcpcyf6aqgp6qrdk".parse().unwrap();
|
||||
let to_address: AccountId = to.parse().unwrap();
|
||||
// let to_address: AccountId = "n19kdst4srf76xgwe55jg32mpcpcyf6aqgp6qrdk".parse().unwrap();
|
||||
|
||||
let signer = DirectSecp256k1HdWallet::from_mnemonic(prefix, signer_mnemonic);
|
||||
let signer_address = signer.try_derive_accounts().unwrap()[0].address().clone();
|
||||
|
||||
@@ -30,8 +30,12 @@ enum Commands {
|
||||
|
||||
#[derive(Debug, Clone, Args)]
|
||||
struct OfflineSignTx {
|
||||
/// some random info for testing
|
||||
string: String,
|
||||
// / some random info for testing
|
||||
// string: String,
|
||||
/// mnemonic
|
||||
mnemonic: String,
|
||||
/// recipient nym address
|
||||
to: String
|
||||
}
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
@@ -46,11 +50,11 @@ async fn main() {
|
||||
let cli = Cli::parse();
|
||||
|
||||
match &cli.command {
|
||||
Some(Commands::OfflineSignTx(string)) => {
|
||||
let tx_bytes = commands::commands::offline_sign();
|
||||
Some(Commands::OfflineSignTx(OfflineSignTx { mnemonic, to } )) => {
|
||||
let tx_bytes = commands::commands::offline_sign(mnemonic, to);
|
||||
// TODO parse future
|
||||
// println!("{}", parsed.iter().format(", "));
|
||||
println!("end {:?}", string);
|
||||
println!("signed");
|
||||
}
|
||||
Some(Commands::SendTx(sp_address)) => {
|
||||
todo!();
|
||||
|
||||
Reference in New Issue
Block a user