Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions examples/cardinal/lockservice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,15 @@ pub fn lockservice(channel: LocalChannel<BrokerStorage>, identifier: Identifier)
_ => panic!("Expected Transaction message"),
};

info!("Received message from channel: {:?}", status.tx_id);
info!(
"Received message from channel: {:?}",
status.tx.as_ref().unwrap().compute_txid()
);
info!("happy path secret: {}", fake_secret);
info!("happy path public: {}", aggregated_happy_path);

let msg = serde_json::to_string(&(status.tx_id, fake_secret))?;
let tx = status.tx_or_err()?;
let msg = serde_json::to_string(&(tx.compute_txid(), fake_secret))?;
channel.send(&identifier, msg)?;
}

Expand Down
5 changes: 5 additions & 0 deletions src/bitvmx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,11 @@ impl BitVMX {
// TODO: Complete what to do here
ack_news = AckNews::Coordinator(AckCoordinatorNews::NetworkError(tx_id));
}
CoordinatorNews::TransactionStuckInMempool(tx_id, _context_data) => {
// TODO: Complete what to do here
ack_news =
AckNews::Coordinator(AckCoordinatorNews::TransactionStuckInMempool(tx_id));
}
}

self.program_context
Expand Down
5 changes: 4 additions & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bitcoin::{consensus::encode::FromHexError, network::ParseNetworkError, Witness};
use bitcoin_coordinator::errors::BitcoinCoordinatorError;
use bitcoin_coordinator::{errors::BitcoinCoordinatorError, IndexerError};
use bitcoincore_rpc::bitcoin::{key::ParsePublicKeyError, sighash::SighashTypeParseError};
use bitvmx_broker::{identification::errors::IdentificationError, rpc::errors::BrokerError};
use bitvmx_cpu_definitions::challenge::EmulatorResultError;
Expand Down Expand Up @@ -267,6 +267,9 @@ pub enum BitVMXError {
#[error("Failed to use Bitcoin Coordinator: {0}")]
BitcoinCoordinatorError(#[from] BitcoinCoordinatorError),

#[error("Indexer error: {0}")]
IndexerError(#[from] IndexerError),

#[error("Invalid transaction name {0}")]
InvalidTransactionName(String),

Expand Down
3 changes: 2 additions & 1 deletion src/program/protocols/cardinal/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ impl ProtocolHandler for LockProtocol {
);
}
if name == LOCK_TX && tx_status.confirmations == 1 {
let witness = tx_status.tx.input[0].witness.clone();
let tx = tx_status.tx_or_err()?;
let witness = tx.input[0].witness.clone();
info!(
"secret witness {:?}",
String::from_utf8(witness[1].to_vec())
Expand Down
19 changes: 7 additions & 12 deletions src/program/protocols/cardinal/slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,8 @@ impl ProtocolHandler for SlotProtocol {
.parse::<u32>()?;

info!("Operator {} has sent a certificate hash", operator);
self.decode_witness_for_tx(
&name,
0,
program_context,
&tx_status.tx,
Some(0),
None,
None,
)?;
let tx = tx_status.tx_or_err()?;
self.decode_witness_for_tx(&name, 0, program_context, tx, Some(0), None, None)?;

// after sending the certificate hash, the operator should send the group id
if self.ctx.my_idx == operator as usize {
Expand Down Expand Up @@ -282,7 +275,7 @@ impl ProtocolHandler for SlotProtocol {
.unwrap()
.number()?;

let txid = tx_status.tx_id;
let txid = tx.compute_txid();

//notify when the stops are consumed
for i in 0..total_operators - 1 {
Expand Down Expand Up @@ -433,11 +426,12 @@ impl ProtocolHandler for SlotProtocol {
vec![1.into()],
)?;
let speedup_data = self.get_speedup_data_from_tx(&tx, program_context, None)?;
let block_height = tx_status.block_info_or_err()?.height;
program_context.bitcoin_coordinator.dispatch(
tx,
Some(speedup_data),
Context::ProgramId(self.ctx.id).to_string()?,
Some(tx_status.block_info.unwrap().height + timelock_blocks),
Some(block_height + timelock_blocks),
self.requested_confirmations(program_context),
)?;
}
Expand All @@ -451,11 +445,12 @@ impl ProtocolHandler for SlotProtocol {
.collect();

info!("Operator {} has sent a group id", op_and_id[0]);
let tx = tx_status.tx_or_err()?;
self.decode_witness_for_tx(
&name,
0,
program_context,
&tx_status.tx,
tx,
Some(op_and_id[1]),
None,
None,
Expand Down
4 changes: 2 additions & 2 deletions src/program/protocols/dispute/tx_news.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ pub fn handle_tx_news(

match vout {
Some(vout) => {
let transaction = &tx_status.tx;
let transaction = tx_status.tx_or_err()?;
let input_index = drp.find_prevout(tx_id, vout, transaction)?;
let witness = transaction.input[input_index as usize].witness.clone();

Expand Down Expand Up @@ -533,7 +533,7 @@ pub fn handle_tx_news(
vout,
&name,
program_context,
&tx_status.tx,
transaction,
None,
)?;
}
Expand Down
3 changes: 2 additions & 1 deletion src/program/protocols/union/accept_pegin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ impl ProtocolHandler for AcceptPegInProtocol {
if operator_index == self.ctx.my_idx {
// Both, OPERATOR_TAKE_TX and OPERATOR_WON_TX, have the same output index to reimburse funds to the operator
let output_index: u32 = 0;
let amount = tx_status.tx.output[output_index as usize].value.to_sat();
let tx = tx_status.tx_or_err()?;
let amount = tx.output[output_index as usize].value.to_sat();
let utxo = (
tx_id,
output_index,
Expand Down
4 changes: 2 additions & 2 deletions src/program/protocols/union/advance_funds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ impl ProtocolHandler for AdvanceFundsProtocol {
block_height,
)?;

let tx = tx_status.tx;
self.update_advance_funds_input(context, &tx)?;
let tx = tx_status.tx_or_err()?;
self.update_advance_funds_input(context, tx)?;
}

Ok(())
Expand Down
3 changes: 2 additions & 1 deletion src/program/protocols/union/dispute_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2224,11 +2224,12 @@ impl DisputeCoreProtocol {
REVEAL_INPUT_TX_REVEAL_LEAF as u32,
)?;

let tx = tx_status.tx_or_err()?;
self.decode_witness_for_tx(
tx_name,
REVEAL_INPUT_TX_REVEAL_INDEX as u32,
context,
&tx_status.tx,
tx,
Some(REVEAL_INPUT_TX_REVEAL_LEAF as u32),
Some(protocol),
Some(vec![script]),
Expand Down
Loading