Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show First 20 Lines • Show All 261 Lines • ▼ Show 20 Lines | static void ImportScript(CWallet *const pwallet, const CScript &script, | ||||
pwallet->MarkDirty(); | pwallet->MarkDirty(); | ||||
if (!pwallet->HaveWatchOnly(script) && | if (!pwallet->HaveWatchOnly(script) && | ||||
!pwallet->AddWatchOnly(script, 0 /* nCreateTime */)) { | !pwallet->AddWatchOnly(script, 0 /* nCreateTime */)) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet"); | throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet"); | ||||
} | } | ||||
if (isRedeemScript) { | if (isRedeemScript) { | ||||
if (!pwallet->HaveCScript(script) && !pwallet->AddCScript(script)) { | const CScriptID id(script); | ||||
if (!pwallet->HaveCScript(id) && !pwallet->AddCScript(script)) { | |||||
throw JSONRPCError(RPC_WALLET_ERROR, | throw JSONRPCError(RPC_WALLET_ERROR, | ||||
"Error adding p2sh redeemScript to wallet"); | "Error adding p2sh redeemScript to wallet"); | ||||
} | } | ||||
ImportAddress(pwallet, CScriptID(script), strLabel); | ImportAddress(pwallet, id, strLabel); | ||||
} else { | } else { | ||||
CTxDestination destination; | CTxDestination destination; | ||||
if (ExtractDestination(script, destination)) { | if (ExtractDestination(script, destination)) { | ||||
pwallet->SetAddressBook(destination, strLabel, "receive"); | pwallet->SetAddressBook(destination, strLabel, "receive"); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 837 Lines • ▼ Show 20 Lines | try { | ||||
pwallet->MarkDirty(); | pwallet->MarkDirty(); | ||||
if (!pwallet->AddWatchOnly(redeemScript, timestamp)) { | if (!pwallet->AddWatchOnly(redeemScript, timestamp)) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, | throw JSONRPCError(RPC_WALLET_ERROR, | ||||
"Error adding address to wallet"); | "Error adding address to wallet"); | ||||
} | } | ||||
if (!pwallet->HaveCScript(redeemScript) && | CScriptID redeem_id(redeemScript); | ||||
if (!pwallet->HaveCScript(redeem_id) && | |||||
!pwallet->AddCScript(redeemScript)) { | !pwallet->AddCScript(redeemScript)) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, | throw JSONRPCError(RPC_WALLET_ERROR, | ||||
"Error adding p2sh redeemScript to wallet"); | "Error adding p2sh redeemScript to wallet"); | ||||
} | } | ||||
CTxDestination redeem_dest = CScriptID(redeemScript); | CScript redeemDestination = GetScriptForDestination(redeem_id); | ||||
CScript redeemDestination = GetScriptForDestination(redeem_dest); | |||||
if (::IsMine(*pwallet, redeemDestination) == ISMINE_SPENDABLE) { | if (::IsMine(*pwallet, redeemDestination) == ISMINE_SPENDABLE) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, | throw JSONRPCError(RPC_WALLET_ERROR, | ||||
"The wallet already contains the private " | "The wallet already contains the private " | ||||
"key for this address or script"); | "key for this address or script"); | ||||
} | } | ||||
pwallet->MarkDirty(); | pwallet->MarkDirty(); | ||||
▲ Show 20 Lines • Show All 436 Lines • Show Last 20 Lines |