Skip to content

Commit

Permalink
chore: Update bitcoin to 0.31.2
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyhodl committed Jun 4, 2024
1 parent 8771f30 commit 5f11673
Show file tree
Hide file tree
Showing 25 changed files with 200 additions and 177 deletions.
8 changes: 4 additions & 4 deletions bitcoin-rpc-provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ name = "bitcoin-rpc-provider"
version = "0.1.0"

[dependencies]
bitcoin = {version = "0.30.2"}
bitcoincore-rpc = {version = "0.17.0"}
bitcoincore-rpc-json = {version = "0.17.0"}
bitcoin = {version = "0.31.2"}
bitcoincore-rpc = {version = "0.19.0"}
bitcoincore-rpc-json = {version = "0.19.0"}
dlc-manager = {path = "../dlc-manager"}
hex = { package = "hex-conservative", version = "0.1" }
lightning = { version = "0.0.121" }
lightning = { version = "0.0.123" }
log = "0.4.14"
rust-bitcoin-coin-selection = { version = "0.1.0", git = "https://github.com/p2pderivatives/rust-bitcoin-coin-selection", rev = "405451929568422f7df809e35d6ad8f36fccce90", features = ["rand"] }
simple-wallet = {path = "../simple-wallet"}
6 changes: 3 additions & 3 deletions bitcoin-test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ name = "bitcoin-test-utils"
version = "0.1.0"

[dependencies]
bitcoin = { version = "0.30.2", default-features = false }
bitcoincore-rpc = {version = "0.17"}
bitcoincore-rpc-json = {version = "0.17"}
bitcoin = { version = "0.31.2", default-features = false }
bitcoincore-rpc = {version = "0.19"}
bitcoincore-rpc-json = {version = "0.19"}
9 changes: 5 additions & 4 deletions dlc-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ use-serde = ["serde", "dlc/use-serde", "dlc-messages/serde", "dlc-trie/use-serde

[dependencies]
async-trait = "0.1.50"
bitcoin = { version = "0.30.2", default-features = false }
bitcoin = { version = "0.31.2", default-features = false }
dlc = { version = "0.4.0", default-features = false, path = "../dlc" }
dlc-messages = { version = "0.4.0", default-features = false, path = "../dlc-messages" }
dlc-trie = { version = "0.4.0", default-features = false, path = "../dlc-trie" }
hex = { package = "hex-conservative", version = "0.1" }
lightning = { version = "0.0.121", default-features = false, features = ["grind_signatures"] }
# lightning = { version = "0.0.123", default-features = false, features = ["grind_signatures"] }
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", default-features = false, features = ["grind_signatures"] }
log = "0.4.14"
rand_chacha = {version = "0.3.1", optional = true}
secp256k1-zkp = {version = "0.9.2"}
secp256k1-zkp = {version = "0.10.1"}
serde = {version = "1.0", optional = true}

[dev-dependencies]
Expand All @@ -39,7 +40,7 @@ dlc-messages = { path = "../dlc-messages", default-features = false, features =
electrs-blockchain-provider = {path = "../electrs-blockchain-provider"}
env_logger = "0.9.1"
mocks = {path = "../mocks"}
secp256k1-zkp = {version = "0.9.2", features = ["bitcoin_hashes", "rand", "rand-std", "global-context", "serde"]}
secp256k1-zkp = {version = "0.10.1", features = ["rand", "rand-std", "global-context", "serde"]}
serde = "1.0"
serde_json = "1.0"
simple-wallet = {path = "../simple-wallet"}
Expand Down
48 changes: 24 additions & 24 deletions dlc-manager/src/channel_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ where
let buffer_adaptor_signature = get_tx_adaptor_signature(
secp,
&buffer_transaction,
dlc_transactions.get_fund_output().value,
dlc_transactions.get_fund_output().value.to_sat(),
&dlc_transactions.funding_script_pubkey,
&signer.get_secret_key()?,
&offer_revoke_params.publish_pk.inner,
Expand All @@ -237,7 +237,7 @@ where
&accept_params,
&funding_inputs,
&own_secret_key,
buffer_transaction.output[0].value,
buffer_transaction.output[0].value.to_sat(),
Some(&buffer_script_pubkey),
&dlc_transactions,
)?;
Expand Down Expand Up @@ -359,7 +359,7 @@ where
&accept_channel.funding_inputs,
&accept_channel.refund_signature,
&accept_cet_adaptor_signatures,
buffer_transaction.output[0].value,
buffer_transaction.output[0].value.to_sat(),
wallet,
&offer_own_sk,
Some(&buffer_script_pubkey),
Expand All @@ -371,7 +371,7 @@ where
verify_tx_adaptor_signature(
secp,
&buffer_transaction,
dlc_transactions.get_fund_output().value,
dlc_transactions.get_fund_output().value.to_sat(),
&dlc_transactions.funding_script_pubkey,
&signed_contract.accepted_contract.accept_params.fund_pubkey,
&offer_revoke_params.publish_pk.inner,
Expand All @@ -381,7 +381,7 @@ where
let own_buffer_adaptor_signature = get_tx_adaptor_signature(
secp,
&buffer_transaction,
dlc_transactions.get_fund_output().value,
dlc_transactions.get_fund_output().value.to_sat(),
&dlc_transactions.funding_script_pubkey,
&offer_fund_sk.get_secret_key()?,
&accept_revoke_params.publish_pk.inner,
Expand Down Expand Up @@ -457,7 +457,7 @@ where
verify_tx_adaptor_signature(
secp,
&accepted_channel.buffer_transaction,
accepted_contract.dlc_transactions.get_fund_output().value,
accepted_contract.dlc_transactions.get_fund_output().value.to_sat(),
&accepted_contract.dlc_transactions.funding_script_pubkey,
&accepted_contract.offered_contract.offer_params.fund_pubkey,
&own_publish_pk,
Expand All @@ -472,7 +472,7 @@ where
&sign_channel.refund_signature,
&cet_adaptor_signatures,
&sign_channel.funding_signatures,
accepted_channel.buffer_transaction.output[0].value,
accepted_channel.buffer_transaction.output[0].value.to_sat(),
Some(&accepted_channel.buffer_script_pubkey),
Some(counter_own_pk),
wallet,
Expand Down Expand Up @@ -840,7 +840,7 @@ where
verify_tx_adaptor_signature(
secp,
settle_tx,
channel.fund_tx.output[channel.fund_output_index].value,
channel.fund_tx.output[channel.fund_output_index].value.to_sat(),
&channel.fund_script_pubkey,
&channel.counter_params.fund_pubkey,
&accept_revoke_params.publish_pk.inner,
Expand Down Expand Up @@ -1190,7 +1190,7 @@ where
let buffer_adaptor_signature = get_tx_adaptor_signature(
secp,
&buffer_transaction,
dlc_transactions.get_fund_output().value,
dlc_transactions.get_fund_output().value.to_sat(),
&dlc_transactions.funding_script_pubkey,
&contract_signer.get_secret_key()?,
&offer_revoke_params.publish_pk.inner,
Expand All @@ -1204,7 +1204,7 @@ where
&signed_channel.own_params,
&[],
&own_secret_key,
buffer_transaction.output[0].value,
buffer_transaction.output[0].value.to_sat(),
Some(&buffer_script_pubkey),
&dlc_transactions,
)?;
Expand Down Expand Up @@ -1318,7 +1318,7 @@ where
&[],
&renew_accept.refund_signature,
&cet_adaptor_signatures,
buffer_transaction.output[0].value,
buffer_transaction.output[0].value.to_sat(),
wallet,
&offer_own_sk,
Some(&buffer_script_pubkey),
Expand All @@ -1330,7 +1330,7 @@ where
verify_tx_adaptor_signature(
secp,
&buffer_transaction,
dlc_transactions.get_fund_output().value,
dlc_transactions.get_fund_output().value.to_sat(),
&dlc_transactions.funding_script_pubkey,
&signed_contract.accepted_contract.accept_params.fund_pubkey,
&offer_revoke_params.publish_pk.inner,
Expand All @@ -1340,7 +1340,7 @@ where
let own_buffer_adaptor_signature = get_tx_adaptor_signature(
secp,
&buffer_transaction,
dlc_transactions.get_fund_output().value,
dlc_transactions.get_fund_output().value.to_sat(),
&dlc_transactions.funding_script_pubkey,
&contract_signer.get_secret_key()?,
&accept_revoke_params.publish_pk.inner,
Expand Down Expand Up @@ -1416,7 +1416,7 @@ where
verify_tx_adaptor_signature(
secp,
buffer_transaction,
accepted_contract.dlc_transactions.get_fund_output().value,
accepted_contract.dlc_transactions.get_fund_output().value.to_sat(),
&accepted_contract.dlc_transactions.funding_script_pubkey,
&accepted_contract.offered_contract.offer_params.fund_pubkey,
&own_publish_pk,
Expand All @@ -1431,7 +1431,7 @@ where
&FundingSignatures {
funding_signatures: Vec::new(),
},
buffer_transaction.output[0].value,
buffer_transaction.output[0].value.to_sat(),
Some(buffer_script_pubkey),
Some(counter_own_pk),
wallet,
Expand Down Expand Up @@ -1573,7 +1573,7 @@ where
let total_collateral =
signed_channel.own_params.collateral + signed_channel.counter_params.collateral;
let offer_payout = total_collateral - counter_payout;
let fund_output_value = signed_channel.fund_tx.output[signed_channel.fund_output_index].value;
let fund_output_value = signed_channel.fund_tx.output[signed_channel.fund_output_index].value.to_sat();

let close_tx = dlc::channel::create_collaborative_close_transaction(
&signed_channel.own_params,
Expand Down Expand Up @@ -1648,7 +1648,7 @@ where
}

let offer_payout = total_collateral - close_offer.counter_payout;
let fund_output_value = signed_channel.fund_tx.output[signed_channel.fund_output_index].value;
let fund_output_value = signed_channel.fund_tx.output[signed_channel.fund_output_index].value.to_sat();

let close_tx = dlc::channel::create_collaborative_close_transaction(
&signed_channel.counter_params,
Expand Down Expand Up @@ -1695,7 +1695,7 @@ where
keys_id
)?;

let fund_out_amount = signed_channel.fund_tx.output[signed_channel.fund_output_index].value;
let fund_out_amount = signed_channel.fund_tx.output[signed_channel.fund_output_index].value.to_sat();

let contract_signer = signer_provider.derive_contract_signer(*keys_id)?;

Expand Down Expand Up @@ -1771,15 +1771,15 @@ fn get_settle_tx_and_adaptor_sig(
accept_payout,
csv_timelock,
lock_time,
fund_tx.output[fund_vout].value,
fund_tx.output[fund_vout].value.to_sat(),
fee_rate_per_vb,
)?;

if let Some((adaptor_sig, fund_pk)) = counter_adaptor_signature {
verify_tx_adaptor_signature(
secp,
&settle_tx,
fund_tx.output[fund_vout].value,
fund_tx.output[fund_vout].value.to_sat(),
funding_script_pubkey,
&fund_pk,
&offer_revoke_params.publish_pk.inner,
Expand All @@ -1796,7 +1796,7 @@ fn get_settle_tx_and_adaptor_sig(
let settle_adaptor_signature = dlc::channel::get_tx_adaptor_signature(
secp,
&settle_tx,
fund_tx.output[fund_vout].value,
fund_tx.output[fund_vout].value.to_sat(),
funding_script_pubkey,
own_fund_sk,
&counter_pk,
Expand Down Expand Up @@ -1878,7 +1878,7 @@ where
&signed_channel.counter_params.fund_pubkey,
&fund_sk.get_secret_key()?,
&signed_channel.fund_script_pubkey,
signed_channel.fund_tx.output[signed_channel.fund_output_index].value,
signed_channel.fund_tx.output[signed_channel.fund_output_index].value.to_sat(),
0,
)?;

Expand Down Expand Up @@ -1951,7 +1951,7 @@ where
dlc::channel::sign_cet(
secp,
&mut cet,
buffer_transaction.output[0].value,
buffer_transaction.output[0].value.to_sat(),
&offer_revoke_params,
&accept_revoke_params,
&own_sk,
Expand Down Expand Up @@ -2009,7 +2009,7 @@ where
&signed_channel.counter_params.fund_pubkey,
&fund_sk.get_secret_key()?,
&signed_channel.fund_script_pubkey,
signed_channel.fund_tx.output[signed_channel.fund_output_index].value,
signed_channel.fund_tx.output[signed_channel.fund_output_index].value.to_sat(),
0,
)?;

Expand Down
2 changes: 1 addition & 1 deletion dlc-manager/src/contract/accepted_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl AcceptedContract {
.iter()
.find_map(|x| {
if &x.script_pubkey == v0_witness_payout_script {
Some(x.value)
Some(x.value.to_sat())
} else {
None
}
Expand Down
20 changes: 10 additions & 10 deletions dlc-manager/src/contract_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::ops::Deref;

use bitcoin::psbt::PartiallySignedTransaction;
use bitcoin::psbt::Psbt;
use bitcoin::{consensus::Decodable, Script, Transaction, Witness};
use dlc::{DlcTransactions, PartyParams};
use dlc_messages::FundingInput;
Expand Down Expand Up @@ -112,7 +112,7 @@ where
offered_contract.fund_output_serial_id,
)?;

let fund_output_value = dlc_transactions.get_fund_output().value;
let fund_output_value = dlc_transactions.get_fund_output().value.to_sat();

let (accepted_contract, adaptor_sigs) = accept_contract_internal(
secp,
Expand Down Expand Up @@ -272,7 +272,7 @@ where
offered_contract.cet_locktime,
offered_contract.fund_output_serial_id,
)?;
let fund_output_value = dlc_transactions.get_fund_output().value;
let fund_output_value = dlc_transactions.get_fund_output().value.to_sat();

let signer = signer_provider.derive_contract_signer(offered_contract.keys_id)?;
let (signed_contract, adaptor_sigs) = verify_accepted_and_sign_contract_internal(
Expand All @@ -297,7 +297,7 @@ where
}

fn populate_psbt(
psbt: &mut PartiallySignedTransaction,
psbt: &mut Psbt,
all_funding_inputs: &[&FundingInput],
) -> Result<(), Error> {
// add witness utxo to fund_psbt for all inputs
Expand Down Expand Up @@ -344,7 +344,7 @@ where
funding_script_pubkey,
} = dlc_transactions;

let mut fund_psbt = PartiallySignedTransaction::from_unsigned_tx(fund.clone())
let mut fund_psbt = Psbt::from_unsigned_tx(fund.clone())
.map_err(|_| Error::InvalidState("Tried to create PSBT from signed tx".to_string()))?;
let mut cets = cets.clone();

Expand Down Expand Up @@ -536,7 +536,7 @@ where
&sign_msg.refund_signature,
&cet_adaptor_signatures,
&sign_msg.funding_signatures,
accepted_contract.dlc_transactions.get_fund_output().value,
accepted_contract.dlc_transactions.get_fund_output().value.to_sat(),
None,
None,
wallet,
Expand Down Expand Up @@ -595,7 +595,7 @@ where
}

let fund_tx = &accepted_contract.dlc_transactions.fund;
let mut fund_psbt = PartiallySignedTransaction::from_unsigned_tx(fund_tx.clone())
let mut fund_psbt = Psbt::from_unsigned_tx(fund_tx.clone())
.map_err(|_| Error::InvalidState("Tried to create PSBT from signed tx".to_string()))?;

// get all funding inputs
Expand Down Expand Up @@ -655,7 +655,7 @@ where
channel_id,
};

Ok((signed_contract, fund_psbt.extract_tx()))
Ok((signed_contract, fund_psbt.extract_tx()?))
}

/// Signs and return the CET that can be used to close the given contract.
Expand Down Expand Up @@ -708,7 +708,7 @@ where
.accepted_contract
.dlc_transactions
.get_fund_output()
.value,
.value.to_sat(),
)?;

Ok(cet)
Expand All @@ -726,7 +726,7 @@ where
let accepted_contract = &contract.accepted_contract;
let offered_contract = &accepted_contract.offered_contract;
let funding_script_pubkey = &accepted_contract.dlc_transactions.funding_script_pubkey;
let fund_output_value = accepted_contract.dlc_transactions.get_fund_output().value;
let fund_output_value = accepted_contract.dlc_transactions.get_fund_output().value.to_sat();
let (other_fund_pubkey, other_sig) = if offered_contract.is_offer_party {
(
&accepted_contract.accept_params.fund_pubkey,
Expand Down
2 changes: 1 addition & 1 deletion dlc-manager/src/conversion_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub fn get_tx_input_infos(
.output
.get(vout as usize)
.ok_or(Error::InvalidParameters)?;
input_amount += tx_out.value;
input_amount += tx_out.value.to_sat();
inputs.push(TxInputInfo {
outpoint: OutPoint {
txid: tx.txid(),
Expand Down
Loading

0 comments on commit 5f11673

Please sign in to comment.