-
Notifications
You must be signed in to change notification settings - Fork 217
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
Add derivation paths to coin selection change outputs #2244
Add derivation paths to coin selection change outputs #2244
Conversation
e2d903e
to
d15c740
Compare
This comment has been minimized.
This comment has been minimized.
f171225
to
070ebfc
Compare
lib/core/src/Cardano/Wallet.hs
Outdated
-- have been assigned with addresses and are included in the set of ordinary | ||
-- outputs. We use the 'Void' type here to prevent callers from accidentally | ||
-- passing change values into this function: | ||
-> UnsignedTx input output Void |
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.
for quite a while have not seen Void :-)
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.
Originally I wrote this by specifying change ~ Void
in the list of constraints, and then specifying UnsignedTx input output change
as the parameter type, as I felt that this would be more readable.
However, GHC views this as a redundant constraint. Of course, it's possible to silence the redundant constraint warning, but that would mean silencing this warning for the whole file. So I eventually switched to just writing Void
inline, even though it is slightly less readable (IMO).
070ebfc
to
77a335f
Compare
This comment has been minimized.
This comment has been minimized.
tryBuild succeeded: |
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.
so far lgtm.having a way to derive change and inputs begs for some advanced testing sometime in future: we have a wallet with mnemonic1 with one utxo, and send some money to another one. We can now have a handle to output and change. We re-derive the addresses using derivation paths in cardano-addresses. And use them to create another transaction blob in cardano-transactions. Then send it using external api endpoint and see that it works in integration testing . Maybe @piotr-iohk would be interested in adding such a test sometime in the future:-)
77a335f
to
431b2cd
Compare
d0dc17e
to
b991025
Compare
This function is currently only used in contexts where all change outputs have been assigned with addresses and are included in the set of ordinary outputs. We use the 'Void' type here to prevent callers from accidentally passing change values into this function.
Use `Void` type in function `assignMigrationAddresses` to indicate that no change is returned.
Use this function to factor out common parts of `selectCoinsExternal`.
Before this change we were constructing payment addresses from the stake key, which remains constant over time. This resulted in the generation of a constant "payment address" that was not recognizable as a valid payment address belonging to the wallet, causing subsequent calls to `isOurs` to fail.
Update integration test `WALLETS_COIN_SELECTION_01` to check that: - change outputs are listed within the `change` field of an `ApiCoinSelection`. - change output derivation paths are valid.
Update integration test `WALLETS_COIN_SELECTION_02` to check that the set of coin selection outputs is exactly the same as intially provided, rather than being a subset.
Update integration test `SHELLEY_HW_WALLETS/HW_WALLETS_04` to make multiple payments. In addition, we expect that the resulting selection will have: * an output for each of the original payments. * at least one change output.
Update integration test `BYRON_HW_WALLETS/HW_WALLETS_04` to make multiple payments. In addition, we expect that the resulting selection will have: * an output for each of the original payments. * at least one change output.
We now expect that there are: * no ordinary outputs. * at least one change output.
We now expect that there are: * no ordinary outputs. * at least one change output.
We now expect that there are: * no ordinary outputs. * at least one change output.
5295989
to
ebcfd02
Compare
bors try |
bors r+ |
2244: Add derivation paths to coin selection change outputs r=jonathanknowles a=jonathanknowles # Issue Number #2247 # Overview This PR introduces a new `ApiCoinSelectionChange` type that includes a derivation path: ```hs data ApiCoinSelectionChange (n :: NetworkDiscriminant) = ApiCoinSelectionChange { address :: !(ApiT Address, Proxy n) , amount :: !(Quantity "lovelace" Natural) , derivationPath :: NonEmpty (ApiT DerivationIndex) } deriving (Eq, Generic, Show) ``` In addition, we modify the `ApiCoinSelection` type so that ordinary outputs (**_without_** derivation paths) and change outputs (**_with_** derivation paths) are held in separate fields: ```patch data ApiCoinSelection (n :: NetworkDiscriminant) = ApiCoinSelection { inputs :: !(NonEmpty (ApiCoinSelectionInput n)) - , outputs :: !(NonEmpty (AddressAmount (ApiT Address, Proxy n))) + , outputs :: !(NonEmpty (ApiCoinSelectionOutput n)) + , change :: ![ApiCoinSelectionChange n] } deriving (Eq, Generic, Show) ``` # Comments This PR updates the following integration tests: - `WALLETS_COIN_SELECTION_01`. - `WALLETS_COIN_SELECTION_02`. - `SHELLEY_HW_WALLETS/HW_WALLETS_04`. - `BYRON_HW_WALLETS/HW_WALLETS_04`. Co-authored-by: Jonathan Knowles <[email protected]>
tryTimed out. |
Timed out. |
bors r+ |
2244: Add derivation paths to coin selection change outputs r=jonathanknowles a=jonathanknowles # Issue Number #2247 # Overview This PR introduces a new `ApiCoinSelectionChange` type that includes a derivation path: ```hs data ApiCoinSelectionChange (n :: NetworkDiscriminant) = ApiCoinSelectionChange { address :: !(ApiT Address, Proxy n) , amount :: !(Quantity "lovelace" Natural) , derivationPath :: NonEmpty (ApiT DerivationIndex) } deriving (Eq, Generic, Show) ``` In addition, we modify the `ApiCoinSelection` type so that ordinary outputs (**_without_** derivation paths) and change outputs (**_with_** derivation paths) are held in separate fields: ```patch data ApiCoinSelection (n :: NetworkDiscriminant) = ApiCoinSelection { inputs :: !(NonEmpty (ApiCoinSelectionInput n)) - , outputs :: !(NonEmpty (AddressAmount (ApiT Address, Proxy n))) + , outputs :: !(NonEmpty (ApiCoinSelectionOutput n)) + , change :: ![ApiCoinSelectionChange n] } deriving (Eq, Generic, Show) ``` # Comments This PR updates the following integration tests: - `WALLETS_COIN_SELECTION_01`. - `WALLETS_COIN_SELECTION_02`. - `SHELLEY_HW_WALLETS/HW_WALLETS_04`. - `BYRON_HW_WALLETS/HW_WALLETS_04`. 2257: API data-types & specifications for arbitrary metadata signing. r=rvl a=KtorZ # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> ADP-481 > ADP-508 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - 209781b 📍 **define ToText/FromText instances for 'DerivationIndex'** I had to also move it in '...Primitive.AddressDerivation' because of otherwise circular dependencies (since this module is using the Bounded instances of 'Index', relying on the 'DerivationType' as type parameter. This is mostly extracting the text parsing that was already done in the JSON instance, and moving it as a ToText/FromText instances (and re-using it to build the JSON instances). I've however added a quick sanity text roundtrip property test in the meantime. - c965936 📍 **rename UTxO*ternal -> Utxo*ternal** We use the data-type constructor in order to generate text instances. However, our automatic casing function is doing pretty bad with the mixed cases and we end up with something like: - u_tx_o_external - u_tx_o_internal - mutable_account Instead of fixing the instance itself to work around this, I found it easier to just fix the type (which isn't used in many places). - c4cbafe 📍 **do not output back invalid input when parsing text values.** This is a rather bad practice; if a value failed to parse, then we have very little idea about _what_ it is and what's it's shape. It may not be even readable / printable. Instead, the error message should show valid expected options. - fb5ab0d 📍 **extend API and specifications to include the 'signMetadata' operation** # Comments <!-- Additional comments or screenshots to attach if any --> <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Assign the PR to a corresponding milestone ✓ Acknowledge any changes required to the Wiki --> Co-authored-by: Jonathan Knowles <[email protected]> Co-authored-by: KtorZ <[email protected]> Co-authored-by: Rodney Lorrimar <[email protected]>
This PR was included in a batch that timed out, it will be automatically retried |
Build succeeded: |
2261: Update the API specification to reflect the minimum number of inputs returned by `selectCoins`. r=KtorZ a=jonathanknowles # Issue Related to #2244. # Overview This PR updates the API specification for the `selectCoins` operation, changing the minimum number of inputs from `0` to `1` in the returned coin selection. This matches the existing `ApiCoinSelection` type, which specifies a `NonEmpty` list of `ApiCoinSelectionInput` values: ```hs data ApiCoinSelection (n :: NetworkDiscriminant) = ApiCoinSelection { inputs :: !(NonEmpty (ApiCoinSelectionInput n)) , outputs :: ![ApiCoinSelectionOutput n] , change :: ![ApiCoinSelectionChange n] , certificates :: Maybe (NonEmpty ApiCertificate) } deriving (Eq, Generic, Show) ``` Co-authored-by: Jonathan Knowles <[email protected]>
2261: Update the API specification to reflect the minimum number of inputs returned by `selectCoins`. r=KtorZ a=jonathanknowles # Issue Related to #2244. # Overview This PR updates the API specification for the `selectCoins` operation, changing the minimum number of inputs from `0` to `1` in the returned coin selection. This matches the existing `ApiCoinSelection` type, which specifies a `NonEmpty` list of `ApiCoinSelectionInput` values: ```hs data ApiCoinSelection (n :: NetworkDiscriminant) = ApiCoinSelection { inputs :: !(NonEmpty (ApiCoinSelectionInput n)) , outputs :: ![ApiCoinSelectionOutput n] , change :: ![ApiCoinSelectionChange n] , certificates :: Maybe (NonEmpty ApiCertificate) } deriving (Eq, Generic, Show) ``` Co-authored-by: Jonathan Knowles <[email protected]>
Issue Number
#2247
Overview
This PR adjusts the API
selectCoins
operation so that:ordinary outputs and change outputs are held in separate fields in the returned selection:
outputs
change
each change output now has a
derivation_path
field containing the full derivation path for the change output address.The format of this field is identical to the format of the existing
derivation_path
field of each input.Click here to see updated API description
Internal Changes
This PR introduces a
ApiCoinSelectionChange
type that includes a derivation path:In addition, we modify the
ApiCoinSelection
type so that ordinary outputs (without derivation paths) and change outputs (with derivation paths) are held in separate fields:Testing
This PR updates the following integration tests:
WALLETS_COIN_SELECTION_01
.WALLETS_COIN_SELECTION_02
.SHELLEY_HW_WALLETS/HW_WALLETS_04
.BYRON_HW_WALLETS/HW_WALLETS_04
.