| 181 | |
| 182 | void ImportAddress(const CTxDestination& dest, const std::string& strLabel); |
| 183 | void ImportScript(const CScript& script, const std::string& strLabel, bool isRedeemScript) |
| 184 | { |
| 185 | if (!isRedeemScript && ::IsMine(*pwalletMain, script) == ISMINE_SPENDABLE) |
| 186 | throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the private key for this address or script"); |
| 187 | |
| 188 | pwalletMain->MarkDirty(); |
| 189 | |
| 190 | if (!pwalletMain->HaveWatchOnly(script) && !pwalletMain->AddWatchOnly(script)) |
| 191 | throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet"); |
| 192 | |
| 193 | if (isRedeemScript) { |
| 194 | if (!pwalletMain->HaveCScript(script) && !pwalletMain->AddCScript(script)) |
| 195 | throw JSONRPCError(RPC_WALLET_ERROR, "Error adding p2sh redeemScript to wallet"); |
| 196 | ImportAddress(GetScriptForDestination(CScriptID(script)), strLabel); |
| 197 | } else { |
| 198 | CTxDestination destination; |
| 199 | if (ExtractDestination(script, destination)) { |
| 200 | pwalletMain->SetAddressBook(destination, strLabel, "receive"); |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | void ImportAddress(const CTxDestination& dest, const std::string& strLabel) |
| 206 | { |
no test coverage detected