Skip to content

Commit

Permalink
wallet: Correct output type for Segwit address
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pablomartin4btc committed Sep 11, 2023
1 parent 05f508f commit e0e22a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/interfaces/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ class Wallet
//! Get public key.
virtual bool getPubKey(const CScript& script, const CKeyID& address, CPubKey& pub_key) = 0;

//! Get Output type from a Destination.
virtual OutputType getOutputType(const CTxDestination& dest) = 0;

//! Sign message
virtual SigningResult signMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) = 0;

Expand Down
7 changes: 7 additions & 0 deletions src/wallet/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ class WalletImpl : public Wallet
}
return false;
}
OutputType getOutputType(const CTxDestination& dest) override
{
CScript script = GetScriptForDestination(dest);
std::unique_ptr<SigningProvider> provider = m_wallet->GetSolvingProvider(script);
std::unique_ptr<Descriptor> desc = provider ? InferDescriptor(script, *provider) : InferDescriptor(script, FlatSigningProvider());
return desc->GetOutputType().value_or(OutputType::UNKNOWN);
}
SigningResult signMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) override
{
return m_wallet->SignMessage(message, pkhash, str_sig);
Expand Down

0 comments on commit e0e22a1

Please sign in to comment.