|
20 | 20 | #include <univalue.h>
|
21 | 21 |
|
22 | 22 | extern void SendBDAPTransaction(const CScript& bdapDataScript, const CScript& bdapOPScript, CWalletTx& wtxNew, const CAmount& nDataAmount, const CAmount& nOpAmount, const bool fUseInstantSend);
|
23 |
| -extern void SendColorTransaction(const CScript& scriptColorCoins, CWalletTx& wtxNew, const CAmount& nColorAmount, const CCoinControl* coinControl, const bool fUseInstantSend, const bool fUsePrivateSend); |
| 23 | +extern void SendColorTransaction(const CScript& scriptColorCoins, const CScript& stealthDataScript, CWalletTx& wtxNew, const CAmount& nColorAmount, const CCoinControl* coinControl, const bool fUseInstantSend, const bool fUsePrivateSend); |
24 | 24 |
|
25 | 25 | static UniValue AddDomainEntry(const JSONRPCRequest& request, BDAP::ObjectType bdapType)
|
26 | 26 | {
|
@@ -958,20 +958,40 @@ UniValue makecredits(const JSONRPCRequest& request)
|
958 | 958 | if (nColorAmount <= 0)
|
959 | 959 | throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for coloring");
|
960 | 960 |
|
| 961 | + CScript scriptDestination; |
| 962 | + std::vector<uint8_t> vStealthData; |
| 963 | + bool fStealthAddress = false; |
| 964 | + if (dest.type() == typeid(CStealthAddress)) |
| 965 | + { |
| 966 | + CStealthAddress sxAddr = boost::get<CStealthAddress>(dest); |
| 967 | + std::string sError; |
| 968 | + if (0 != PrepareStealthOutput(sxAddr, scriptDestination, vStealthData, sError)) { |
| 969 | + LogPrintf("%s -- PrepareStealthOutput failed. Error = %s\n", __func__, sError); |
| 970 | + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); |
| 971 | + } |
| 972 | + fStealthAddress = true; |
| 973 | + CTxDestination newDest; |
| 974 | + if (ExtractDestination(scriptDestination, newDest)) |
| 975 | + LogPrint("bdap", "%s -- Stealth send to address: %s\n", __func__, CDynamicAddress(newDest).ToString()); |
| 976 | + } |
| 977 | + else { |
| 978 | + scriptDestination = GetScriptForDestination(dest); |
| 979 | + } |
| 980 | + CScript stealthScript; |
| 981 | + if (fStealthAddress) { |
| 982 | + stealthScript << OP_RETURN << vStealthData; |
| 983 | + } |
| 984 | + // Create BDAP move asset operation script |
961 | 985 | std::vector<unsigned char> vchMoveSource = vchFromString(std::string("DYN"));
|
962 | 986 | std::vector<unsigned char> vchMoveDestination = vchFromString(std::string("BDAP"));
|
963 |
| - |
964 |
| - // Create BDAP move asset operation script |
965 | 987 | CScript scriptColorCoins;
|
966 | 988 | scriptColorCoins << CScript::EncodeOP_N(OP_BDAP_MOVE) << CScript::EncodeOP_N(OP_BDAP_ASSET)
|
967 | 989 | << vchMoveSource << vchMoveDestination << OP_2DROP << OP_2DROP;
|
968 | 990 |
|
969 |
| - CScript scriptDestination; |
970 |
| - scriptDestination = GetScriptForDestination(dest); |
971 | 991 | scriptColorCoins += scriptDestination;
|
972 | 992 |
|
973 | 993 | CWalletTx wtx;
|
974 |
| - SendColorTransaction(scriptColorCoins, wtx, nColorAmount, NULL, false, false); |
| 994 | + SendColorTransaction(scriptColorCoins, stealthScript, wtx, nColorAmount, NULL, false, false); |
975 | 995 |
|
976 | 996 | return wtx.GetHash().GetHex();
|
977 | 997 | }
|
|
0 commit comments