Navigation Menu

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

rpcclient: add getnewaddresstype and revert breaking change #1844

Merged
merged 1 commit into from Jun 6, 2022

Conversation

chappjc
Copy link
Contributor

@chappjc chappjc commented Apr 14, 2022

Since the address type was added to the btcjson and rpcclient packages, but the corresponding btcwallet PR is not yet merged, it made it clear that the rpcclient would ideally be able to work with older btcwallet versions. That is not straightforward with the recently modified rpcclient.Client methods. See #1843. This change seeks to make the rpcclient's GetNewAddress method compatible with both old and new btcwallet apps.

This reverts the previous breaking change to the GetNewAddress and GetRawChangeAddress rpcclient.Client methods, and adds the methods GetNewAddressType and GetRawChangeAddressType for requesting an address of a certain type. This change allows the rpcclient package to continue to work with versions of the btcwallet app that do not recognize the address type parameter.

An alternate change that does not add new methods but lets the type param be omitted is here: #1843 (comment) That keeps the current API with the breaking change however.

This reverts the previous breaking change to the GetNewAddress and
GetRawChangeAddress rpcclient.Client methods, and adds the methods
GetNewAddressType and GetRawChangeAddressType for requesting
an address of a certain type.  This change allows the rpcclient package
to continue to work with versions of the btcwallet app that do not
recognize the address type parameter.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 2168427285

  • 0 of 30 (0.0%) changed or added relevant lines in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.02%) to 54.247%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rpcclient/wallet.go 0 30 0.0%
Files with Coverage Reduction New Missed Lines %
rpcclient/wallet.go 2 0%
Totals Coverage Status
Change from base Build 2162753669: -0.02%
Covered Lines: 25184
Relevant Lines: 46425

💛 - Coveralls

@chappjc
Copy link
Contributor Author

chappjc commented Apr 27, 2022

To summarize, this is primarily to allow latest rpcclient package to work with older btcwallet apps.

Could also achieve that with

// ... an empty addrType string will omit the type from the marshalled request.
func (c *Client) GetNewAddressAsync(account, addrType string) FutureGetNewAddressResult {
	aType := &addrType
	if addrType == "" {
		aType = nil
	}
	cmd := btcjson.NewGetNewAddressCmd(&account, aType)

Entirely depends on design goals for the btcwallet packages.

The change of the signature of GetNewAddress and GetNewAddressAsync introduced in 061aef9 is a smaller consideration IMO.

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🦴

@Roasbeef Roasbeef merged commit 1696c63 into btcsuite:master Jun 6, 2022
@chappjc
Copy link
Contributor Author

chappjc commented Jun 6, 2022

Swinging back to btcsuite/btcwallet#783 now

Roasbeef added a commit to Roasbeef/btcd that referenced this pull request Jun 6, 2022
Includes:
  * A fix in the RPC server: btcsuite#1862
  * Rolling back a breaking change fromteh PoV of the rpcclient: btcsuite#1844
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants