HomePhabricator

[backport#17584] wallet: replace raw pointer with const reference in…

Description

[backport#17584] wallet: replace raw pointer with const reference in AddrToPubKey

Summary:
1a3a256d5e0443d19757c1f1fceb9c9ede17758a wallet: replace raw pointer with const reference in AddrToPubKey (Harris)

Pull request description:

This PR replaces a redundant reference-to-pointer conversion in **addmultisigaddress** from *wallet/rpcwallet.cpp*. It also makes the API from *rpc/util.h* look more straightforward as **AddrToPubKey** now uses const references like other functions from there.

I am not sure why there is a ref-to-ptr conversion in addmultisignatures, so I can only speculate that this is because of "historical reasons".

The ref-to-ptr conversion happens here: https://github.com/bitcoin/bitcoin/blob/master/src/wallet/rpcwallet.cpp#L1001

There, the address of LegacyScriptPubKeyMan& is given to AddrToPubKey.

Later, in AddrToPubKey, it gets converted back to a reference, because GetKeyForDestination in rpc/util.cpp expects a const ref: https://github.com/bitcoin/bitcoin/blob/master/src/rpc/util.cpp#L140

Regards,

Backport of Core PR17584

Test Plan:

ninja all check check-functional

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D7715

Details

Provenance
Samuel Dobson <dobsonsa68@gmail.com>Authored on Nov 26 2019, 08:17
majcostaCommitted on Oct 1 2020, 16:34
majcostaPushed on Oct 1 2020, 16:34
Reviewer
Restricted Project
Differential Revision
D7715: [backport#17584] wallet: replace raw pointer with const reference in AddrToPubKey
Parents
rABC1884ca2a13c8: tests: Added missing tests for RPC wallet errors
Branches
Unknown
Tags
Unknown