Skip to content

Commit e0e22a1

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 05f508f commit e0e22a1

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

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

src/wallet/interfaces.cpp

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

0 commit comments

Comments
 (0)