Skip to content

Commit c6c362d

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 68f34f9 commit c6c362d

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
@@ -101,6 +101,9 @@ class Wallet
101101
//! Get public key.
102102
virtual bool getPubKey(const CScript& script, const CKeyID& address, CPubKey& pub_key) = 0;
103103

104+
//! Get Output type from a Destination.
105+
virtual OutputType getOutputType(const CTxDestination& dest) = 0;
106+
104107
//! Sign message
105108
virtual SigningResult signMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) = 0;
106109

src/wallet/interfaces.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ class WalletImpl : public Wallet
166166
}
167167
return false;
168168
}
169+
OutputType getOutputType(const CTxDestination& dest) override
170+
{
171+
CScript script = GetScriptForDestination(dest);
172+
std::unique_ptr<SigningProvider> provider = m_wallet->GetSolvingProvider(script);
173+
std::unique_ptr<Descriptor> desc = provider ? InferDescriptor(script, *provider) : InferDescriptor(script, FlatSigningProvider());
174+
return desc->GetOutputType().value_or(OutputType::UNKNOWN);
175+
}
169176
SigningResult signMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) override
170177
{
171178
return m_wallet->SignMessage(message, pkhash, str_sig);

0 commit comments

Comments
 (0)