Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Erik Jansen
crown-core-test-new-gitlab-runner
Commits
0831b47e
Commit
0831b47e
authored
6 years ago
by
Ashot
Browse files
Options
Download
Email Patches
Plain Diff
Added CLI converter for old Crown addresses
parent
046bb34f
reduce-testnet-difficulty
166-mn-pos-integration
211-agent-voting
235-getrawtransaction-nft-vote-tx
Current-dev
bitcore-current-dev
bitcore-current-dev-fix-261
current-dev-fix-261
develop-platform
No related merge requests found
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
src/base58.cpp
+12
-2
src/base58.cpp
src/base58.h
+2
-1
src/base58.h
src/qt/walletmodel.h
+2
-7
src/qt/walletmodel.h
src/rpcserver.cpp
+1
-0
src/rpcserver.cpp
src/rpcserver.h
+1
-0
src/rpcserver.h
src/rpcwallet.cpp
+31
-0
src/rpcwallet.cpp
src/walletdb.cpp
+2
-7
src/walletdb.cpp
with
51 additions
and
17 deletions
+51
-17
src/base58.cpp
View file @
0831b47e
...
...
@@ -287,10 +287,20 @@ CTxDestination CBitcoinAddress::Get() const
return
CNoDestination
();
}
bool
CBitcoinAddress
::
IsDeprecated
(
)
const
bool
CBitcoinAddress
::
IsDeprecated
(
const
std
::
string
&
address
)
{
// If the old constructed address is valid then it's deprecated
return
CBitcoinAddress
(
this
->
ToString
(),
CChainParams
::
DEPRECATED_ADDRESS_TYPE
).
IsValid
();
return
CBitcoinAddress
(
address
,
CChainParams
::
DEPRECATED_ADDRESS_TYPE
).
IsValid
();
}
std
::
string
CBitcoinAddress
::
ConvertToNew
(
const
std
::
string
&
address
)
{
if
(
IsDeprecated
(
address
))
{
CTxDestination
key
=
CBitcoinAddress
(
address
,
CChainParams
::
DEPRECATED_ADDRESS_TYPE
).
Get
();
return
CBitcoinAddress
(
key
).
ToString
();
}
return
address
;
}
bool
CBitcoinAddress
::
GetKeyID
(
CKeyID
&
keyID
)
const
...
...
This diff is collapsed.
Click to expand it.
src/base58.h
View file @
0831b47e
...
...
@@ -133,7 +133,8 @@ public:
CBitcoinAddress
(
const
char
*
pszAddress
)
{
SetString
(
pszAddress
);
}
CTxDestination
Get
()
const
;
bool
IsDeprecated
()
const
;
static
bool
IsDeprecated
(
const
std
::
string
&
address
);
static
std
::
string
ConvertToNew
(
const
std
::
string
&
address
);
bool
GetKeyID
(
CKeyID
&
keyID
)
const
;
bool
IsScript
()
const
;
};
...
...
This diff is collapsed.
Click to expand it.
src/qt/walletmodel.h
View file @
0831b47e
...
...
@@ -85,13 +85,8 @@ public:
if
(
ser_action
.
ForRead
())
{
if
(
CBitcoinAddress
(
sAddress
).
IsDeprecated
())
{
// If the address is deprecated then get the new address
// based on destination of old one
CTxDestination
key
=
CBitcoinAddress
(
sAddress
,
CChainParams
::
DEPRECATED_ADDRESS_TYPE
).
Get
();
sAddress
=
CBitcoinAddress
(
key
).
ToString
();
}
// If the address is not depricated then the value won't be converted
sAddress
=
CBitcoinAddress
::
ConvertToNew
(
sAddress
);
address
=
QString
::
fromStdString
(
sAddress
);
label
=
QString
::
fromStdString
(
sLabel
);
...
...
This diff is collapsed.
Click to expand it.
src/rpcserver.cpp
View file @
0831b47e
...
...
@@ -353,6 +353,7 @@ static const CRPCCommand vRPCCommands[] =
{
"wallet"
,
"getaddressesbyaccount"
,
&
getaddressesbyaccount
,
true
,
false
,
true
},
{
"wallet"
,
"getbalance"
,
&
getbalance
,
false
,
false
,
true
},
{
"wallet"
,
"getnewaddress"
,
&
getnewaddress
,
true
,
false
,
true
},
{
"wallet"
,
"oldtonewaddress"
,
&
oldtonewaddress
,
true
,
false
,
true
},
{
"wallet"
,
"getrawchangeaddress"
,
&
getrawchangeaddress
,
true
,
false
,
true
},
{
"wallet"
,
"getreceivedbyaccount"
,
&
getreceivedbyaccount
,
false
,
false
,
true
},
{
"wallet"
,
"getreceivedbyaddress"
,
&
getreceivedbyaddress
,
false
,
false
,
true
},
...
...
This diff is collapsed.
Click to expand it.
src/rpcserver.h
View file @
0831b47e
...
...
@@ -165,6 +165,7 @@ extern json_spirit::Value estimatefee(const json_spirit::Array& params, bool fHe
extern
json_spirit
::
Value
estimatepriority
(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
extern
json_spirit
::
Value
getnewaddress
(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
// in rpcwallet.cpp
extern
json_spirit
::
Value
oldtonewaddress
(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
// in rpcwallet.cpp
extern
json_spirit
::
Value
getaccountaddress
(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
extern
json_spirit
::
Value
getrawchangeaddress
(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
extern
json_spirit
::
Value
setaccount
(
const
json_spirit
::
Array
&
params
,
bool
fHelp
);
...
...
This diff is collapsed.
Click to expand it.
src/rpcwallet.cpp
View file @
0831b47e
...
...
@@ -79,6 +79,37 @@ string AccountFromValue(const Value& value)
return strAccount;
}
Value oldtonewaddress(const json_spirit::Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"oldtonewaddress( \"oldaddress\" )\n"
"\nConverts given old Crown address to a new one.\n"
"\nArguments:\n"
"1. \"oldaddress\" (string, required) The old Crown address.\n"
"\nResult:\n"
"\"crownaddress\" (string) The new crown address\n"
"\nExamples:\n"
+ HelpExampleCli("oldtonewaddress", "15bj2HB2UbmjEZgXyEW4M8MhUL5TXGCN8L")
+ HelpExampleCli("oldtonewaddress", "\"15bj2HB2UbmjEZgXyEW4M8MhUL5TXGCN8L\"")
+ HelpExampleRpc("oldtonewaddress", "\"15bj2HB2UbmjEZgXyEW4M8MhUL5TXGCN8L\"")
);
std::string strAddress = params[0].get_str();
if (CBitcoinAddress(strAddress).IsValid())
{
throw runtime_error("Error: Given address is a valid new Crown address and cannot be converted.");
}
std::string newAddress = CBitcoinAddress::ConvertToNew(strAddress);
if (newAddress.compare(strAddress) == 0)
{
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unable to convert. Invalid Crown address.");
}
return newAddress;
}
Value getnewaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() > 1)
...
...
This diff is collapsed.
Click to expand it.
src/walletdb.cpp
View file @
0831b47e
...
...
@@ -586,13 +586,8 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
ssKey
>>
strKey
;
ssValue
>>
strValue
;
if
(
CBitcoinAddress
(
strAddress
).
IsDeprecated
())
{
// If the address is deprecated then get the new address
// based on destination of old one
CTxDestination
key
=
CBitcoinAddress
(
strAddress
,
CChainParams
::
DEPRECATED_ADDRESS_TYPE
).
Get
();
strAddress
=
CBitcoinAddress
(
key
).
ToString
();
}
// If the address is not depricated then the value won't be converted
strAddress
=
CBitcoinAddress
::
ConvertToNew
(
strAddress
);
if
(
!
pwallet
->
LoadDestData
(
CBitcoinAddress
(
strAddress
).
Get
(),
strKey
,
strValue
))
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help