mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
Broken addresses on command line no longer trigger testnet.
When passing a bitcoin: URI on the command line, invalid addresses do not incorrectly send the user to the test network.
This commit is contained in:
parent
9d26dc3b29
commit
e84843c0db
@ -215,9 +215,13 @@ bool CBitcoinAddress::Set(const CTxDestination &dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CBitcoinAddress::IsValid() const {
|
bool CBitcoinAddress::IsValid() const {
|
||||||
|
return IsValid(Params());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CBitcoinAddress::IsValid(const CChainParams ¶ms) const {
|
||||||
bool fCorrectSize = vchData.size() == 20;
|
bool fCorrectSize = vchData.size() == 20;
|
||||||
bool fKnownVersion = vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS) ||
|
bool fKnownVersion = vchVersion == params.Base58Prefix(CChainParams::PUBKEY_ADDRESS) ||
|
||||||
vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS);
|
vchVersion == params.Base58Prefix(CChainParams::SCRIPT_ADDRESS);
|
||||||
return fCorrectSize && fKnownVersion;
|
return fCorrectSize && fKnownVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +104,7 @@ public:
|
|||||||
bool Set(const CScriptID &id);
|
bool Set(const CScriptID &id);
|
||||||
bool Set(const CTxDestination &dest);
|
bool Set(const CTxDestination &dest);
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
bool IsValid(const CChainParams ¶ms) const;
|
||||||
|
|
||||||
CBitcoinAddress() {}
|
CBitcoinAddress() {}
|
||||||
CBitcoinAddress(const CTxDestination &dest) { Set(dest); }
|
CBitcoinAddress(const CTxDestination &dest) { Set(dest); }
|
||||||
|
@ -220,24 +220,25 @@ const CChainParams &Params() {
|
|||||||
return *pCurrentParams;
|
return *pCurrentParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectParams(CBaseChainParams::Network network) {
|
CChainParams &Params(CBaseChainParams::Network network) {
|
||||||
SelectBaseParams(network);
|
|
||||||
switch (network) {
|
switch (network) {
|
||||||
case CBaseChainParams::MAIN:
|
case CBaseChainParams::MAIN:
|
||||||
pCurrentParams = &mainParams;
|
return mainParams;
|
||||||
break;
|
|
||||||
case CBaseChainParams::TESTNET:
|
case CBaseChainParams::TESTNET:
|
||||||
pCurrentParams = &testNetParams;
|
return testNetParams;
|
||||||
break;
|
|
||||||
case CBaseChainParams::REGTEST:
|
case CBaseChainParams::REGTEST:
|
||||||
pCurrentParams = ®TestParams;
|
return regTestParams;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
assert(false && "Unimplemented network");
|
assert(false && "Unimplemented network");
|
||||||
return;
|
return mainParams;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SelectParams(CBaseChainParams::Network network) {
|
||||||
|
SelectBaseParams(network);
|
||||||
|
pCurrentParams = &Params(network);
|
||||||
|
}
|
||||||
|
|
||||||
bool SelectParamsFromCommandLine() {
|
bool SelectParamsFromCommandLine() {
|
||||||
if (!SelectBaseParamsFromCommandLine())
|
if (!SelectBaseParamsFromCommandLine())
|
||||||
return false;
|
return false;
|
||||||
|
@ -111,6 +111,9 @@ protected:
|
|||||||
*/
|
*/
|
||||||
const CChainParams &Params();
|
const CChainParams &Params();
|
||||||
|
|
||||||
|
/** Return parameters for the given network. */
|
||||||
|
CChainParams &Params(CBaseChainParams::Network network);
|
||||||
|
|
||||||
/** Sets the params returned by Params() to those for the given network. */
|
/** Sets the params returned by Params() to those for the given network. */
|
||||||
void SelectParams(CBaseChainParams::Network network);
|
void SelectParams(CBaseChainParams::Network network);
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "optionsmodel.h"
|
#include "optionsmodel.h"
|
||||||
|
|
||||||
#include "base58.h"
|
#include "base58.h"
|
||||||
|
#include "chainparams.h"
|
||||||
#include "ui_interface.h"
|
#include "ui_interface.h"
|
||||||
#include "wallet.h"
|
#include "wallet.h"
|
||||||
|
|
||||||
@ -199,8 +200,11 @@ bool PaymentServer::ipcParseCommandLine(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
CBitcoinAddress address(r.address.toStdString());
|
CBitcoinAddress address(r.address.toStdString());
|
||||||
|
|
||||||
|
if (address.IsValid(Params(CBaseChainParams::MAIN)))
|
||||||
|
{
|
||||||
SelectParams(CBaseChainParams::MAIN);
|
SelectParams(CBaseChainParams::MAIN);
|
||||||
if (!address.IsValid())
|
}
|
||||||
|
else if (address.IsValid(Params(CBaseChainParams::TESTNET)))
|
||||||
{
|
{
|
||||||
SelectParams(CBaseChainParams::TESTNET);
|
SelectParams(CBaseChainParams::TESTNET);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user