MCPcopy Create free account
hub / github.com/QuipNetwork/cpp-sdk / deriveClassicalPublicKey

Method deriveClassicalPublicKey

src/quip_wallet.cpp:654–684  ·  view source on GitHub ↗

Derive classical public key from private key

Source from the content-addressed store, hash-verified

652
653 // Derive classical public key from private key
654 std::string deriveClassicalPublicKey(const PrivateKey &private_key) {
655 // Use the same approach as CLI - call ethers.js from ethereum-sdk
656 std::string command = "cd " +
657 std::string(getenv("PWD") ? getenv("PWD") : ".") +
658 "/ethereum-sdk && node -e \"console.log(new "
659 "(require('ethers').Wallet)('" +
660 private_key + "').address)\"";
661
662 FILE *pipe = popen(command.c_str(), "r");
663 if (!pipe) {
664 throw std::runtime_error("Failed to execute ethers.js command");
665 }
666
667 std::string result;
668 char buffer[128];
669 while (fgets(buffer, sizeof(buffer), pipe) != nullptr) {
670 result += buffer;
671 }
672
673 int status = pclose(pipe);
674 if (status != 0) {
675 throw std::runtime_error("ethers.js command failed");
676 }
677
678 // Remove newline and return the address
679 if (!result.empty() && result[result.length() - 1] == '\n') {
680 result.erase(result.length() - 1);
681 }
682
683 return result;
684 }
685
686 std::string getRecipientAddress() const {
687 return "0x742d35cc6634c0532925a3b8d4c9db96c4b4d8b6";

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected