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

Implement bip352 full #1

Closed
wants to merge 37 commits into from
Closed

Commits on Jun 18, 2024

  1. Configuration menu
    Copy the full SHA
    363423f View commit details
    Browse the repository at this point in the history
  2. Add "sp" HRP

    josibake committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    eaeace2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    24535c3 View commit details
    Browse the repository at this point in the history
  4. common: add bip352.{h,cpp} secp256k1 module

    Wrap the silentpayments module from libsecp256k1. This is placed in
    common as it is intended to be used by:
    
      * RPCs: for parsing addresses
      * Wallet: for sending, receiving, spending silent payment outputs
      * Node: for creating silent payment indexes for light clients
    josibake committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    b7eebb6 View commit details
    Browse the repository at this point in the history
  5. wallet: disable sending to silent payment address

    Have `IsValidDestination` return false for silent payment destinations
    and set an error string when decoding a silent payment address.
    
    This prevents anyone from sending to a silent payment address before
    sending is implemented in the wallet, but also allows the functions to
    be used in the unit testing famework.
    josibake committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    6d33868 View commit details
    Browse the repository at this point in the history
  6. tests: add BIP352 test vectors as unit tests

    Use the test vectors to test sending and receiving. A few cases are not
    covered here, namely anything that requires testing specific to the
    wallet. For example:
    
    * Taproot script path spending is not tested, as that is better tested in
      a wallets coin selection / signing logic
    * Re-computing outputs during RBF is not tested, as that is better
      tested in a wallets RBF logic
    
    The unit tests are written in such a way that adding new test cases is
    as easy as updating the JSON file
    josibake committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    76845e9 View commit details
    Browse the repository at this point in the history
  7. wallet: get serialized size for V0SilentPayments

    BIP352 v0 specifies that a silent payment output is a taproot output.
    Taproot scriptPubKeys are a fixed size, so when calculating the
    serialized size for a CRecipient with a V0SilentPayments destination,
    use WitnessV1Taproot for the serialized txout size.
    josibake committed Jun 18, 2024
    Configuration menu
    Copy the full SHA
    4a2d5c8 View commit details
    Browse the repository at this point in the history

Commits on Jun 28, 2024

  1. wallet: add method for retreiving a private key

    Add a method for retreiving a private key for a given scriptPubKey.
    If the scriptPubKey is a taproot output, tweak the private key with the
    merkle root or hash of the public key, if applicable.
    josibake authored and Eunovo committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    4bf011f View commit details
    Browse the repository at this point in the history
  2. wallet: make coin selection silent payment aware

    Add a flag to the `CoinControl` object if silent payment destinations
    are provided. Before adding the flag, call a function which checks if:
    
    * The wallet has private keys
    * The wallet is unlocked
    
    Without both of the above being true, we cannot send to a silent payment
    address.
    
    During coin selection, if this flag is set, skip taproot inputs when
    script spend data is available. This is based on the assumption that if
    a user provides script spend data, they don't have access to the key
    path spend. As future improvement, we could instead check to see if we
    have access to the key path spend, and only exclude the output when we
    don't regardless of whether or not the user provides script spend data.
    
    Also skip UTXOs of type `WITNESS_UNKNOWN`, although it is very unlikely
    our wallet would ever try to spend a witness unknown output.
    josibake authored and Eunovo committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    7e8da9c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4002638 View commit details
    Browse the repository at this point in the history
  4. wallet: add CreateSilentPaymentOutputs function

    `CreateSilentPaymentsOutputs` gets the correct private keys, adds them
    together, groups the silent payment destinations and then generates the
    taproot script pubkeys. These are then passed back to
    CreateTransactionInternal, which uses these scriptPubKeys to update
    vecSend before adding them to the transaction outputs.
    josibake authored and Eunovo committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    c26197d View commit details
    Browse the repository at this point in the history
  5. wallet: update TransactionChangeType

    If sending to a silent payment destination, the change type should be taproot
    josibake authored and Eunovo committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    1f58b83 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    82fc714 View commit details
    Browse the repository at this point in the history
  7. tests: add sending functional tests

    josibake authored and Eunovo committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    4b0faa2 View commit details
    Browse the repository at this point in the history
  8. add TweakAdd method to CKey

    This is a temporary measure and might not be what we want long term.
    josibake authored and Eunovo committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    975012e View commit details
    Browse the repository at this point in the history
  9. add TweakAdd method to CPubKey

    this is a temporary measure. The alternative to having this method is
    to store the full spk + tweak in the DB (34 + 32 bytes), vs only storing
    the tweak (32 bytes) and recreating the spks every time we load the tweaks.
    
    Another option is to add this method directly to V0SilentPayments so that
    its not generally available for any CPubKey.
    josibake authored and Eunovo committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    9fb000f View commit details
    Browse the repository at this point in the history

Commits on Jul 3, 2024

  1. wallet: create new type OutputType::SILENT_PAYMENT

    * Exclude OutputType::SILENT_PAYMENT from wallet notifications fuzz test
      because wallet cannot create a V0SilentPaymentDestination yet
    josibake authored and Eunovo committed Jul 3, 2024
    Configuration menu
    Copy the full SHA
    ca74998 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7368028 View commit details
    Browse the repository at this point in the history
  3. post-rebase fixups

    Eunovo committed Jul 3, 2024
    Configuration menu
    Copy the full SHA
    05b01ab View commit details
    Browse the repository at this point in the history
  4. keys: Add Silent Payment Key

    Eunovo committed Jul 3, 2024
    Configuration menu
    Copy the full SHA
    252ad45 View commit details
    Browse the repository at this point in the history
  5. keys: Add key io for Silent Payment Keys

    * Add base58 prefixes for Silent Payment Keys
    * Encode and Decode SP Keys using Base58Check. This will changed to Bech32M later
    Eunovo committed Jul 3, 2024
    Configuration menu
    Copy the full SHA
    596c18d View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    e6d26a6 View commit details
    Browse the repository at this point in the history
  7. signingprovider: Add spkeys to signing provider

    This allows DescriptorImpl.Extract to add spkeys to
    FlatSigningProvider
    Eunovo committed Jul 3, 2024
    Configuration menu
    Copy the full SHA
    db5cd0d View commit details
    Browse the repository at this point in the history
  8. descriptor: Implement SP descriptor parser

    Parse sp(sppub or spprv) or sp(scan_priv_key,spend_pub_key or spend_priv_key)
    Eunovo committed Jul 3, 2024
    Configuration menu
    Copy the full SHA
    ab17be4 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    6770b93 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    759255a View commit details
    Browse the repository at this point in the history
  11. wallet: Add Silent Payment utility funcitons

    Update GenerateWalletDescriptor to generate sp descriptor for SP and return scan and spend private keys to caller
    Add function to extranct SP tweak data from tx and spent_coins
    Add function to extract SpPubKey from an sp desc
    All of these will be used for the SP DescriptorSPKMan Impl
    Eunovo committed Jul 3, 2024
    Configuration menu
    Copy the full SHA
    2aff507 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    f67c0fb View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    c717853 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    f72a8d4 View commit details
    Browse the repository at this point in the history
  15. wallet: Add wallet flag for silent payments and setup when set

    Optionally allow users to create a wallet that supports silent payments.
    This is signaled through an option in createwallet and a new wallet
    flag.
    achow101 authored and Eunovo committed Jul 3, 2024
    Configuration menu
    Copy the full SHA
    796b2c1 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    ca68a7b View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    1629b14 View commit details
    Browse the repository at this point in the history
  18. wallet: check for self-transfer when sending

    Call IsMineSilentPayment when sending to a SP address if our wallet has
    SPs enabled.
    
    In `CreateSilentPaymentOutputs`, we create a change output using silent payments. The
    presence of the change output will cause us to not fully check the
    transaction and thus never create the silent payment tweaks, which is
    why we check for self-transfers here. This feels a bit hacky, but works
    for now.
    josibake authored and Eunovo committed Jul 3, 2024
    Configuration menu
    Copy the full SHA
    c042811 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    7b31dec View commit details
    Browse the repository at this point in the history
  20. tests: add receiving functional test

    josibake authored and Eunovo committed Jul 3, 2024
    Configuration menu
    Copy the full SHA
    1a60240 View commit details
    Browse the repository at this point in the history
  21. wallet: Fixups for Silent Payments support

    * Allow same Silent Payments DSPKM to be loaded as both internal and external spkm
    * Update AddWalletDescriptor to handle silent payment descr
    Eunovo committed Jul 3, 2024
    Configuration menu
    Copy the full SHA
    f81fb83 View commit details
    Browse the repository at this point in the history