-
Notifications
You must be signed in to change notification settings - Fork 133
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 onchain address validation compatible with Taproot adresses #194
Comments
@zx9r and @satsbaba are interested on this task. |
When you say valid that means that it should follow general guidlines of how a taproot address should be ? @Reckless-Satoshi Meaning a taproot address should start with 'bc1p.....' else if not it is not a taproot address? |
Yes, but not only. It should have a valid checksum. More context here https://en.bitcoin.it/wiki/Base58Check_encoding#Creating_a_Base58Check_string there is probably some lightweight library to perform this check much better suited that coinaddrvalidator. |
ohh yes that makes more sense. I am looking into this task for seeing how it can be done. Realised I can use github web editor also for coding. |
I will take a look at the different approachs that could be taken:
|
You will definitely need to run the function :) |
That I can do it definitely. @Reckless-Satoshi |
Also it should adhere to bech32 https://en.bitcoin.it/wiki/Bech32 also. @Reckless-Satoshi |
I think that to avoid using external libraries, and to avoid reinventing the wheel writing new code to validate, which is prone to errors and needs maintenance, a good solution would be to make a rpc call to bitcoind validateaddress. Example outputs: ./bitcoin-cli validateaddress 16p7Hhj1tTgAo4GdwQhyzb9gJdsivC1rFH ./bitcoin-cli validateaddress 3Av2maSQWHmibBAdDaHQS7utMKzjp3JrnF ./bitcoin-cli validateaddress bc1q4zmgw3dy7u5npxtnrweq3pt9hvpjppz6klpxvf With a TAPROOT address: With an invalid address (the same from last example changing the last character): $ ./bitcoin-cli validateaddress bc1pzvysgkm0c5q4qwjegme4csthynhrtznt4ye080ggxlz8ylaeaf2q4unkrp |
Agree, more reliable and elegant. It might be that in order to implement/test this feature one might indeed needs to run the development stack? |
A call with a testnet bitcoin address with a bitcoind running in mainnet returns invalid as expected: $ ./bitcoin-cli validateaddress mfWxJ45yp2SFn7UciZyNpvDKrzbhyfKrY8 I cannot test with a bitcoind running in testnet though |
I can test the function locally but i dont have a robosats development enviroment to make integration tests. BTW, I dont know how to access the bitcoind rpc inside robosats. Could it be passed as a parameter to the function ? |
Well if it is just a REST call to bitcoind I guess I can get the connection parameters from config. Right ? |
We are not calling bitcoind anywhere at the moment from robosats backend. So the wiring will have to be implemented in a similar fashion we do with LND. Just add a environmental variables in Then it could be retrieved in |
I am putting a pull request for this task please check. I have checked this function for this list of btc addresses:
|
link for the pull request : #200 |
Thank you guys for the prompt action on this Issue! Both approaches look great (#198 & #200). Just a note for future tasks eligible for Sats. The idea behind the rewarded tasks is to offload work from the lead developer. We also want to avoid duplicate work as much as possible. I believe there was some initial agreement (in telegram) that @zx9r would be the first one to give the task a try. But I understand it was a fun task and both of you wanted to give it a try :) If the work is duplicated and the assignees require hints/help and testing from the lead dev for two different PRs, then we have failed our main mission: this does not offload work from the lead dev. In fact, it can potentially result in more work for me than if I had implemented myself :D I will only fully test one of the PRs, the one of @zx9r as it is succinct with no new dependencies and we can be sure it will always work (as it relies directly on Bitcoin Core). We keep @satsbaba PR as a plan B in case we find some issue (e.g. when bitcoind service is down? To explore if this is ever a real issue) |
Is your feature request related to a problem? Please describe.
Current on-chain payout (as on-the-fly swaps) does not accept taproot addressed. The RoboSats backend can pay to taproot. However, the function to validate an address submitted by the user does not support it.
Describe the solution you'd like
We are using pip package coinaddrvalidator to validate on-chain addresses. Ideally, we would prefer to validate addresses using the LND backend, but this functionality does not seem to be implemented for gRPC calls (I think?). In addition, coinaddrvalidator is not well maintained and bloated with shitcoin address validators. It would be great to instead find a replacement or write our own on-chain address validation.
This is the relevant util that performs validation using coinaddrvalidator. The task consist in a) making it compatible with taproot and b) making it dependency free (or a light dependency).
https://github.com/Reckless-Satoshi/robosats/blob/aad87e7d98be30bbbb814b91534e0709724c2bc4/api/utils.py#L14-L43
Alternatively, a call to Bitcoin RPC or LND gRPC would also be good solutions.
Additional context
This task is ⚡rewarded with 120K Sats⚡ . Drop a comment if you want to be assigned.
The text was updated successfully, but these errors were encountered: