Skip to content

Add allow_partial parameter to the "coins to spend" query #2904

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

Closed
wants to merge 7 commits into from

Conversation

rafal-ch
Copy link
Contributor

@rafal-ch rafal-ch commented Mar 25, 2025

Closes #2898

Description

This PR introduces the new allow_partial parameter to the "coins to spend" query. The default value of this parameters is false to preserve the old behavior. If set to true, the query returns available coins instead of failing when the requested amount is unavailable.

I consider this change "non-breaking" since the new parameter is not strictly required when sending the query.

Checklist

  • New behavior is reflected in tests

Before requesting review

  • I have reviewed the code myself

After merging, notify other teams

[Add or remove entries as needed]

@rafal-ch rafal-ch added the breaking A breaking api change label Mar 25, 2025
@rafal-ch rafal-ch changed the title Rafal/2898 coins to spend updates Add allow_partial parameter to the "coins to spend" query Mar 25, 2025
@rafal-ch rafal-ch removed the breaking A breaking api change label Mar 25, 2025
@rafal-ch rafal-ch requested a review from a team as a code owner March 25, 2025 14:33
Comment on lines +1102 to +1106
excludedIds: ExcludeInput,
"""
If true, returns available coins instead of failing when the requested amount is unavailable.
"""
allowPartial: Boolean! = false
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it should be optional and part of the SpendQueryElementInput. In this case user can specify which one can be filled partially, and which one can't.

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressed in #2912

Comment on lines +108 to +109
// TODO[RC]: Support partial flag in the AssembleTx transaction
let allow_partial = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

When we fetch required balances, it should be false, but when we fetch coins to cover the fee, it can be true

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressed in #2912

@AurelienFT
Copy link
Contributor

Close in favor of #2912 because of CLA.

@AurelienFT AurelienFT closed this Mar 31, 2025
AurelienFT added a commit that referenced this pull request Apr 7, 2025
## Linked Issues/PRs
Closes #2898

THIS IS A REVIVAL OF #2904
WITH REVIEW COMMENTS ADDRESSED (because of CLA). Inspiration from Rafal.
Kudos to @rafal-ch !

## Description
This PR introduces the new allow_partial parameter to the "coins to
spend" inputs query. This field is optional to avoid breaking change. If
set to true, the query returns available coins instead of failing when
the requested amount is unavailable.

I consider this change "non-breaking" since the new parameter is not
strictly required when sending the query.

## Checklist
- [x] New behavior is reflected in tests

### Before requesting review
- [x] I have reviewed the code myself

---------

Co-authored-by: Mitchell Turner <james.mitchell.turner@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CoinsToSpend query should return selected coins even if the amount cannot be covered
3 participants