Skip to content

Support bech32 addresses in rpc methods#211

Merged
dangershony merged 1 commit intoblock-core:masterfrom
xandronus:getnewaddress-bech32
Sep 2, 2020
Merged

Support bech32 addresses in rpc methods#211
dangershony merged 1 commit intoblock-core:masterfrom
xandronus:getnewaddress-bech32

Conversation

@xandronus
Copy link
Copy Markdown
Contributor

Update getnewaddress and getunsusedaddress RPC calls to support returning bech32 addresses
Fixes #101

// Currently segwit and bech32 addresses are not supported.
if (!addressType.Equals("legacy", StringComparison.InvariantCultureIgnoreCase))
throw new RPCServerException(RPCErrorCode.RPC_METHOD_NOT_FOUND, "Only address type 'legacy' is currently supported.");
// Currently segwit addresses are not supported.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Doesn't Bech32 imply segwit?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe should clarify as p2sh-segwit addresses are not supported. Not sure we need to worry about them as bech32 seems to have been well adopted

@dangershony
Copy link
Copy Markdown
Member

Looks fine to me @sondreb ?

@dangershony dangershony merged commit 2da28a6 into block-core:master Sep 2, 2020
return new NewAddressModel(base58Address);
string address = hdAddress.Address; // legacy address
if (addressType != null && addressType.Equals("bech32", StringComparison.InvariantCultureIgnoreCase))
address = hdAddress.Bech32Address;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This could be simplified to avoid performing two get operations every time the user request bech32 address. The assignment should depend on the conditional check.

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.

Add segwit to getnewaddress RPC call

3 participants