Skip to content
This repository has been archived by the owner on Feb 3, 2025. It is now read-only.

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
exclude mutiny-server from workspace
Browse files Browse the repository at this point in the history
elnosh committed Apr 4, 2024
1 parent 1a7ccef commit 21e13b1
Showing 7 changed files with 5,256 additions and 529 deletions.
40 changes: 36 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -34,10 +34,7 @@ jobs:
cargo +nightly-2023-10-24 fmt -- --check
- name: Check docs
run: cargo +nightly-2023-10-24 doc --exclude mutiny-server --workspace

- name: Check docs server
run: cargo +nightly-2023-10-24 doc --target x86_64-unknown-linux-gnu -p mutiny-server
run: cargo +nightly-2023-10-24 doc

website:
name: Build WASM binary
@@ -288,3 +285,38 @@ jobs:

- name: Run cargo build
run: cargo build --all-features --package mutiny-core --target=${{ matrix.target }}

check_formatting-server:
name: Check Formatting mutiny-server
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v3

- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-${{ runner.os }}-formatting-v2-${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }}
restore-keys: |
cargo-${{ runner.os }}-formatting-v2-
cargo-${{ runner.os }}-
- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2023-10-24
components: rustfmt
profile: minimal

- name: Check formatting
run: |
cd mutiny-server && cargo +nightly-2023-10-24 fmt -- --check
- name: Check docs
run: cd mutiny-server && cargo +nightly-2023-10-24 doc --target x86_64-unknown-linux-gnu

- name: Run cargo clippy
run: cd mutiny-server && cargo clippy --all-features --tests --target=x86_64-unknown-linux-gnu -- -D warnings
504 changes: 12 additions & 492 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -3,10 +3,11 @@ resolver = "2"

members = [
"mutiny-core",
"mutiny-server",
"mutiny-wasm",
]

exclude = ["mutiny-server"]


# Tell `rustc` to optimize for small code size.
[profile.release.package.mutiny-core]
5,182 changes: 5,182 additions & 0 deletions mutiny-server/Cargo.lock

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion mutiny-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -23,4 +23,7 @@ futures-util = { version = "0.3", default-features = false }
sled = "0.34.7"
tokio = { version = "1.36.0", features = ["full"] }
reqwest = { version = "0.11", features = ["json"] }
serde = { version = "1.0.196", features = ["derive"] }
serde = { version = "1.0.196", features = ["derive"] }

[patch.crates-io]
lightning = { git = 'https://github.com/MutinyWallet/rust-lightning.git', rev = "e82635b32458a77d28a5a23b664696422eb526e4" }
49 changes: 19 additions & 30 deletions mutiny-server/src/routes.rs
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ pub async fn new_address(
.mutiny_wallet
.node_manager
.get_new_address(vec![])
.map_err(|e| handle_mutiny_err(e))?;
.map_err(handle_mutiny_err)?;
Ok(Json(json!(address)))
}

@@ -67,7 +67,7 @@ pub async fn send_to_address(
request.fee_rate_sat_byte,
)
.await
.map_err(|e| handle_mutiny_err(e))?;
.map_err(handle_mutiny_err)?;

Ok(Json(json!(tx_id.to_string())))
}
@@ -102,7 +102,7 @@ pub async fn open_channel(
.node_manager
.open_channel(None, to_pubkey, request.amount_sat, request.fee_rate, None)
.await
.map_err(|e| handle_mutiny_err(e))?;
.map_err(handle_mutiny_err)?;
Ok(Json(json!(channel)))
}

@@ -122,7 +122,7 @@ pub async fn close_channel(
.node_manager
.list_channels()
.await
.map_err(|e| handle_mutiny_err(e))?;
.map_err(handle_mutiny_err)?;

let outpoint = match channels
.into_iter()
@@ -167,12 +167,12 @@ pub async fn close_channel(
None => None,
};

let _ = state
state
.mutiny_wallet
.node_manager
.close_channel(&outpoint, address, false, false)
.await
.map_err(|e| handle_mutiny_err(e))?;
.map_err(handle_mutiny_err)?;

Ok(Json(json!("ok")))
}
@@ -205,7 +205,7 @@ pub async fn create_invoice(
.mutiny_wallet
.create_invoice(request.amount_sat, label)
.await
.map_err(|e| handle_mutiny_err(e))?;
.map_err(handle_mutiny_err)?;

let amount_sat = invoice.amount_sats.ok_or((
StatusCode::INTERNAL_SERVER_ERROR,
@@ -250,7 +250,7 @@ pub async fn pay_invoice(
.mutiny_wallet
.pay_invoice(&request.invoice, request.amount_sat, Vec::new())
.await
.map_err(|e| handle_mutiny_err(e))?;
.map_err(handle_mutiny_err)?;

let amount_sat = invoice.amount_sats.ok_or((
StatusCode::INTERNAL_SERVER_ERROR,
@@ -296,7 +296,7 @@ pub async fn get_incoming_payments(
let invoices = state
.mutiny_wallet
.list_invoices()
.map_err(|e| handle_mutiny_err(e))?;
.map_err(handle_mutiny_err)?;

let invoices: Vec<MutinyInvoice> = invoices
.into_iter()
@@ -305,11 +305,7 @@ pub async fn get_incoming_payments(

let mut payments = Vec::with_capacity(invoices.len());
for invoice in invoices.into_iter() {
let pr = match invoice.bolt11.clone() {
Some(bolt_11) => Some(bolt_11.to_string()),
None => None,
};

let pr = invoice.bolt11.as_ref().map(|bolt11| bolt11.to_string());
let (is_paid, amount_sats, fees) = get_payment_info(&invoice)?;

let payment = PaymentResponse {
@@ -343,12 +339,9 @@ pub async fn get_payment(
.mutiny_wallet
.get_invoice_by_hash(&hash)
.await
.map_err(|e| handle_mutiny_err(e))?;
.map_err(handle_mutiny_err)?;

let pr = match invoice.bolt11.clone() {
Some(bolt11) => Some(bolt11.to_string()),
None => None,
};
let pr = invoice.bolt11.as_ref().map(|bolt11| bolt11.to_string());
let (is_paid, amount_sats, fees) = get_payment_info(&invoice)?;

let payment = PaymentResponse {
@@ -372,7 +365,7 @@ pub async fn get_balance(
.mutiny_wallet
.get_balance()
.await
.map_err(|e| handle_mutiny_err(e))?;
.map_err(handle_mutiny_err)?;
Ok(Json(json!(balance)))
}

@@ -416,24 +409,23 @@ pub async fn get_node_info(
.node_manager
.list_nodes()
.await
.map_err(|e| handle_mutiny_err(e))?;
.map_err(handle_mutiny_err)?;

let node_pubkey: PublicKey;
if !nodes.is_empty() {
node_pubkey = nodes[0];
let node_pubkey: PublicKey = if !nodes.is_empty() {
nodes[0]
} else {
return Err((
StatusCode::INTERNAL_SERVER_ERROR,
Json(json!({"error": "unable to get node info"})),
));
}
};

let channels = state
.mutiny_wallet
.node_manager
.list_channels()
.await
.map_err(|e| handle_mutiny_err(e))?;
.map_err(handle_mutiny_err)?;

let channels = channels
.into_iter()
@@ -443,10 +435,7 @@ pub async fn get_node_info(
false => ChannelState::Unusable,
};

let funding_tx_id = match channel.outpoint {
Some(outpoint) => Some(outpoint.txid.to_string()),
None => None,
};
let funding_tx_id = channel.outpoint.map(|outpoint| outpoint.txid.to_string());

Channel {
state: state.to_string(),
2 changes: 1 addition & 1 deletion mutiny-server/src/sled.rs
Original file line number Diff line number Diff line change
@@ -141,7 +141,7 @@ impl MutinyStorage for SledStorage {
.iter()
.keys()
.filter_map(|key| key.ok())
.map(|key| ivec_to_string(key))
.map(ivec_to_string)
.filter_map(Result::ok)
.filter(|key| {
key.starts_with(prefix) && (suffix.is_none() || key.ends_with(suffix.unwrap()))

0 comments on commit 21e13b1

Please sign in to comment.