mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Rework CallRPC, use bitcoind cookie auth
This commit is contained in:
parent
f1878a4462
commit
bab5e9ef7c
5 changed files with 60 additions and 11 deletions
|
|
@ -75,6 +75,16 @@ boost::filesystem::path GetAuthCookieFile()
|
|||
return path;
|
||||
}
|
||||
|
||||
boost::filesystem::path GetMainchainAuthCookieFile()
|
||||
{
|
||||
boost::filesystem::path path(GetArg("-mainchainrpccookiefile", COOKIEAUTH_FILE));
|
||||
//Change to default false for live network
|
||||
if (!path.is_complete() && GetBoolArg("-testnet", true)) path = "testnet3" / path;
|
||||
if (!path.is_complete() && GetBoolArg("-regtest", false)) path = "regtest" / path;
|
||||
if (!path.is_complete()) path = GetDataDir(false) / path;
|
||||
return path;
|
||||
}
|
||||
|
||||
bool GenerateAuthCookie(std::string *cookie_out)
|
||||
{
|
||||
const size_t COOKIE_SIZE = 32;
|
||||
|
|
@ -117,6 +127,23 @@ bool GetAuthCookie(std::string *cookie_out)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool GetMainchainAuthCookie(std::string *cookie_out)
|
||||
{
|
||||
std::ifstream file;
|
||||
std::string cookie;
|
||||
|
||||
boost::filesystem::path filepath = GetMainchainAuthCookieFile();
|
||||
file.open(filepath.string().c_str());
|
||||
if (!file.is_open())
|
||||
return false;
|
||||
std::getline(file, cookie);
|
||||
file.close();
|
||||
|
||||
if (cookie_out)
|
||||
*cookie_out = cookie;
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeleteAuthCookie()
|
||||
{
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue