Only used for functionary integration tests
| 1741 | |
| 1742 | // Only used for functionary integration tests |
| 1743 | RPCHelpMan generatepegoutproof() |
| 1744 | { |
| 1745 | return RPCHelpMan{"generatepegoutproof", |
| 1746 | "\nONLY FOR TESTING: Generates pegout authorization proof for pegout based on the summed privkey and returns in hex. Result should be passed as an argument in `sendtomainchain`. Caution: Whitelist proof-validating mempools will filter incorrect pegoutproofs but aren't consensus enforced!\n", |
| 1747 | { |
| 1748 | {"sumkey", RPCArg::Type::STR, RPCArg::Optional::NO, "Base58 summed key of Bitcoin and offline key"}, |
| 1749 | {"btcpubkey", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex pegout destination Bitcoin pubkey"}, |
| 1750 | {"onlinepubkey", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "hex `online pubkey`"}, |
| 1751 | }, |
| 1752 | RPCResult{ |
| 1753 | RPCResult::Type::STR_HEX, "pegoutproof", "pegout authorization proof to be passed into sendtomainchain", |
| 1754 | }, |
| 1755 | RPCExamples{ |
| 1756 | HelpExampleCli("generatepegoutproof", "\"cQtNrRngdc4RJ9CkuTVKVLyxPFsijiTJySob24xCdKXGohdFhXML\" \"02c611095119e3dc96db428a0e190a3e142237bcd2efa4fb358257497885af3ab6\" \"0390695fff5535780df1e04c1f6c10e7c0a399fa56cfce34bf8108d0a9bc7a437b\"") |
| 1757 | + HelpExampleRpc("generatepegoutproof", "\"cQtNrRngdc4RJ9CkuTVKVLyxPFsijiTJySob24xCdKXGohdFhXML\" \"02c611095119e3dc96db428a0e190a3e142237bcd2efa4fb358257497885af3ab6\" \"0390695fff5535780df1e04c1f6c10e7c0a399fa56cfce34bf8108d0a9bc7a437b\"") |
| 1758 | }, |
| 1759 | [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue |
| 1760 | { |
| 1761 | std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request); |
| 1762 | if (!pwallet) return NullUniValue; |
| 1763 | |
| 1764 | LOCK(pwallet->cs_wallet); |
| 1765 | |
| 1766 | if (!IsHex(request.params[1].get_str())) |
| 1767 | throw JSONRPCError(RPC_TYPE_ERROR, "btcpubkey must be hex string"); |
| 1768 | if (!IsHex(request.params[2].get_str())) |
| 1769 | throw JSONRPCError(RPC_TYPE_ERROR, "onlinepubkey must be hex string"); |
| 1770 | |
| 1771 | //Parse private keys |
| 1772 | |
| 1773 | CKey summedSecret = DecodeSecret(request.params[0].get_str()); |
| 1774 | if (!summedSecret.IsValid()) { |
| 1775 | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid summed private key encoding"); |
| 1776 | } |
| 1777 | |
| 1778 | std::vector<unsigned char> sumprivkeybytes(summedSecret.begin(), summedSecret.end()); |
| 1779 | std::vector<unsigned char> btcpubkeybytes = ParseHex(request.params[1].get_str()); |
| 1780 | std::vector<unsigned char> onlinepubkeybytes = ParseHex(request.params[2].get_str()); |
| 1781 | |
| 1782 | //Parse onlinepubkey |
| 1783 | CPubKey onlinepubkey; |
| 1784 | onlinepubkey.Set(onlinepubkeybytes.begin(), onlinepubkeybytes.end()); |
| 1785 | if (!onlinepubkey.IsFullyValid()) |
| 1786 | throw JSONRPCError(RPC_WALLET_ERROR, "Invalid online pubkey"); |
| 1787 | secp256k1_pubkey onlinepubkey_secp; |
| 1788 | if (!secp256k1_ec_pubkey_parse(secp256k1_ctx, &onlinepubkey_secp, &onlinepubkeybytes[0], onlinepubkeybytes.size())) |
| 1789 | throw JSONRPCError(RPC_WALLET_ERROR, "Invalid online pubkey"); |
| 1790 | |
| 1791 | CPAKList paklist = GetActivePAKList(pwallet->chain().getTip(), Params().GetConsensus()); |
| 1792 | if (paklist.IsReject()) { |
| 1793 | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pegout freeze is under effect to aid a pak transition to a new list. Please consult the network operator."); |
| 1794 | } |
| 1795 | |
| 1796 | LegacyScriptPubKeyMan* spk_man = pwallet->GetLegacyScriptPubKeyMan(); |
| 1797 | if (!spk_man) { |
| 1798 | throw JSONRPCError(RPC_WALLET_ERROR, "This type of wallet does not support this command"); |
| 1799 | } |
| 1800 |
nothing calls this directly
no test coverage detected