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

wallet, rpc: FundTransaction refactor #28560

Merged

Commits on Jan 19, 2024

  1. test: add tests for fundrawtx and sendmany rpcs

    If the serialized transaction passed to `fundrawtransaction` contains
    duplicates, they will be deserialized and added to the transaction. Add
    a test to ensure this behavior is not changed during the refactor.
    
    A user can pass any number of duplicated and unrelated addresses as an
    SFFO argument to `sendmany` and the RPC will not throw an error (note,
    all the rest of the RPCs which take SFFO as an argument will error if
    the user passes duplicates or specifies outputs not present in the
    transaction). Add a test to ensure this behavior is not changed during
    the refactor.
    josibake committed Jan 19, 2024
    Configuration menu
    Copy the full SHA
    435fe5c View commit details
    Browse the repository at this point in the history
  2. refactor: move normalization to new function

    Move the univalue formatting logic out of AddOutputs and into its own function,
    `NormalizeOutputs`. This allows us to re-use this logic in later commits.
    josibake committed Jan 19, 2024
    Configuration menu
    Copy the full SHA
    6f569ac View commit details
    Browse the repository at this point in the history
  3. refactor: move parsing to new function

    Move the parsing and validation out of `AddOutputs` into its own function,
    `ParseOutputs`. This allows us to re-use this logic in `ParseRecipients` in a
    later commit, where the code is currently duplicated.
    
    The new `ParseOutputs` function returns a CTxDestination,CAmount tuples.
    This allows the caller to then translate the validated outputs into
    either CRecipients or CTxOuts.
    josibake committed Jan 19, 2024
    Configuration menu
    Copy the full SHA
    f7384b9 View commit details
    Browse the repository at this point in the history
  4. refactor: remove out param from ParseRecipients

    Have `ParseRecipients` return a vector of `CRecipients` and rename to `CreateRecipients`.
    josibake committed Jan 19, 2024
    Configuration menu
    Copy the full SHA
    47353a6 View commit details
    Browse the repository at this point in the history
  5. refactor: simplify CreateRecipients

    Move validation logic out of `CreateRecipients` and instead take the
    already validated outputs from `ParseOutputs` as an input.
    
    Move SFFO parsing out of `CreateRecipients` into a new function,
    `InterpretSubtractFeeFromOutputsInstructions`. This takes the SFFO instructions
    from `sendmany` and `sendtoaddress` and turns them into a set of integers.
    In a later commit, we will also move the SFFO parsing logic from
    `FundTransaction` into this function.
    
    Worth noting: a user can pass duplicate addresses and addresses that dont exist
    in the transaction outputs as SFFO args to `sendmany` and `sendtoaddress`
    without triggering a warning. This behavior is preserved in to keep this commit
    strictly a refactor.
    josibake committed Jan 19, 2024
    Configuration menu
    Copy the full SHA
    5ad1966 View commit details
    Browse the repository at this point in the history
  6. refactor: pass CRecipient to FundTransaction

    Instead turning tx.vout into a vector of `CRecipient`, make `FundTransaction`
    take a `CRecipient` vector directly. This allows us to remove SFFO logic from
    the wrapper RPC `FundTransaction` since the `CRecipient` objects have already
    been created with the correct SFFO values. This also allows us to remove
    SFFO from both `FundTransaction` function signatures.
    
    This sets us up in a future PR to be able to use these RPCs with BIP352
    static payment codes.
    josibake committed Jan 19, 2024
    Configuration menu
    Copy the full SHA
    18ad1b9 View commit details
    Browse the repository at this point in the history