| 563 | } |
| 564 | |
| 565 | UniValue dumphdinfo(const UniValue& params, bool fHelp) |
| 566 | { |
| 567 | if (!EnsureWalletIsAvailable(fHelp)) |
| 568 | return NullUniValue; |
| 569 | |
| 570 | if (fHelp || params.size() != 0) |
| 571 | throw runtime_error( |
| 572 | "dumphdinfo\n" |
| 573 | "Returns an object containing sensitive private info about this HD wallet.\n" |
| 574 | "\nResult:\n" |
| 575 | "{\n" |
| 576 | " \"hdseed\": \"seed\", (string) The HD seed (bip32, in hex)\n" |
| 577 | " \"mnemonic\": \"words\", (string) The mnemonic for this HD wallet (bip39, english words) \n" |
| 578 | " \"mnemonicpassphrase\": \"passphrase\", (string) The mnemonic passphrase for this HD wallet (bip39)\n" |
| 579 | "}\n" |
| 580 | "\nExamples:\n" |
| 581 | + HelpExampleCli("dumphdinfo", "") |
| 582 | + HelpExampleRpc("dumphdinfo", "") |
| 583 | ); |
| 584 | |
| 585 | LOCK(pwalletMain->cs_wallet); |
| 586 | |
| 587 | EnsureWalletIsUnlocked(); |
| 588 | |
| 589 | // add the base58check encoded extended master if the wallet uses HD |
| 590 | CHDChain hdChainCurrent; |
| 591 | if (!pwalletMain->GetHDChain(hdChainCurrent)) |
| 592 | throw JSONRPCError(RPC_WALLET_ERROR, "This wallet is not an HD wallet."); |
| 593 | |
| 594 | if (!pwalletMain->GetDecryptedHDChain(hdChainCurrent)) |
| 595 | throw JSONRPCError(RPC_INTERNAL_ERROR, "Cannot decrypt HD seed"); |
| 596 | |
| 597 | SecureString ssMnemonic; |
| 598 | SecureString ssMnemonicPassphrase; |
| 599 | hdChainCurrent.GetMnemonic(ssMnemonic, ssMnemonicPassphrase); |
| 600 | |
| 601 | UniValue obj(UniValue::VOBJ); |
| 602 | obj.push_back(Pair("hdseed", HexStr(hdChainCurrent.GetSeed()))); |
| 603 | obj.push_back(Pair("mnemonic", ssMnemonic.c_str())); |
| 604 | obj.push_back(Pair("mnemonicpassphrase", ssMnemonicPassphrase.c_str())); |
| 605 | |
| 606 | return obj; |
| 607 | } |
| 608 | |
| 609 | |
| 610 | UniValue dumpwallet(const UniValue& params, bool fHelp) |
nothing calls this directly
no test coverage detected