Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disprove tx #388

Merged
merged 22 commits into from
Jan 9, 2025
Merged

disprove tx #388

merged 22 commits into from
Jan 9, 2025

Conversation

atacann
Copy link

@atacann atacann commented Jan 3, 2025

Description

Adds disprove tx, challenge tx and happy reimburse tx.

@atacann atacann changed the base branch from main to dev January 3, 2025 11:29
@@ -286,6 +286,36 @@ impl Actor {
Ok(sig_hash)
}

#[tracing::instrument(err(level = tracing::Level::ERROR), ret(level = tracing::Level::TRACE))]
pub fn convert_tx_to_script_spend(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have this in Actor

@atacann atacann marked this pull request as ready for review January 3, 2025 14:06
@atacann atacann requested a review from ekrembal January 3, 2025 14:10
core/src/builder/sighash.rs Outdated Show resolved Hide resolved
core/src/builder/transaction.rs Outdated Show resolved Hide resolved
core/src/builder/transaction.rs Outdated Show resolved Hide resolved
core/src/builder/transaction.rs Outdated Show resolved Hide resolved
core/src/builder/transaction.rs Show resolved Hide resolved
core/src/builder/transaction.rs Show resolved Hide resolved

let sig_hash = sighash_cache.taproot_key_spend_signature_hash(
txin_index,
&bitcoin::sighash::Prevouts::All(&tx.prevouts),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is inccorect, it should be like:

            &match sighash_type {
                Some(TapSighashType::SinglePlusAnyoneCanPay) => {
                    bitcoin::sighash::Prevouts::One(input_index, prevouts[input_index].clone())
                }
                _ => bitcoin::sighash::Prevouts::All(prevouts),
            },

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a511219

let mut sighash_cache: SighashCache<&mut bitcoin::Transaction> =
SighashCache::new(&mut tx_handler.tx);

let prevouts = bitcoin::sighash::Prevouts::All(&tx_handler.prevouts);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is inccorect, it should be like:

            &match sighash_type {
                Some(TapSighashType::SinglePlusAnyoneCanPay) => {
                    bitcoin::sighash::Prevouts::One(input_index, prevouts[input_index].clone())
                }
                _ => bitcoin::sighash::Prevouts::All(prevouts),
            },

core/src/builder/transaction.rs Show resolved Hide resolved

let tx_outs = vec![TxOut {
value: OPERATOR_CHALLENGE_AMOUNT,
script_pubkey: operator_taproot_address.script_pubkey(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use operator_reimbursement_wallet_address here,

We use operator_taproot_address for signing but operators will be using their bitcoin core wallet to send the fee paying child txs for their assert txs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9a907d4

TxOut {
// value in create_move_tx currently
value: bridge_amount_sats - MOVE_TX_MIN_RELAY_FEE - anyone_can_spend_txout.value,
script_pubkey: operator_taproot_address.script_pubkey(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use operator_reimbursment_address here as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this part commit 9a907d4 was wrong, fixed in 3987d9a

core/src/builder/transaction.rs Show resolved Hide resolved
let mut sighash_cache: SighashCache<&mut bitcoin::Transaction> =
SighashCache::new(&mut tx_handler.tx);
let prevouts = &match sighash_type {
Some(TapSighashType::SinglePlusAnyoneCanPay) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add other cases?
For these sighases:
SIGHASH_ALL|ANYONECANPAY
SIGHASH_SINGLE|ANYONECANPAY
SIGHASH_NONE|ANYONECANPAY
We require One prevout, otherwise we require all prevouts

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added them 536f1f7

@atacann atacann merged commit 32a0ac6 into dev Jan 9, 2025
9 checks passed
@atacann atacann deleted the atacan/disprove_tx branch January 9, 2025 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants