Skip to content

Commit 65e7eb2

Browse files
authored
Input validation (#37)
* validate npub * validate txid * validate address * validate nsec * validate Amount * validate fee rate * validate transaction * validate signature * validate timelock * validate esplora * tailwind * persistent default endpoint * always make sure that the escrow type is valid * better lints and remove unused serde * bump version to 0.2.0 * ci: add dependabot
1 parent ab57822 commit 65e7eb2

File tree

9 files changed

+483
-85
lines changed

9 files changed

+483
-85
lines changed

.github/dependabot.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"
7+
- package-ecosystem: "cargo"
8+
directory: "/"
9+
schedule:
10+
interval: "monthly"

Cargo.lock

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "scrow"
3-
version = "0.1.1"
3+
version = "0.2.0"
44
edition = "2024"
55
authors = [
66
"Jose Storopoli <[email protected]>",
@@ -20,7 +20,6 @@ bitcoin = { version = "0.32.5", default-features = false, features = [
2020
] }
2121
secp256k1 = { version = "0.29.0", features = ["global-context"] }
2222
nostr = "0.39.0"
23-
serde = { version = "1.0.218", features = ["derive"] }
2423
thiserror = "2.0.11"
2524
esplora-client = { version = "0.11.0", default-features = false, features = [
2625
"tokio",
@@ -48,8 +47,15 @@ web = ["dioxus/web"]
4847
desktop = ["dioxus/desktop"]
4948
mobile = ["dioxus/mobile"]
5049

51-
[lints.rust]
52-
unsafe_code = "forbid" # Forbid unsafe code
50+
[lints]
51+
rust.missing_debug_implementations = "warn"
52+
rust.rust_2018_idioms = { level = "deny", priority = -1 }
53+
rust.unreachable_pub = "warn"
54+
rust.unused_crate_dependencies = "deny"
55+
rust.unused_must_use = "deny"
56+
rust.unsafe_code = "forbid"
57+
rust.missing_docs = "warn"
58+
rustdoc.all = "warn"
5359

5460
[profile.release]
5561
opt-level = "z" # Optimized for size, use 3 for speed

assets/tailwind.css

+28-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/broadcast.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Broadcast escrow transaction component.
22
3-
use bitcoin::hex::prelude::*;
43
use bitcoin::{Transaction, consensus};
54
use dioxus::prelude::*;
65

@@ -51,8 +50,8 @@ pub(crate) fn Broadcast() -> Element {
5150
#[cfg(debug_assertions)]
5251
info!(% ESPLORA_ENDPOINT, "Created esplora client");
5352
let esplora_client = create_client(&ESPLORA_ENDPOINT.read()).unwrap();
54-
let signed_tx: Transaction = consensus::deserialize(
55-
Vec::from_hex(&signed_tx.read()).unwrap().as_ref(),
53+
let signed_tx: Transaction = consensus::encode::deserialize_hex(
54+
&signed_tx.read(),
5655
)
5756
.unwrap();
5857
let txid = signed_tx.compute_txid();

src/components/combine.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Combine escrow signatures component.
22
3-
use bitcoin::hex::prelude::*;
43
use bitcoin::{Transaction, consensus, hex::DisplayHex};
54
use dioxus::prelude::*;
65

@@ -122,8 +121,8 @@ pub(crate) fn Combine() -> Element {
122121
let npub_buyer = parse_npub(&npub_buyer.read()).unwrap();
123122
let npub_seller = parse_npub(&npub_seller.read()).unwrap();
124123
let escrow_type = parse_escrow_type(&escrow_type.read()).unwrap();
125-
let unsigned_tx: Transaction = consensus::deserialize(
126-
Vec::from_hex(&unsigned_tx.read()).unwrap().as_ref(),
124+
let unsigned_tx: Transaction = consensus::encode::deserialize_hex(
125+
&unsigned_tx.read(),
127126
)
128127
.unwrap();
129128
let signatures: Vec<schnorr::Signature> = vec![

0 commit comments

Comments
 (0)