btcsuite / btcd

An alternative full node bitcoin implementation written in Go (golang)
https://github.com/btcsuite/btcd/blob/master/README.md
ISC License
6.28k stars 2.38k forks source link

rpcclient: listaccounts is deprecated and replaced with listlabels #1974

Open brandonpille opened 1 year ago

brandonpille commented 1 year ago

A couple of commands have been deprecated and replaced by others. For example listaccounts is now listlabels. Most accounts related rpcs are now renamed to label. See https://chainquery.com/bitcoin-cli

brandonpille commented 1 year ago

Can anyone pick this up?

roy9495 commented 1 year ago

Hi, I want to contribute. But I don't know what code changes I have to make. Can you please elaborate on this issue?

roy9495 commented 1 year ago

So these are the commands that got deprecated https://chainquery.com/bitcoin-cli#deprecated. Do you want all occurrences of these commands replaced by the alternatives, in this repo? Thanks.

brandonpille commented 1 year ago

Yes, it doesn't make sense to use deprecated calls by default as they will disappear some day. Or at least do the same as in the bitcoin nodes. In the new bitcoin node you can pass an argument telling the node to use the old (deprecated) calls instead. I think it makes sense to do that. We should, by default, use new calls and if wanted use the deprecated calls.

brandonpille commented 1 year ago

Hi, do we have an estimate for this?

brandonpille commented 1 year ago

If someone wants to contribute, it's just modifying some function names and some arguments. Here are the required changes (got that from bitcoin repository: https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-0.17.0.md#label-and-account-apis-for-wallet):

Deprecated Method New Method Notes
getaccount getaddressinfo getaddressinfo returns a json object with address information instead of just the name of the account as a string.
getaccountaddress n/a There is no replacement for getaccountaddress since labels do not have an associated receive address.
getaddressesbyaccount getaddressesbylabel getaddressesbylabel returns a json object with the addresses as keys, instead of a list of strings.
getreceivedbyaccount getreceivedbylabel no change in behavior
listaccounts listlabels listlabels does not return a balance or accept minconf and watchonly arguments.
listreceivedbyaccount listreceivedbylabel Both methods return new label fields, along with account fields for backward compatibility.
move n/a no replacement
sendfrom n/a no replacement
setaccount setlabel Both methods now:
  • allow assigning labels to any address, instead of raising an error if the address is not receiving address.
  • delete the previous label associated with an address when the final address using that label is reassigned to a different label, instead of making an implicit getaccountaddress call to ensure the previous label still has a receiving address.
Changed Method Notes
addmultisigaddress Renamed account named parameter to label. Still accepts account for backward compatibility if running with '-deprecatedrpc=accounts'.
getnewaddress Renamed account named parameter to label. Still accepts account for backward compatibility. if running with '-deprecatedrpc=accounts'
listunspent Returns new label fields. account field will be returned for backward compatibility if running with '-deprecatedrpc=accounts'
sendmany The account named parameter has been renamed to dummy. If provided, the dummy parameter must be set to the empty string, unless running with the -deprecatedrpc=accounts argument (in which case functionality is unchanged).
listtransactions The account named parameter has been renamed to dummy. If provided, the dummy parameter must be set to the string *, unless running with the -deprecatedrpc=accounts argument (in which case functionality is unchanged).
getbalance account, minconf and include_watchonly parameters are deprecated, and can only be used if running with '-deprecatedrpc=accounts'
elnosh commented 1 year ago

Hi, I'm new here and looking to contribute. May I pick this up?

Eoous commented 1 year ago

Hi, maybe we can work together.

yemmyharry commented 9 months ago

@brandonpille pls is this issue still unresolved? Would love to contribute.

joseguru commented 9 months ago

@brandonpille pls is this issue still unresolved? Would love to contribute.

@yemmyharry If its still unresolved I would also want to help

Roasbeef commented 9 months ago

See https://github.com/btcsuite/btcd/issues/1934 also

dv29 commented 4 months ago

is this still valid and open? i can take it up

Roasbeef commented 4 months ago

@dv29 yep, also see #1934

dv29 commented 3 months ago

@Roasbeef i'm not sure how #1934 relates to this? are you saying that I should also implement the generic interface? could you expand a little on it please? i can also work on #1934 if thats supposed to be done before this

Roasbeef commented 2 months ago

@dv29 what I'm saying is that we no longer strive to keep 1:1 compatibility with bitcoind, as their RPC interface changes rather frequently, and the feature sets no longer align 1:1.

The rpcclient package supports making raw requests: https://pkg.go.dev/github.com/btcsuite/btcd/rpcclient#Client.RawRequest. Using this, you can make the JSON struct in a package, then use the linked API call to make requests with that new message. The issue I linked to is about creating a more generalized way to do custom messages.

dv29 commented 2 months ago

That makes sense, in that case i'll implement this and then work on creating the generalized way to do custom messages.