Skip to content

Commit

Permalink
coinjoin-merge-unsigned.rs
Browse files Browse the repository at this point in the history
added coinjoin-merge-unsigned.rs
  • Loading branch information
pinklite34 authored Feb 12, 2020
1 parent a70ca5a commit 6228f4d
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions coinjoin-merge-unsigned.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use hash::Hashable;

/* Modules */
mod decoder;
mod hash;
mod merge_unsigned;
mod transaction;
mod util;

/**
* Entry point
*/
fn main()
{
println ("Welcome to coinjoin-merge-unsigned. Enter each unsigned raw transaction");
println ("on a separate line, followed by a blank line or EOF to finish.");

let mut transactions: ~[transaction::Transaction] = ~[];

let mut next_ln = util::read_hex();
while next_ln.len() > 0 {
match transaction::from_hex (next_ln) {
Some(t) => { transactions.push (t); }
None => { println ("err: Failed to decode transaction."); }
}
next_ln = util::read_hex();
}

match merge_unsigned::merge_unsigned_transactions (transactions) {
None => { println ("err: Failed to merge transactions."); }
Some(t) => {
println (format! ("mpo: {:f}", (t.most_popular_output() as f64) / 100000000f64 ));
println (format! ("mpc: {:u}", t.most_popular_output_count()));
println (format! ("hex: {:s}", t.to_str()));
}
}
}

© 2020 GitHub, Inc.


0 comments on commit 6228f4d

Please sign in to comment.