tABC_CC ABC_BridgeWatcherConnect(Wallet &self, tABC_Error *pError) { tABC_CC cc = ABC_CC_Ok; tABC_GeneralInfo *ppInfo = NULL; const char *szServer = FALLBACK_OBELISK; Watcher *watcher = nullptr; ABC_CHECK_NEW(watcherFind(watcher, self)); // Pick a server: if (isTestnet()) { szServer = TESTNET_OBELISK; } else if (ABC_CC_Ok == ABC_GeneralGetInfo(&ppInfo, pError) && 0 < ppInfo->countObeliskServers) { ++gLastObelisk; if (ppInfo->countObeliskServers <= gLastObelisk) gLastObelisk = 0; szServer = ppInfo->aszObeliskServers[gLastObelisk]; } // Connect: ABC_DebugLog("Wallet %s connecting to %s", self.id().c_str(), szServer); watcher->connect(szServer); exit: ABC_GeneralFreeInfo(ppInfo); return cc; }
const ScryptSnrp & usernameSnrp() { static const ScryptSnrp mainnet = { { 0xb5, 0x86, 0x5f, 0xfb, 0x9f, 0xa7, 0xb3, 0xbf, 0xe4, 0xb2, 0x38, 0x4d, 0x47, 0xce, 0x83, 0x1e, 0xe2, 0x2a, 0x4a, 0x9d, 0x5c, 0x34, 0xc7, 0xef, 0x7d, 0x21, 0x46, 0x7c, 0xc7, 0x58, 0xf8, 0x1b }, SCRYPT_DEFAULT_SERVER_N, SCRYPT_DEFAULT_SERVER_R, SCRYPT_DEFAULT_SERVER_P }; static const ScryptSnrp testnet = { { 0xa5, 0x96, 0x3f, 0x3b, 0x9c, 0xa6, 0xb3, 0xbf, 0xe4, 0xb2, 0x36, 0x42, 0x37, 0xfe, 0x87, 0x1e, 0xf2, 0x2a, 0x4a, 0x9d, 0x4c, 0x34, 0xa7, 0xef, 0x3d, 0x21, 0x47, 0x8c, 0xc7, 0x58, 0xf8, 0x1b }, SCRYPT_DEFAULT_SERVER_N, SCRYPT_DEFAULT_SERVER_R, SCRYPT_DEFAULT_SERVER_P }; return isTestnet() ? testnet : mainnet; }
static Status blockchainPostTx(DataSlice tx) { std::string body = "tx=" + base16Encode(tx); if (isTestnet()) return ABC_ERROR(ABC_CC_Error, "No blockchain.info testnet"); HttpReply reply; ABC_CHECK(HttpRequest(). header("Content-Type", "application/x-www-form-urlencoded"). post(reply, "https://blockchain.info/pushtx", body)); ABC_CHECK(reply.codeOk()); return Status(); }
static Status insightPostTx(DataSlice tx) { std::string body = "rawtx=" + base16Encode(tx); const char *url = isTestnet() ? "https://test-insight.bitpay.com/api/tx/send": "https://insight.bitpay.com/api/tx/send"; HttpReply reply; ABC_CHECK(HttpRequest(). post(reply, url, body)); ABC_CHECK(reply.codeOk()); return Status(); }
std::vector<std::string> generalBitcoinServers() { std::vector<std::string> out; if (isTestnet()) { std::string serverlist[] = TESTNET_BITCOIN_SERVERS; size_t size = sizeof(serverlist) / sizeof(*serverlist); for (int i = 0; i < size; i++) out.push_back(serverlist[i]); return out; } auto arrayJson = generalLoad().bitcoinServers(); size_t size = arrayJson.size(); out.reserve(size); for (size_t i = 0; i < size; i++) { auto stringJson = arrayJson[i]; if (json_is_string(stringJson.get())) { std::string servername = json_string_value(stringJson.get()); out.push_back(servername); } } if (!out.size()) { std::string serverlist[] = FALLBACK_BITCOIN_SERVERS; size_t size = sizeof(serverlist) / sizeof(*serverlist); for (int i = 0; i < size; i++) out.push_back(serverlist[i]); } return out; }
bool Currency::init() { if (!generateGenesisBlock()) { logger(ERROR, BRIGHT_RED) << "Failed to generate genesis block"; return false; } if (!get_block_hash(m_genesisBlock, m_genesisBlockHash)) { logger(ERROR, BRIGHT_RED) << "Failed to get genesis block hash"; return false; } if (isTestnet()) { m_upgradeHeight = 0; m_blocksFileName = "testnet_" + m_blocksFileName; m_blocksCacheFileName = "testnet_" + m_blocksCacheFileName; m_blockIndexesFileName = "testnet_" + m_blockIndexesFileName; m_txPoolFileName = "testnet_" + m_txPoolFileName; m_blockchinIndicesFileName = "testnet_" + m_blockchinIndicesFileName; } return true; }