Page MenuHomePhabricator

SegWit wallet support
ClosedPublic

Authored by deadalnix on May 27 2019, 18:31.

Details

Summary

This introduces two command line flags (-addresstype and -changetype) which control
the type of addresses/outputs created by the GUI and RPCs. Certain RPCs allow
overriding these (getnewaddress and getrawchangeaddress). Supported types
are "legacy" (P2PKH and P2SH-multisig), "p2sh-segwit" (P2SH-P2WPKH and P2SH-P2WSH-multisig),
and "bech32" (P2WPKH and P2WSH-multisig).

A few utility functions are added to the wallet to construct different address type
and to add the necessary entries to the wallet file to be compatible with earlier
versions (see CWallet::LearnRelatedScripts, GetDestinationForKey,
GetAllDestinationsForKey, CWallet::AddAndGetDestinationForScript).

This is a partial backport of Core PR11403 : https://github.com/bitcoin/bitcoin/pull/11403/commits/940a21932ba769ba5829cba713579db84f96d2f8

Because we just have one address type to support, we don't need to add new configuration parameters like in the original code.

Depends on D3129, D3131 and D3132

Test Plan
make check
./test/functional/test_runner.py

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markblundeberg added a subscriber: markblundeberg.

Since we only have one type, I'd strongly recommend dropping the address_type support from RPC, and just set output_type = OutputType::LEGACY.

src/interfaces/wallet.h
120 ↗(On Diff #8934)

hmm this isn't in original PR... got missed in T417 I guess

src/wallet/rpcwallet.cpp
167 ↗(On Diff #8934)

mentions segwit

276 ↗(On Diff #8934)

mentions segwit address types

src/wallet/wallet.cpp
933 ↗(On Diff #8934)

PR changes this to:

dest = GetDestinationForKey(account.vchPubKey, g_address_type);

This revision now requires changes to proceed.May 28 2019, 02:06

Remove address type from the RPC doc.
Add missed backport in wallet.cpp

just one mistake I missed on first pass

src/wallet/rpcwallet.cpp
155 ↗(On Diff #8958)

keep account -> label

This revision is now accepted and ready to land.May 28 2019, 13:17
This revision was landed with ongoing or failed builds.May 28 2019, 14:09
This revision was automatically updated to reflect the committed changes.