cculianu / Fulcrum

A fast & nimble SPV Server for BCH, BTC, and LTC
Other
331 stars 76 forks source link

Consider implementing blockchain.address.get_first_use #185

Closed monsterbitar closed 10 months ago

monsterbitar commented 1 year ago

There is a proposal for blockchain.address.get_first_use and blockchain.scripthash.get_first_use on https://bitcoincash.network/electrum/protocol-methods-extra.html#blockchain-address-get-first-use which seems useful.

cculianu commented 1 year ago

Yes this is not difficult at all to implement since it re-uses existing database data easily enough with zero extra cost. I’ll try and get this in before the next release.

zander commented 1 year ago

this would be useful

cculianu commented 10 months ago

Ok I implemented this in PR #210 . Note that I am copying the API of the Electrs & Rostrum implementation. Of note:

I am in particular curious about the first bullet-point above. Do we want to return null if the address has no history or do we want to throw an RPC error. I am a bit uncomfortable with throwing an error here because the other blockchain.address.* RPCs only throw on invalid arguments, never on missing history or missing utxos for a particular address.

monsterbitar commented 10 months ago

I commented on the MR with a preference for null instead of error, as I have what I consider valid usage that will not find data (recover from seed without knowing the derivation path, therefor trying multiple paths).

Closing this issue since the feature is implemented, but ideally some coordination with other implementations on the matter would be helpful. if they are willing to update they can, for example, make it so that after some specific version it adops the new behaviour. If not, then it's probably better to stick with the error version for now.

cculianu commented 10 months ago

TBH for the reasons you cited -- it makes more sense to return null here. I will change it and notify in this issue when that's done.

cculianu commented 10 months ago

Actually. I just re-read what you wrote. It seems you want to co-ordinate with Rostrum (the only other impl.). Can you ask @dagurval if he is willing to change it?

If so then I will change it. He may listen to you. :)

cculianu commented 10 months ago

Update: After discussions on TG it appears people are ok with returning null for unused addresses. I have updated Fulcrum to do just that in the latest commit pushed to master.