Skip to content

Commit 90284c7

Browse files
wallet: Correct output type for Segwit address
Current OutputTypeFromDestination at outputtype, returns OUTPUT_TYPE_STRING_LEGACY for Segwit addresses, as p2sh-segwit requires extra info from the wallet to figure that out, this change adds a correct way to obtain the desired result from the wallet interface. So far this will be needed from the UI to identify such type, as currently a user could select this output type to create an address (receivecoinsdialog) but no display of it exists.
1 parent bc0e33f commit 90284c7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/interfaces/wallet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ class Wallet
9696
//! Get public key.
9797
virtual bool getPubKey(const CScript& script, const CKeyID& address, CPubKey& pub_key) = 0;
9898

99+
//! Get Output type from a Destination.
100+
virtual OutputType getOutputType(const CTxDestination& dest) = 0;
101+
99102
//! Sign message
100103
virtual SigningResult signMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) = 0;
101104

src/wallet/interfaces.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ class WalletImpl : public Wallet
163163
}
164164
return false;
165165
}
166+
OutputType getOutputType(const CTxDestination& dest) override
167+
{
168+
CScript script = GetScriptForDestination(dest);
169+
std::unique_ptr<SigningProvider> provider = m_wallet->GetSolvingProvider(script);
170+
std::unique_ptr<Descriptor> desc = provider ? InferDescriptor(script, *provider) : InferDescriptor(script, FlatSigningProvider());
171+
return desc->GetOutputType().value_or(OutputType::UNKNOWN);
172+
}
166173
SigningResult signMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) override
167174
{
168175
return m_wallet->SignMessage(message, pkhash, str_sig);

0 commit comments

Comments
 (0)