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

Add wallet #59

Merged
merged 1 commit into from
Aug 12, 2021
Merged
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Wallet which allows users to select coins through a backend configured by them via the `GetUtxos` trait.
The provided wallet comes with a UTXO cache which this is updated using `Wallet::sync`.
This allows users of the library to optimise the number of requests to their backend.
Users can also sign said UTXOs by calling `Wallet::sign`.

### Changed

- The borrower can now choose the collateral inputs before calling `Borrower0::new`.

### Fixed

- The loan transaction no longer expects collateral and principal change outputs.
Expand Down
12 changes: 11 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,29 @@ license-file = "LICENSE"
description = "Library to facilitate DeFi on Liquid"

[dependencies]
aes-gcm-siv = { version = "0.9", features = ["std"] }
anyhow = "1"
async-trait = "0.1"
bdk = { version = "0.4", default-features = false }
bip32 = { version = "0.2", features = ["secp256k1-ffi", "bip39"], default-features = false }
conquer-once = "0.3"
elements = { version = "0.18", features = ["serde-feature"] }
elements-miniscript = { version = "0.1", features = ["use-serde"] }
futures = "0.3"
hex = "0.4"
hkdf = { version = "0.10", features = ["std"] }
itertools = "0.10"
log = "0.4"
rand = "0.6"
rand = { version = "0.6", features = ["wasm-bindgen"] }
reqwest = { version = "0.11", default-features = false, features = ["rustls", "json"] }
rust_decimal = "1"
serde = { version = "1", features = ["derive"] }
sha2 = "0.9"
thiserror = "1"

[dev-dependencies]
elements-consensus = { git = "https://github.com/comit-network/rust-elements-consensus", rev = "ac88dbedcd019eef44f58499417dcdbeda994b0b" }
link-cplusplus = "1"
rand_chacha = "0.1"
serde_json = "1"
tokio = { version = "1", default-features = false, features = ["macros", "rt"] }
17 changes: 17 additions & 0 deletions src/avg_vbytes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//! These constants have been reverse engineered through the following transactions:
//!
//! https://blockstream.info/liquid/tx/a17f4063b3a5fdf46a7012c82390a337e9a0f921933dccfb8a40241b828702f2
//! https://blockstream.info/liquid/tx/d12ff4e851816908810c7abc839dd5da2c54ad24b4b52800187bee47df96dd5c
//! https://blockstream.info/liquid/tx/47e60a3bc5beed45a2cf9fb7a8d8969bab4121df98b0034fb0d44f6ed2d60c7d
//!
//! This gives us the following set of linear equations:
//!
//! - 1 in, 1 out, 1 fee = 1332
//! - 1 in, 2 out, 1 fee = 2516
//! - 2 in, 2 out, 1 fee = 2623
//!
//! Which we can solve using wolfram alpha: https://www.wolframalpha.com/input/?i=1x+%2B+1y+%2B+1z+%3D+1332%2C+1x+%2B+2y+%2B+1z+%3D+2516%2C+2x+%2B+2y+%2B+1z+%3D+2623
//!
pub const INPUT: u64 = 107;
pub const OUTPUT: u64 = 1184;
pub const FEE: u64 = 41;
Loading