Skip to content

Commit

Permalink
Merge pull request #37 from comit-network/release/0.2.0
Browse files Browse the repository at this point in the history
Release 0.2.0 - We can actually release this one!
  • Loading branch information
luckysori authored Aug 2, 2021
2 parents db553d0 + 03b76e4 commit 857ab82
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 40 deletions.
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.2.0] - 2021-07-30

### Added

- Dynamic liquidation branch to the loan protocol:
Expand All @@ -28,14 +30,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `fn liquidation_transaction()` API on `Lender1` is now `async`.
- Model the collateral contract's timelock as a `u32`.

## [0.1.1] - 2021-07-23
### Fixed

- Squashed an [elusive bug](https://github.com/comit-network/baru/issues/35) preventing users from building version `0.1.0` of this library.
This required updating `rust-elements` to version `0.18`.

## [0.1.0] - 2021-07-16

### Added

- Loan protocol and swap libraries originally developed in [Project Waves](https://github.com/comit-network/waves).

[Unreleased]: https://github.com/comit-network/baru/compare/0.1.1...HEAD
[0.1.1]: https://github.com/comit-network/baru/compare/0.1.0...0.1.1
[Unreleased]: https://github.com/comit-network/baru/compare/0.2.0...HEAD
[0.2.0]: https://github.com/comit-network/baru/compare/0.1.0...0.2.0
[0.1.0]: https://github.com/comit-network/baru/releases/tag/0.1.0
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = [ "elements-rpc" ]

[package]
name = "baru"
version = "0.1.1"
version = "0.2.0"
authors = [ "CoBloX Team <[email protected]>" ]
edition = "2018"
license-file = "LICENSE"
Expand All @@ -13,8 +13,8 @@ description = "Library to facilitate DeFi on Liquid"
anyhow = "1"
bitcoin_hashes = "0.9.0"
conquer-once = "0.3"
elements = { version = "0.17", features = [ "serde-feature" ] }
elements-miniscript = { git = "http://github.com/ElementsProject/elements-miniscript", features = [ "use-serde" ] }
elements = { version = "0.18", features = [ "serde-feature" ] }
elements-miniscript = { version = "0.1", features = [ "use-serde" ] }
env_logger = "0.8.3"
hex = "0.4"
hmac = "0.10"
Expand All @@ -29,7 +29,7 @@ sha2 = "0.9"
thiserror = "1"

[dev-dependencies]
elements-harness = { git = "https://github.com/comit-network/elements-harness" }
elements-harness = { git = "https://github.com/comit-network/elements-harness", rev = "0c28948c124d68e828e0f27c9202ba278dc04421" }
elements-rpc = { path = "./elements-rpc" }
rand_chacha = "0.1"
testcontainers = "0.12"
Expand Down
2 changes: 1 addition & 1 deletion elements-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false
[dependencies]
anyhow = "1.0"
bitcoin_hashes = "0.9.0"
elements = { version = "0.17", features = [ "serde-feature" ] }
elements = { version = "0.18", features = [ "serde-feature" ] }
jsonrpc_client = { version = "0.6", features = [ "reqwest" ] }
reqwest = "0.11"
serde = "1.0"
Expand Down
10 changes: 5 additions & 5 deletions src/loan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ impl CollateralContract {
let script = &self.raw_script;
let sighash = SigHashCache::new(&*transaction).segwitv0_sighash(
input_index as usize,
&script,
script,
input_value,
SigHashType::All,
);
Expand Down Expand Up @@ -334,10 +334,10 @@ impl CollateralContract {
let descriptor_cov = &self.descriptor.as_cov().expect("covenant descriptor");

let cov_sat = CovSatisfier::new_segwitv0(
&transaction,
transaction,
input_index,
input_value,
&cov_script,
cov_script,
SigHashType::All,
);

Expand All @@ -358,7 +358,7 @@ impl CollateralContract {
let script = &self.raw_script;
let sighash = SigHashCache::new(&*transaction).segwitv0_sighash(
input_index as usize,
&script,
script,
input_value,
SigHashType::All,
);
Expand Down Expand Up @@ -1443,7 +1443,7 @@ where
{
let sk = SecretKey::new(rng);
let pk = PublicKey::from_private_key(
&SECP256K1,
SECP256K1,
&PrivateKey {
compressed: true,
network: Network::Regtest,
Expand Down
26 changes: 13 additions & 13 deletions src/loan/protocol_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ mod tests {
let lender = lender
.interpret(
&mut rng,
&SECP256K1,
SECP256K1,
{
let client = client.clone();
|amount, asset| async move { find_inputs(&client, asset, amount).await }
Expand All @@ -133,7 +133,7 @@ mod tests {
.unwrap();
let loan_response = lender.loan_response();

let borrower = borrower.interpret(&SECP256K1, loan_response).unwrap();
let borrower = borrower.interpret(SECP256K1, loan_response).unwrap();
let loan_transaction = borrower
.sign({
let wallet = borrower_wallet.clone();
Expand All @@ -160,7 +160,7 @@ mod tests {
let loan_repayment_transaction = borrower
.loan_repayment_transaction(
&mut rng,
&SECP256K1,
SECP256K1,
{
let borrower_wallet = borrower_wallet.clone();
|amount, asset| async move { borrower_wallet.find_inputs(asset, amount).await }
Expand Down Expand Up @@ -277,7 +277,7 @@ mod tests {
let lender = lender
.interpret(
&mut rng,
&SECP256K1,
SECP256K1,
{
let client = client.clone();
|amount, asset| async move { find_inputs(&client, asset, amount).await }
Expand All @@ -289,7 +289,7 @@ mod tests {
.unwrap();
let loan_response = lender.loan_response();

let borrower = borrower.interpret(&SECP256K1, loan_response).unwrap();
let borrower = borrower.interpret(SECP256K1, loan_response).unwrap();
let loan_transaction = borrower
.sign(|transaction| async move { Ok(borrower_wallet.sign_all_inputs(transaction)) })
.await
Expand All @@ -309,7 +309,7 @@ mod tests {
.unwrap();

let liquidation_transaction = lender
.liquidation_transaction(&mut rng, &SECP256K1, Amount::from_sat(1))
.liquidation_transaction(&mut rng, SECP256K1, Amount::from_sat(1))
.await
.unwrap();

Expand Down Expand Up @@ -426,7 +426,7 @@ mod tests {
let lender = lender
.interpret(
&mut rng,
&SECP256K1,
SECP256K1,
{
let client = client.clone();
|amount, asset| async move { find_inputs(&client, asset, amount).await }
Expand All @@ -438,7 +438,7 @@ mod tests {
.unwrap();
let loan_response = lender.loan_response();

let borrower = borrower.interpret(&SECP256K1, loan_response).unwrap();
let borrower = borrower.interpret(SECP256K1, loan_response).unwrap();
let loan_transaction = borrower
.sign(|transaction| async move { Ok(borrower_wallet.sign_all_inputs(transaction)) })
.await
Expand Down Expand Up @@ -474,7 +474,7 @@ mod tests {
let liquidation_transaction = lender
.dynamic_liquidation_transaction(
&mut rng,
&SECP256K1,
SECP256K1,
oracle_msg,
oracle_sig,
Amount::ONE_SAT,
Expand Down Expand Up @@ -505,7 +505,7 @@ mod tests {
let liquidation_transaction = lender
.dynamic_liquidation_transaction(
&mut rng,
&SECP256K1,
SECP256K1,
oracle_msg,
oracle_sig,
Amount::ONE_SAT,
Expand Down Expand Up @@ -539,7 +539,7 @@ mod tests {
let liquidation_transaction = lender
.dynamic_liquidation_transaction(
&mut rng,
&SECP256K1,
SECP256K1,
oracle_msg,
oracle_sig,
Amount::ONE_SAT,
Expand Down Expand Up @@ -570,7 +570,7 @@ mod tests {
let liquidation_transaction = lender
.dynamic_liquidation_transaction(
&mut rng,
&SECP256K1,
SECP256K1,
oracle_msg,
oracle_sig,
Amount::ONE_SAT,
Expand Down Expand Up @@ -789,7 +789,7 @@ mod tests {
{
let sk = SecretKey::new(rng);
let pk = PublicKey::from_private_key(
&SECP256K1,
SECP256K1,
&PrivateKey {
compressed: true,
network: Network::Regtest,
Expand Down
14 changes: 7 additions & 7 deletions src/swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ where
let (receive_output_alice, abf_receive_alice, vbf_receive_alice) =
TxOut::new_not_last_confidential(
rng,
&secp,
secp,
alice.receive_amount.as_sat(),
alice.address.clone(),
alice.receive_asset,
&inputs_not_last_confidential.as_slice(),
inputs_not_last_confidential.as_slice(),
)?;

let (redeem_output_bob, abf_receive_bob, vbf_receive_bob) = TxOut::new_not_last_confidential(
rng,
&secp,
secp,
bob.receive_amount.as_sat(),
bob.address.clone(),
bob.receive_asset,
Expand All @@ -82,7 +82,7 @@ where
let (change_output_alice, abf_change_alice, vbf_change_alice) =
TxOut::new_not_last_confidential(
rng,
&secp,
secp,
change_amount_alice.as_sat(),
alice.address.clone(),
bob.receive_asset,
Expand Down Expand Up @@ -112,7 +112,7 @@ where

let (change_output_bob, _, _) = TxOut::new_last_confidential(
rng,
&secp,
secp,
change_amount_bob.as_sat(),
bob.address,
alice.receive_asset,
Expand Down Expand Up @@ -176,7 +176,7 @@ pub fn sign_with_key<C>(
where
C: Signing,
{
let input_pk = PublicKey::from_secret_key(&secp, &input_sk);
let input_pk = PublicKey::from_secret_key(secp, input_sk);

let hash = hash160::Hash::hash(&input_pk.serialize());
let script = Builder::new()
Expand All @@ -189,7 +189,7 @@ where

let sighash = cache.segwitv0_sighash(index, &script, value, SigHashType::All);

let sig = secp.sign(&Message::from(sighash), &input_sk);
let sig = secp.sign(&Message::from(sighash), input_sk);

let mut serialized_signature = sig.serialize_der().to_vec();
serialized_signature.push(SigHashType::All as u8);
Expand Down
14 changes: 7 additions & 7 deletions tests/swap_happy_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async fn collaborative_create_and_sign() {
.unwrap();

let alice = Actor::new(
&SECP256K1,
SECP256K1,
vec![Input {
txin: input_alice.0,
original_txout: input_alice.1.clone(),
Expand All @@ -100,7 +100,7 @@ async fn collaborative_create_and_sign() {
.unwrap();

let bob = Actor::new(
&SECP256K1,
SECP256K1,
vec![Input {
txin: input_bob.0,
original_txout: input_bob.1.clone(),
Expand Down Expand Up @@ -129,7 +129,7 @@ async fn collaborative_create_and_sign() {
.context("transaction does not contain input")?;

tx.input[input_index_1].witness.script_witness = sign_with_key(
&SECP256K1,
SECP256K1,
&mut SigHashCache::new(&tx),
input_index_1,
&fund_sk_bob,
Expand All @@ -153,7 +153,7 @@ async fn collaborative_create_and_sign() {
.context("transaction does not contain input")?;

tx.input[input_index].witness.script_witness = sign_with_key(
&SECP256K1,
SECP256K1,
&mut SigHashCache::new(&tx),
input_index,
&fund_sk_alice,
Expand Down Expand Up @@ -213,7 +213,7 @@ async fn move_output_to_wallet(
let asset_id = previous_output_secrets.asset;
let (output, _, _) = TxOut::new_last_confidential(
&mut thread_rng(),
&SECP256K1,
SECP256K1,
amount_out.as_sat(),
move_address,
asset_id,
Expand All @@ -231,7 +231,7 @@ async fn move_output_to_wallet(
};

let previous_output_pk = PublicKey::from_private_key(
&SECP256K1,
SECP256K1,
&PrivateKey {
compressed: true,
network: Network::Regtest,
Expand Down Expand Up @@ -288,7 +288,7 @@ fn extract_input(tx: &Transaction, address: Address) -> Result<(OutPoint, TxOut)
fn make_keypair() -> (SecretKey, PublicKey) {
let sk = SecretKey::new(&mut thread_rng());
let pk = PublicKey::from_private_key(
&SECP256K1,
SECP256K1,
&PrivateKey {
compressed: true,
network: Network::Regtest,
Expand Down

0 comments on commit 857ab82

Please sign in to comment.