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

KVAC Mint and Wallet #619

Draft
wants to merge 91 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
261a024
kvac keyset
lollerfirst Jan 15, 2025
e93d55a
keysets pt.2
lollerfirst Jan 15, 2025
99b411c
migrations
lollerfirst Jan 15, 2025
9c53bdd
migrations pt2
lollerfirst Jan 15, 2025
8638835
bootstrap
lollerfirst Jan 15, 2025
4ef7f18
separate keysets and keyset methods
lollerfirst Jan 16, 2025
0ee7d66
migration fix
lollerfirst Jan 16, 2025
2d0604a
remove max order from kvac keyset creation
lollerfirst Jan 16, 2025
0b18726
keyset responses
lollerfirst Jan 16, 2025
633de5e
bootstrap request
lollerfirst Jan 16, 2025
79fc2ab
missing doc
lollerfirst Jan 16, 2025
c9c60b5
inputs -> outputs
lollerfirst Jan 17, 2025
fe81c11
fix typo
lollerfirst Jan 17, 2025
cb45798
update cashu-kvac
lollerfirst Jan 17, 2025
24a07fa
fix dependencies
lollerfirst Jan 17, 2025
264aff1
wallet kvac keysets
lollerfirst Jan 17, 2025
726de71
cdk-redb cdk-rexie add missing WalletDb trait methods
lollerfirst Jan 18, 2025
0252b9f
default trait implementations
lollerfirst Jan 18, 2025
ca79ff9
fix botched migration
lollerfirst Jan 18, 2025
8f01d84
more bootstrap related changes
lollerfirst Jan 18, 2025
70974ca
complete bootstrap logic
lollerfirst Jan 19, 2025
3ae0cbb
default impl for unimplemented kvac traits
lollerfirst Jan 19, 2025
28e82a3
working bootstrap request
lollerfirst Jan 19, 2025
81b6881
update cashu-kvac + script should be a String
lollerfirst Jan 19, 2025
44d0bbc
bump cashu-kvac
lollerfirst Jan 19, 2025
707cdd6
remove dummy kvac methods implementations from redb crate
lollerfirst Jan 19, 2025
7b66a87
start swap impl
lollerfirst Jan 24, 2025
42cc0e8
mint swap complete
lollerfirst Jan 25, 2025
3182975
swap request and database methods
lollerfirst Jan 25, 2025
d47473d
connect to route handler
lollerfirst Jan 25, 2025
46e6371
fixes
lollerfirst Jan 25, 2025
00dc54a
implement add_kvac_issued_macs
lollerfirst Jan 25, 2025
feed058
wallet swap
lollerfirst Jan 26, 2025
747acf5
clearer comments
lollerfirst Jan 26, 2025
c8bc9e4
kvac send wallet side
lollerfirst Jan 29, 2025
50a6912
fixes
lollerfirst Jan 29, 2025
82cc0d6
working ✅
lollerfirst Jan 30, 2025
d282021
cashu-kvac version bump
lollerfirst Feb 1, 2025
0f99a44
bump cashu-kvac
lollerfirst Feb 1, 2025
8d85b05
change tracing output for `process_kvac_swap_request` + cargo fmt
lollerfirst Feb 1, 2025
8e5fbf1
Merge remote-tracking branch 'upstream/main' into cdk-kvac
lollerfirst Feb 4, 2025
7bc4fef
post merge fixups
lollerfirst Feb 4, 2025
852bccc
kvac mint request + unified kvac verification
lollerfirst Feb 4, 2025
f46e4ab
wallet mint request ✅
lollerfirst Feb 5, 2025
187b193
make example interesting
lollerfirst Feb 5, 2025
8ec761b
kvac melt request
lollerfirst Feb 5, 2025
ac01c1b
fix route
lollerfirst Feb 5, 2025
50d2ecc
fix utoipa paths reques types
lollerfirst Feb 5, 2025
15fb341
wallet melt working ✅
lollerfirst Feb 5, 2025
0fba4c6
update kvac wallet example
lollerfirst Feb 5, 2025
970ad5f
bump cashu-kvac
lollerfirst Feb 6, 2025
d6afff3
update melt fee return tweaking
lollerfirst Feb 6, 2025
11712e0
Merge remote-tracking branch 'upstream/main' into cdk-kvac
lollerfirst Feb 10, 2025
20e707b
fix error code
lollerfirst Feb 11, 2025
2735526
Merge remote-tracking branch 'upstream/main' into cdk-kvac
lollerfirst Feb 18, 2025
08b545c
bump cashu-kvac
lollerfirst Feb 18, 2025
6babe65
adjust verification process
lollerfirst Feb 18, 2025
4608593
kvac restore + cargo fmt
lollerfirst Feb 22, 2025
7ce9925
checkstate
lollerfirst Feb 23, 2025
5fa5913
comment out restore.rs
lollerfirst Feb 24, 2025
61d070e
Merge remote-tracking branch 'upstream/main' into cdk-kvac
lollerfirst Feb 25, 2025
835fced
Merge remote-tracking branch 'upstream/main' into cdk-kvac
lollerfirst Feb 25, 2025
e99faed
post-merge fix
lollerfirst Feb 25, 2025
4e9b553
wallet checkstate
lollerfirst Feb 25, 2025
63a7ab9
cargo fmt
lollerfirst Feb 25, 2025
56946bc
wallet restore
lollerfirst Feb 26, 2025
8a6cc8e
cargo fmt
lollerfirst Feb 26, 2025
60c4286
test restore with example
lollerfirst Feb 26, 2025
9cfec5c
wallet restore + state checks + fix bug not committing tx in db
lollerfirst Feb 27, 2025
8725cc5
simply import
lollerfirst Feb 27, 2025
2730f53
cargo fmt
lollerfirst Feb 27, 2025
dd6ab0f
clippy pt.1
lollerfirst Feb 27, 2025
39a2561
cargo clippy pt.2
lollerfirst Feb 27, 2025
e5e1d64
rename kvac wallet example
lollerfirst Feb 27, 2025
fc69140
receive into wallet
lollerfirst Feb 28, 2025
95b8397
receive exaple
lollerfirst Mar 1, 2025
a43784e
correctly reset nullifiers states after failed spent check
lollerfirst Mar 3, 2025
5e9b886
dedicated verification module
lollerfirst Mar 3, 2025
644a070
break down and isolate verification steps
lollerfirst Mar 3, 2025
f760624
cargo fmt
lollerfirst Mar 3, 2025
3757caf
cargo +nightly fmt
lollerfirst Mar 3, 2025
26f9f3e
cargo clippy
lollerfirst Mar 3, 2025
2a22bc3
fix
lollerfirst Mar 3, 2025
cbeb3ca
mod issuance
lollerfirst Mar 3, 2025
14f2e2e
isolate kvac errors
lollerfirst Mar 4, 2025
3634b9d
fix keyset id generation
lollerfirst Mar 4, 2025
d3c12af
update cargo.toml s gated kvac feature
lollerfirst Mar 4, 2025
a41e094
gate all kvac stuff behind "kvac" feature
lollerfirst Mar 4, 2025
d6e5fe4
clarification comments
lollerfirst Mar 4, 2025
1346944
fix comment
lollerfirst Mar 4, 2025
41f6006
apply `kvac` feature to v2 kvac router
lollerfirst Mar 4, 2025
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
4 changes: 3 additions & 1 deletion crates/cashu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ rust-version = "1.63.0"
license = "MIT"

[features]
default = ["mint", "wallet"]
default = ["mint", "wallet", "kvac"]
swagger = ["dep:utoipa"]
mint = ["dep:uuid"]
wallet = []
bench = []
kvac = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To include the KVAC dependency cashu_kvac only when the kvac feature is enabled, you'd have to do two things:

First, specify the kvac feature should pull in the dependency:

Suggested change
kvac = []
kvac = [dep:cashu_kvac]

Second, add an optional = true to the cashu_kvac dependency below, similar for example to utoipa. This will mean the dependency should not be included, unless an activated feature explicitly needs it.


[dependencies]
uuid = { version = "=1.12.1", features = ["v4", "serde"], optional = true }
Expand All @@ -35,6 +36,7 @@ url = "2.3"
utoipa = { version = "4", optional = true }
serde_json = "1"
serde_with = "3"
cashu_kvac = { git = "https://github.com/lollerfirst/cashu-kvac.git", rev = "03bcca4997f310b4e2e1b8a3b22cf444faa41e6a" }

[target.'cfg(target_arch = "wasm32")'.dependencies]
instant = { version = "0.1", features = ["wasm-bindgen", "inaccurate"] }
Expand Down
14 changes: 13 additions & 1 deletion crates/cashu/src/amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub enum Error {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
#[cfg_attr(feature = "swagger", derive(utoipa::ToSchema))]
#[serde(transparent)]
pub struct Amount(u64);
pub struct Amount(pub u64);

impl FromStr for Amount {
type Err = Error;
Expand Down Expand Up @@ -180,6 +180,18 @@ impl From<Amount> for u64 {
}
}

impl TryFrom<Amount> for i64 {
type Error = Error;

fn try_from(value: Amount) -> Result<Self, Error> {
if value.0 < (i64::MAX as u64) {
Ok(value.0 as i64)
} else {
Err(Error::AmountOverflow)
}
}
}

impl AsRef<u64> for Amount {
fn as_ref(&self) -> &u64 {
&self.0
Expand Down
Loading
Loading