-
Notifications
You must be signed in to change notification settings - Fork 57
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
Prepared Send #596
Open
davidcaseria
wants to merge
44
commits into
cashubtc:main
Choose a base branch
from
davidcaseria:prepared-send
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,068
−434
Open
Prepared Send #596
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
39c40bd
select_proofs_v2
davidcaseria 7668b25
select_proofs_v2 fix ups
davidcaseria d9365f3
select_proofs_v2 edge case tests
davidcaseria 10a150f
select_proofs_v2 fix over test
davidcaseria 1fa02aa
Merge remote-tracking branch 'origin/proof-select-v2' into prepared-send
davidcaseria 68caa7c
Prepared send
davidcaseria d26c7b6
Fix swap amount
davidcaseria e1f5cdb
WIP
davidcaseria 9b26914
Try fix
davidcaseria 7c75483
Fix loop range modification bug
davidcaseria 7a50e25
Maybe this works
davidcaseria 0d2925f
Fix split_with_fee
davidcaseria e6820b8
Refactor to pre-compute send_fee
davidcaseria 6d82e22
Fix clippy errors
davidcaseria f9d18d1
Add more comments
davidcaseria 878e9a9
Use new proof selection algorithm
davidcaseria a999c5b
Remove empty file
davidcaseria d99e140
Export PreparedSend struct
davidcaseria ab29654
Include total fee in prepared send
davidcaseria 333741f
Fix swap amount
davidcaseria f51eabd
Fix swap amount
davidcaseria 6bcb512
erge branch 'main' into prepared-send
davidcaseria fba73c3
Fix swap for including fees
davidcaseria a538e45
Finally fix fees
davidcaseria 5dc9e31
Fix returned swap amount
davidcaseria 781797e
Actually fix fees
davidcaseria 3fbc522
Handle exact amounts
davidcaseria 7b2bdd0
DRY ProofsMethods
davidcaseria ff0778b
Ensure proofs are sorted before selecting least amount over
davidcaseria 09e0af0
Allow memo to be set a time of send
davidcaseria 92d3b58
Create SendMemo to use in SendOptions
davidcaseria 67e33e7
Fix clippy
davidcaseria 0037705
Fix fmt
davidcaseria b5514ea
Update crates/cdk/src/wallet/send.rs
davidcaseria 2ef0155
Update crates/cdk/src/wallet/send.rs
davidcaseria 5eb67a6
Update crates/cdk/src/wallet/keysets.rs
davidcaseria abdee5d
Address PR feedback
davidcaseria a26ba5c
Fix clippy
davidcaseria fc559a8
Merge remote-tracking branch 'upstream/main' into prepared-send
davidcaseria 9cb7ac7
Fix doc to use no_compile
davidcaseria a19626c
Merge remote-tracking branch 'upstream/main' into prepared-send
davidcaseria 6f4d6e3
Merge remote-tracking branch 'upstream/main' into prepared-send
davidcaseria f1ccbe9
Add sqlite migration for new proof state
davidcaseria 2fca71a
Change initial migration
davidcaseria File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,14 +84,6 @@ pub trait Database: Debug { | |
added: Vec<ProofInfo>, | ||
removed_ys: Vec<PublicKey>, | ||
) -> Result<(), Self::Err>; | ||
/// Set proofs as pending in storage. Proofs are identified by their Y | ||
/// value. | ||
async fn set_pending_proofs(&self, ys: Vec<PublicKey>) -> Result<(), Self::Err>; | ||
/// Reserve proofs in storage. Proofs are identified by their Y value. | ||
async fn reserve_proofs(&self, ys: Vec<PublicKey>) -> Result<(), Self::Err>; | ||
/// Set proofs as unspent in storage. Proofs are identified by their Y | ||
/// value. | ||
async fn set_unspent_proofs(&self, ys: Vec<PublicKey>) -> Result<(), Self::Err>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe instead of removing the 3 methods, we can keep a default implementation in the trait? /// Set proofs as pending in storage. Proofs are identified by their Y
/// value.
async fn set_pending_proofs(&self, ys: Vec<PublicKey>) -> Result<(), Self::Err> {
self.update_proofs_state(ys, State::Pending).await
}
/// Reserve proofs in storage. Proofs are identified by their Y value.
async fn reserve_proofs(&self, ys: Vec<PublicKey>) -> Result<(), Self::Err> {
self.update_proofs_state(ys, State::Reserved).await
}
/// Set proofs as unspent in storage. Proofs are identified by their Y
/// value.
async fn set_unspent_proofs(&self, ys: Vec<PublicKey>) -> Result<(), Self::Err> {
self.update_proofs_state(ys, State::Unspent).await
} This would avoid the need for wallet DBs to re-implement them (as it's done in |
||
/// Get proofs from storage | ||
async fn get_proofs( | ||
&self, | ||
|
@@ -100,6 +92,8 @@ pub trait Database: Debug { | |
state: Option<Vec<State>>, | ||
spending_conditions: Option<Vec<SpendingConditions>>, | ||
) -> Result<Vec<ProofInfo>, Self::Err>; | ||
/// Update proofs state in storage | ||
async fn update_proofs_state(&self, ys: Vec<PublicKey>, state: State) -> Result<(), Self::Err>; | ||
|
||
/// Increment Keyset counter | ||
async fn increment_keyset_counter(&self, keyset_id: &Id, count: u32) -> Result<(), Self::Err>; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be useful is this returned the tolerance?
Option<Amount>
instead of a bool?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then
has_tolerance
could be merged withis_exact
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to use bools instead of checking the state of Options when doing conditional logic, such as how these functions are used. I can add a tolerance function that returns an Option, but I don't see why we shouldn't provide all of these functions in the API.