tABC_CC ABC_BridgeSweepKey(Wallet &self, tABC_U08Buf key, bool compressed, tABC_Sweep_Done_Callback fCallback, void *pData, tABC_Error *pError) { tABC_CC cc = ABC_CC_Ok; bc::ec_secret ec_key; bc::ec_point ec_addr; bc::payment_address address; PendingSweep sweep; WatcherInfo *watcherInfo = nullptr; ABC_CHECK_NEW(watcherFind(watcherInfo, self)); // Decode key and address: ABC_CHECK_ASSERT(key.size() == ec_key.size(), ABC_CC_Error, "Bad key size"); std::copy(key.begin(), key.end(), ec_key.data()); ec_addr = bc::secret_to_public_key(ec_key, compressed); address.set(pubkeyVersion(), bc::bitcoin_short_hash(ec_addr)); // Start the sweep: sweep.address = address; sweep.key = abcd::wif_key{ec_key, compressed}; sweep.done = false; sweep.fCallback = fCallback; sweep.pData = pData; watcherInfo->sweeping.push_back(sweep); watcherInfo->watcher.watch_address(address); exit: return cc; }
/** * Changes the password for an account on the server. * * This function sends information to the server to change the password for an account. * Either the old LP1 or LRA1 can be used for authentication. * * @param oldLP1 Old password hash for the account (if this is empty, LRA1 is used instead) * @param LRA1 LRA1 for the account (used if oldP1 is empty) */ tABC_CC ABC_LoginServerChangePassword(const Lobby &lobby, tABC_U08Buf oldLP1, tABC_U08Buf newLP1, tABC_U08Buf newLRA1, const CarePackage &carePackage, const LoginPackage &loginPackage, tABC_Error *pError) { tABC_CC cc = ABC_CC_Ok; HttpReply reply; std::string url = ABC_SERVER_ROOT "/" ABC_SERVER_CHANGE_PASSWORD_PATH; ServerReplyJson replyJson; char *szPost = NULL; std::string carePackageStr; std::string loginPackageStr; json_t *pJSON_OldLRA1 = NULL; json_t *pJSON_NewLRA1 = NULL; json_t *pJSON_Root = NULL; ABC_CHECK_NULL_BUF(oldLP1); ABC_CHECK_NULL_BUF(newLP1); ABC_CHECK_NEW(carePackage.encode(carePackageStr)); ABC_CHECK_NEW(loginPackage.encode(loginPackageStr)); // Encode those: pJSON_Root = json_pack("{ss, ss, ss, ss, ss}", ABC_SERVER_JSON_L1_FIELD, base64Encode(lobby.authId()).c_str(), ABC_SERVER_JSON_LP1_FIELD, base64Encode(oldLP1).c_str(), ABC_SERVER_JSON_NEW_LP1_FIELD, base64Encode(newLP1).c_str(), ABC_SERVER_JSON_CARE_PACKAGE_FIELD, carePackageStr.c_str(), ABC_SERVER_JSON_LOGIN_PACKAGE_FIELD, loginPackageStr.c_str()); // set up the recovery, if any: if (newLRA1.size()) { pJSON_NewLRA1 = json_string(base64Encode(newLRA1).c_str()); json_object_set(pJSON_Root, ABC_SERVER_JSON_NEW_LRA1_FIELD, pJSON_NewLRA1); } // create the post data szPost = ABC_UtilStringFromJSONObject(pJSON_Root, JSON_COMPACT); // send the command ABC_CHECK_NEW(AirbitzRequest().post(reply, url, szPost)); ABC_CHECK_NEW(replyJson.decode(reply.body)); ABC_CHECK_NEW(replyJson.ok()); exit: ABC_FREE_STR(szPost); if (pJSON_OldLRA1) json_decref(pJSON_OldLRA1); if (pJSON_NewLRA1) json_decref(pJSON_NewLRA1); if (pJSON_Root) json_decref(pJSON_Root); return cc; }