mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
Add mainchain rpc client
This commit is contained in:
parent
238a72bead
commit
d39d440fcf
10 changed files with 291 additions and 5 deletions
|
|
@ -123,6 +123,39 @@ bool GetAuthCookie(std::string *cookie_out)
|
|||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// ELEMENTS:
|
||||
|
||||
/** Default name for mainchain auth cookie file */
|
||||
static const std::string MAINCHAIN_COOKIEAUTH_FILE = "regtest/.cookie";
|
||||
/** Get name mainchain RPC authentication cookie file */
|
||||
static fs::path GetMainchainAuthCookieFile()
|
||||
{
|
||||
boost::filesystem::path path(gArgs.GetArg("-mainchainrpccookiefile", MAINCHAIN_COOKIEAUTH_FILE));
|
||||
if (!path.is_complete()) path = GetDataDir(false) / path;
|
||||
return path;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// END ELEMENTS
|
||||
//
|
||||
|
||||
void DeleteAuthCookie()
|
||||
{
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue