Save transaction as part of TxLogEntry after transaction completion (#1473)
* save wallet transaction on transaction completion * rustfmt * add resend command * rustfmt * added unit tests + fixes for grin wallet repost * add ability to dump transaction file contents * rustfmt * wallet doc update
This commit is contained in:
@@ -343,6 +343,50 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) {
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
("repost", Some(repost_args)) => {
|
||||
let tx_id: u32 = match repost_args.value_of("id") {
|
||||
None => {
|
||||
error!(LOGGER, "Transaction of a completed but unconfirmed transaction required (specify with --id=[id])");
|
||||
panic!();
|
||||
}
|
||||
Some(tx) => match tx.parse() {
|
||||
Ok(t) => t,
|
||||
Err(_) => {
|
||||
panic!("Unable to parse argument 'id' as a number");
|
||||
}
|
||||
},
|
||||
};
|
||||
let dump_file = repost_args.value_of("dumpfile");
|
||||
let fluff = repost_args.is_present("fluff");
|
||||
match dump_file {
|
||||
None => {
|
||||
let result = api.post_stored_tx(tx_id, fluff);
|
||||
match result {
|
||||
Ok(_) => {
|
||||
info!(LOGGER, "Reposted transaction at {}", tx_id);
|
||||
Ok(())
|
||||
}
|
||||
Err(e) => {
|
||||
error!(LOGGER, "Tranasction reposting failed: {}", e);
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(f) => {
|
||||
let result = api.dump_stored_tx(tx_id, f);
|
||||
match result {
|
||||
Ok(_) => {
|
||||
warn!(LOGGER, "Dumped transaction data for tx {} to {}", tx_id, f);
|
||||
Ok(())
|
||||
}
|
||||
Err(e) => {
|
||||
error!(LOGGER, "Tranasction reposting failed: {}", e);
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
("cancel", Some(tx_args)) => {
|
||||
let tx_id = tx_args
|
||||
.value_of("id")
|
||||
|
||||
@@ -222,6 +222,11 @@ fn main() {
|
||||
.help("Fluff the transaction (ignore Dandelion relay protocol)")
|
||||
.short("f")
|
||||
.long("fluff")))
|
||||
.arg(Arg::with_name("stored_tx")
|
||||
.help("If present, use the previously stored Unconfirmed transaction with given id.")
|
||||
.short("t")
|
||||
.long("stored_tx")
|
||||
.takes_value(true))
|
||||
|
||||
.subcommand(SubCommand::with_name("receive")
|
||||
.about("Processes a transaction file to accept a transfer from a sender.")
|
||||
@@ -268,6 +273,23 @@ fn main() {
|
||||
.long("id")
|
||||
.takes_value(true)))
|
||||
|
||||
.subcommand(SubCommand::with_name("repost")
|
||||
.about("Reposts a stored, completed but unconfirmed transaction to the chain, or dumps it to a file")
|
||||
.arg(Arg::with_name("id")
|
||||
.help("Transaction ID Containing the stored completed transaction")
|
||||
.short("i")
|
||||
.long("id")
|
||||
.takes_value(true))
|
||||
.arg(Arg::with_name("dumpfile")
|
||||
.help("File name to duMp the tranaction to instead of posting")
|
||||
.short("m")
|
||||
.long("dumpfile")
|
||||
.takes_value(true))
|
||||
.arg(Arg::with_name("fluff")
|
||||
.help("Fluff the transaction (ignore Dandelion relay protocol)")
|
||||
.short("f")
|
||||
.long("fluff")))
|
||||
|
||||
.subcommand(SubCommand::with_name("cancel")
|
||||
.about("Cancels an previously created transaction, freeing previously locked outputs for use again")
|
||||
.arg(Arg::with_name("id")
|
||||
|
||||
Reference in New Issue
Block a user