From 8c85236c896c5499a680e054fc3acfe91446d51f Mon Sep 17 00:00:00 2001 From: LLFourn Date: Wed, 20 Dec 2023 10:14:54 +1100 Subject: [PATCH] [ci] Add github actions --- .github/workflows/test.yml | 54 ++++++++++++++++++++++++++++++++++++++ README.md | 3 +++ src/coin_selector.rs | 9 +++---- 3 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e60b639 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,54 @@ +on: + push: + branches: + - master + pull_request: + + +# Make sure CI fails on all warnings, including Clippy lints +env: + RUSTFLAGS: "-Dwarnings" + RUSTDOCFLAGS: "-Dwarnings" + +jobs: + fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - run: cargo fmt --all -- --check + + clippy_check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - uses: Swatinem/rust-cache@v2 + - run: cargo clippy --all-targets --all-features --tests + + build-msrv: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.54.0 + - run: cargo build --release + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - run: cargo test --release + + doc-build: + name: doc-build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - run: cargo doc --no-deps diff --git a/README.md b/README.md index dd84d57..048a0cd 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,9 @@ `bdk_coin_select` is a tool to help you select inputs for making Bitcoin (ticker: BTC) transactions. It's got zero dependencies so you can paste it into your project without concern. +> ⚠ This work is only ready to use by those who expect (potentially catastrophic) bugs and will have +> the time to investigate them and contribute back to this crate. + ## Constructing the `CoinSelector` The main structure is [`CoinSelector`](crate::CoinSelector). To construct it, we specify a list of diff --git a/src/coin_selector.rs b/src/coin_selector.rs index 4a0e2b3..0d42a56 100644 --- a/src/coin_selector.rs +++ b/src/coin_selector.rs @@ -625,9 +625,9 @@ impl Candidate { } } -/// A structure that represents the weight costs of a drain (a.k.a. change) output. +/// Represents the weight costs of a drain (a.k.a. change) output. /// -/// This structure can also represent multiple outputs. +/// May also represent multiple outputs. #[derive(Default, Debug, Clone, Copy, Hash, PartialEq, Eq)] pub struct DrainWeights { /// The weight of including this drain output. @@ -659,9 +659,8 @@ impl DrainWeights { /// A drain (A.K.A. change) output. /// Technically it could represent multiple outputs. /// -/// These are usually created by a [`change_policy`]. -/// -/// [`change_policy`]: crate::change_policy +/// This is returned from [`CoinSelector::drain`]. Note if `drain` returns a drain where `is_none()` +/// returns true then **no change should be added** to the transaction. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Default)] pub struct Drain { /// Weight of adding drain output and spending the drain output.