(&mut self, sub_matches: &ArgMatches)
| 452 | } |
| 453 | |
| 454 | pub async fn handle_broadcast_command(&mut self, sub_matches: &ArgMatches) -> io::Result<()> { |
| 455 | self.client.sync().await; |
| 456 | |
| 457 | let subcommand = sub_matches.subcommand(); |
| 458 | let graph_id = subcommand.unwrap().1.get_one::<String>("graph_id").unwrap(); |
| 459 | |
| 460 | match subcommand.unwrap().1.subcommand() { |
| 461 | Some(("assert_commits", _)) => { |
| 462 | let result = self |
| 463 | .client |
| 464 | .broadcast_assert_commits(graph_id, &get_proof()) |
| 465 | .await; |
| 466 | if let Err(e) = result { |
| 467 | println!("Failed to broadcast transaction: {e}"); |
| 468 | } |
| 469 | } |
| 470 | Some((others, _)) => { |
| 471 | let result = match others { |
| 472 | "deposit" => self.client.broadcast_peg_in_deposit(graph_id).await, |
| 473 | "refund" => self.client.broadcast_peg_in_refund(graph_id).await, |
| 474 | "confirm" => self.client.broadcast_peg_in_confirm(graph_id).await, |
| 475 | "peg_out" => { |
| 476 | let input = self |
| 477 | .get_funding_utxo_input(subcommand.unwrap().1.get_one::<String>("utxo")) |
| 478 | .await?; |
| 479 | let result = self.client.broadcast_peg_out(graph_id, input).await; |
| 480 | self.client.flush().await; |
| 481 | result |
| 482 | } |
| 483 | "peg_out_confirm" => self.client.broadcast_peg_out_confirm(graph_id).await, |
| 484 | "kick_off_1" => self.client.broadcast_kick_off_1(graph_id).await, |
| 485 | "kick_off_2" => self.client.broadcast_kick_off_2(graph_id).await, |
| 486 | "start_time" => self.client.broadcast_start_time(graph_id).await, |
| 487 | "assert_initial" => self.client.broadcast_assert_initial(graph_id).await, |
| 488 | "assert_commit_1_invalid" => { |
| 489 | self.client |
| 490 | .broadcast_assert_commit_1(graph_id, &invalidate_proof(&get_proof())) |
| 491 | .await |
| 492 | } |
| 493 | "assert_commit_2_invalid" => { |
| 494 | self.client |
| 495 | .broadcast_assert_commit_2(graph_id, &invalidate_proof(&get_proof())) |
| 496 | .await |
| 497 | } |
| 498 | "assert_final" => self.client.broadcast_assert_final(graph_id).await, |
| 499 | "take_1" => self.client.broadcast_take_1(graph_id).await, |
| 500 | "take_2" => self.client.broadcast_take_2(graph_id).await, |
| 501 | "disprove" => { |
| 502 | let address = subcommand.unwrap().1.get_one::<String>("address").unwrap(); |
| 503 | let reward_address = Address::from_str(address).unwrap(); |
| 504 | let reward_script = reward_address.assume_checked().script_pubkey(); // TODO: verify checked/unchecked address |
| 505 | |
| 506 | self.client |
| 507 | .broadcast_disprove(graph_id, reward_script) |
| 508 | .await |
| 509 | } |
| 510 | &_ => unreachable!(), |
| 511 | }; |
no test coverage detected