MCPcopy Create free account
hub / github.com/ElementsProject/elements / getpegoutkeys

Function getpegoutkeys

src/wallet/rpc/elements.cpp:1843–1917  ·  view source on GitHub ↗

Only used for functionary integration tests

Source from the content-addressed store, hash-verified

1841
1842// Only used for functionary integration tests
1843RPCHelpMan getpegoutkeys()
1844{
1845 return RPCHelpMan{"getpegoutkeys",
1846 "\n(DEPRECATED) Please see `initpegoutwallet` and `sendtomainchain` for best-supported and easiest workflow. This call is for the Liquid network participants' `offline` wallet ONLY. Returns `sumkeys` corresponding to the sum of the Offline PAK and the imported Bitcoin key. The wallet must have the Offline private PAK to succeed. The output will be used in `generatepegoutproof` and `sendtomainchain`. Care is required to keep the bitcoin private key, as well as the `sumkey` safe, as a leak of both results in the leak of your `offlinekey`. Therefore it is recommended to create Bitcoin keys and do Bitcoin transaction signing directly on an offline wallet co-located with your offline Liquid wallet.\n",
1847 {
1848 {"btcprivkey", RPCArg::Type::STR, RPCArg::Optional::NO, "Base58 Bitcoin private key that will be combined with the offline privkey"},
1849 {"offlinepubkey", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED_NAMED_ARG, "Hex pubkey of key to combine with btcprivkey. Primarily intended for integration testing."},
1850 },
1851 RPCResult{
1852 RPCResult::Type::OBJ, "", "",
1853 {
1854 {RPCResult::Type::STR, "sumkey", "Base58-encoded sum key"},
1855 {RPCResult::Type::STR_HEX, "btcpubkey", "the bitcoin pubkey that corresponds to the pegout destination Bitcoin address"},
1856 {RPCResult::Type::STR, "btcaddress", "Destination Bitcoin address for the funds being pegged out using these keys"},
1857 },
1858 },
1859 RPCExamples{
1860 HelpExampleCli("getpegoutkeys", "")
1861 + HelpExampleCli("getpegoutkeys", "\"5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF\" \"0389275d512326f7016e014d8625f709c01f23bd0dc16522bf9845a9ee1ef6cbf9\"")
1862 + HelpExampleRpc("getpegoutkeys", "")
1863 + HelpExampleRpc("getpegoutkeys", "\"5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF\", \"0389275d512326f7016e014d8625f709c01f23bd0dc16522bf9845a9ee1ef6cbf9\"")
1864 },
1865 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1866{
1867 std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
1868 if (!pwallet) return NullUniValue;
1869
1870 LOCK(pwallet->cs_wallet);
1871
1872 LegacyScriptPubKeyMan* spk_man = pwallet->GetLegacyScriptPubKeyMan();
1873 if (!spk_man) {
1874 throw JSONRPCError(RPC_WALLET_ERROR, "This type of wallet does not support this command");
1875 }
1876
1877 if (!request.params[1].isStr() || !IsHex(request.params[1].get_str()) || request.params[1].get_str().size() != 66) {
1878 throw JSONRPCError(RPC_TYPE_ERROR, "offlinepubkey must be hex string of size 66");
1879 }
1880
1881 std::vector<unsigned char> offlinepubbytes = ParseHex(request.params[1].get_str());
1882 CPubKey offline_pub = CPubKey(offlinepubbytes.begin(), offlinepubbytes.end());
1883
1884 if (!offline_pub.IsFullyValid()) {
1885 throw JSONRPCError(RPC_TYPE_ERROR, "offlinepubkey is not a valid pubkey");
1886 }
1887
1888 CKey pegoutkey;
1889 if (!spk_man->GetKey(offline_pub.GetID(), pegoutkey))
1890 throw JSONRPCError(RPC_WALLET_ERROR, "Offline key can not be found in wallet");
1891
1892 CKey bitcoinkey = DecodeSecret(request.params[0].get_str());
1893 if (!bitcoinkey.IsValid()) {
1894 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Private key outside allowed range");
1895 }
1896
1897 CPubKey bitcoinpubkey = bitcoinkey.GetPubKey();
1898 CHECK_NONFATAL(bitcoinkey.VerifyPubKey(bitcoinpubkey));
1899
1900 std::vector<unsigned char> pegoutkeybytes(pegoutkey.begin(), pegoutkey.end());

Callers

nothing calls this directly

Calls 15

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
JSONRPCErrorFunction · 0.85
IsHexFunction · 0.85
ParseHexFunction · 0.85
DecodeSecretFunction · 0.85
EncodeSecretFunction · 0.85
EncodeParentDestinationFunction · 0.85
PKHashClass · 0.85

Tested by

no test coverage detected