-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Introduce sighash streamer * Add timeout tx signing * Verify timeout tx sigs * Save timeout tx sigs to db * Beautify nonce gen * Fix compilation errors, caused by the merge. * database: Add get_timeout_tx_sigs and test for timeout_tx_sigs. * database: Serialize signatures inside of save_timeout_tx_sigs, not outside. * clippy: Apply new suggestions. * builder: Remove blank spaces in sighash. * database: Write Schnorr signatures as bytea. * aggregator: Move create_nonce_streams to rpc crate. * cargo: Move new deps to workspace cargo file. * rpc: Replace deprecated pin_mut with std::pin. * error: Change message for TonicError type. * rpc: Move extract_pub_nonce outside of function and update it's comment. * rpc: verifier: Code simplification. * database: Add SignaturesDB wrapper. --------- Co-authored-by: Ceyhun Şen <[email protected]>
- Loading branch information
Showing
19 changed files
with
649 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ | |
pub mod address; | ||
pub mod script; | ||
pub mod sighash; | ||
pub mod transaction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
use crate::{actor::Actor, builder, database::Database, EVMAddress}; | ||
use async_stream::stream; | ||
use bitcoin::TapSighash; | ||
use bitcoin::{address::NetworkUnchecked, Address, Amount, OutPoint}; | ||
use futures_core::stream::Stream; | ||
|
||
pub fn create_nofn_sighash_stream( | ||
_db: Database, | ||
deposit_outpoint: OutPoint, | ||
evm_address: EVMAddress, | ||
recovery_taproot_address: Address<NetworkUnchecked>, | ||
user_takes_after: u64, | ||
nofn_xonly_pk: secp256k1::XOnlyPublicKey, | ||
) -> impl Stream<Item = TapSighash> { | ||
stream! { | ||
for i in 0..10 { | ||
let mut dummy_move_tx_handler = builder::transaction::create_move_tx_handler( | ||
deposit_outpoint, | ||
evm_address, | ||
&recovery_taproot_address, | ||
nofn_xonly_pk, | ||
bitcoin::Network::Regtest, | ||
user_takes_after as u32, | ||
Amount::from_sat(i as u64 + 1000000), | ||
); | ||
|
||
yield Actor::convert_tx_to_sighash_script_spend(&mut dummy_move_tx_handler, 0, 0) | ||
.unwrap(); | ||
|
||
} | ||
} | ||
} | ||
|
||
pub fn create_timout_tx_sighash_stream( | ||
operator_xonly_pk: secp256k1::XOnlyPublicKey, | ||
collateral_funding_txid: bitcoin::Txid, | ||
collateral_funding_amount: Amount, | ||
timeout_block_count: i64, | ||
max_withdrawal_time_block_count: i64, | ||
num_time_txs: usize, | ||
network: bitcoin::Network, | ||
) -> impl Stream<Item = TapSighash> { | ||
let mut input_txid = collateral_funding_txid; | ||
let mut input_amunt = collateral_funding_amount; | ||
stream! { | ||
for _ in 0..num_time_txs { | ||
let time_tx = builder::transaction::create_time_tx( | ||
operator_xonly_pk, | ||
input_txid, | ||
input_amunt, | ||
timeout_block_count, | ||
max_withdrawal_time_block_count, | ||
network, | ||
); | ||
|
||
let mut timeout_tx_handler = builder::transaction::create_timeout_tx_handler( | ||
operator_xonly_pk, | ||
time_tx.compute_txid(), | ||
timeout_block_count, | ||
network, | ||
); | ||
|
||
yield Actor::convert_tx_to_sighash_script_spend(&mut timeout_tx_handler, 0, 0).unwrap(); | ||
|
||
let time2_tx = builder::transaction::create_time2_tx( | ||
operator_xonly_pk, | ||
time_tx.compute_txid(), | ||
input_amunt, | ||
network, | ||
); | ||
|
||
input_txid = time2_tx.compute_txid(); | ||
input_amunt = time2_tx.output[0].value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.