MCPcopy Index your code
hub / github.com/BitVM/BitVM / create_peg_out_graph

Method create_peg_out_graph

bridge/src/client/client.rs:968–1013  ·  view source on GitHub ↗
(
        &mut self,
        peg_in_graph_id: &str,
        peg_out_confirm_input: Input,
        commitment_secrets: HashMap<CommitmentMessageId, WinternitzSecret>,
    )

Source from the content-addressed store, hash-verified

966 }
967
968 pub fn create_peg_out_graph(
969 &mut self,
970 peg_in_graph_id: &str,
971 peg_out_confirm_input: Input,
972 commitment_secrets: HashMap<CommitmentMessageId, WinternitzSecret>,
973 ) -> String {
974 if self.operator_context.is_none() {
975 panic!("Operator context must be initialized");
976 }
977 let operator_public_key = &self.operator_context.as_ref().unwrap().operator_public_key;
978
979 let peg_in_graph = self
980 .data
981 .peg_in_graphs
982 .iter_mut()
983 .find(|peg_in_graph| peg_in_graph.id().eq(peg_in_graph_id))
984 .unwrap_or_else(|| panic!("Invalid graph ID"));
985
986 let peg_out_graph_id = peg_out_generate_id(peg_in_graph, operator_public_key);
987 let peg_out_graph = self
988 .data
989 .peg_out_graphs
990 .iter()
991 .find(|&peg_out_graph| peg_out_graph.id().eq(&peg_out_graph_id));
992 if peg_out_graph.is_some() {
993 panic!("Peg out graph already exists");
994 }
995
996 let peg_out_graph = PegOutGraph::new(
997 self.operator_context.as_ref().unwrap(),
998 peg_in_graph,
999 peg_out_confirm_input,
1000 &commitment_secrets,
1001 );
1002
1003 self.data.peg_out_graphs.push(peg_out_graph);
1004 peg_in_graph.peg_out_graphs.push(peg_out_graph_id.clone());
1005
1006 self.private_data.commitment_secrets = HashMap::from([(
1007 *operator_public_key,
1008 HashMap::from([(peg_out_graph_id.to_string(), commitment_secrets)]),
1009 )]);
1010 self.save_private_data();
1011
1012 peg_out_graph_id
1013 }
1014
1015 pub async fn broadcast_peg_out(
1016 &mut self,

Callers 8

test_peg_out_feesFunction · 0.80
create_peg_out_graphFunction · 0.80
test_syncFunction · 0.80
setup_and_create_graphsFunction · 0.80
create_graphFunction · 0.80
create_peg_out_graphFunction · 0.80

Calls 5

as_refMethod · 0.80
cloneMethod · 0.80
save_private_dataMethod · 0.80
idMethod · 0.45
pushMethod · 0.45

Tested by 6

test_peg_out_feesFunction · 0.64
create_peg_out_graphFunction · 0.64
test_syncFunction · 0.64
setup_and_create_graphsFunction · 0.64
create_graphFunction · 0.64
create_peg_out_graphFunction · 0.64