-
Notifications
You must be signed in to change notification settings - Fork 2.2k
chore(payment): Implement silent payments #2269
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
base: master
Are you sure you want to change the base?
Conversation
This PR implements bip352 and exposes the following functions: - scanForSilentPayments: to find if given outputs belong to our sp address - deriveOutput: to create a new silent payment output TODO: - [] Decide how we expose scanning and deriving to the developer i guess via the p2sp object ? - [] Decide whether we return the found hex endcoded or Uint8Array output - [] Figure out of we can remove `modN32` and `subBE` as they might exist? - [] Add derivation logic - [] Replace `getPubkeyFromInputTS` from test with something that exists?
Tags were missing from the TAGS
Some outputs wernt matching what we expected them to be.
I've been in discussions on the best way to handle this, and I think it would be a better idea to pass in a cached key. Instead of calculating the sum of the inputs in real time every time, The payment should only take a special key ie. This is primarily because our friends over at BlueWallet see a future where apps like electrs or mempool etc will pre-calculate the aggregate keys and index them for us.... But... yeah... ballooning Payments API into something that encompasses a whole transaction seems like a bit much. At that point we might as well turn it into a method on the Psbt. |
@Overtorment if you'd like to chime in, feel free. |
ye maybe use the following logic:
|
ill take a look. btw we have a TS implementation of SP here: https://github.com/BlueWallet/SilentPayments/ |
Shouldent something have failed here?
Added lazy prop for outputs.
Allow various cases for deriving of outputs : bitcoinjs-lib/ts_src/payments/p2sp.ts Line 89 in 4f52dde
|
network, | ||
); | ||
}); | ||
lazy.prop(o, 'outputs', () => { |
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.
This is something I am unsure about.
- Should outputs be the ones create to send?
- Where and how do we store resulting UTXO when we scanned?
Ye I mentioned on the top :) (thought I referred to to something inside the core bluewallet app). |
I would like to repeat what I said before:
It seems like your reply is ignoring this and talking about placing all of that inside the p2sp Payment API still... am I misunderstanding your response? Could you please clarify? |
For the inputs/outputs i was thinking of a bare minimal set of data, the parsing of the transactions into receiving inputs would be done elsewhere. I think the lazy output property kinda reflects this now right? or do you still think even that is too much here? |
i feel a bit out of element here, every time i get distracted from SP i completely forget how they work and getting familiar again means re-reading all the specs again, and it takes time. are there any specific questions for me? if yes, dumb it down for me. |
no worries thanks for making me aware of scure-btc-signer also mentioned the blue wallet repo there as there was an issue open for silent payments too. |
}); | ||
} | ||
// If we have all the inputs, aSum and only the spend keys for the recipients we need to calculate the input hash and secret | ||
else if ( |
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.
this case drags in inputs (hashes) and we may not want to have this here
}); | ||
} | ||
// If we have all the inputs, privKeys and only the spend keys for the recipients we need to calculate the Sum, the input hash and secret | ||
else if ( |
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.
same here for inputs
Draft for now looking for a bit of feedback on how we can expose the functionality to the developer
Implements bip352 and exposes the following functions:
scanForSilentPayments
: to find if given outputs belong to our sp addressderiveOutput
: to create a new silent payment outputencodeSilentPaymentAddress
decodeSilentPaymentAddress
Note it tests against vectors taken from: https://github.com/bitcoin/bips/blob/master/bip-0352/send_and_receive_test_vectors.json
TODO:
modN32
andsubBE
as they might exist?getPubkeyFromInputTS
from test with something that exists?Do note that when this bitcoin-core/secp256k1#1698 gets merged and we make it available in https://github.com/bitcoinjs/tiny-secp256k1 part of this code becomes redundant but at least we already have the interfaces in place.
Bluewallet also has a TS implementation : https://github.com/BlueWallet/SilentPayments/blob/master/src/index.ts