38 return AreMessagingDeployed() ?
"" :
"\nTHIS COMMAND IS NOT YET ACTIVE!\nhttps://github.com/RavenProject/rips/blob/master/rip-0005.mediawiki\n";
43 throw std::runtime_error(
46 "\nView all messages that the wallet contains\n" 49 "\"Asset Name:\" (string) The name of the asset the message was sent on\n" 50 "\"Message:\" (string) The IPFS hash of the message\n" 51 "\"Time:\" (Date) The time as a date in the format (YY-mm-dd Hour-minute-second)\n" 52 "\"Block Height:\" (number) The height of the block the message was included in\n" 53 "\"Status:\" (string) Status of the message (READ, UNREAD, ORPHAN, EXPIRED, SPAM, HIDDEN, ERROR)\n" 54 "\"Expire Time:\" (Date, optional) If the message had an expiration date assigned, it will be shown here in the format (YY-mm-dd Hour-minute-second)\n" 55 "\"Expire UTC Time:\" (Date, optional) If the message contains an expire date that is too large, the UTC number will be displayed\n" 65 ret.
push_back(
"Messaging is disabled. To enable messaging, run the wallet without -disablemessaging or remove disablemessaging from your raven.conf");
71 ret.
push_back(
"Messaging database and cache are having problems (a wallet restart might fix this issue)");
75 std::set<CMessage> setMessages;
82 if (setMessages.count(message))
83 setMessages.erase(message);
84 setMessages.insert(message);
90 setMessages.erase(message);
94 setMessages.erase(pair.second);
95 setMessages.insert(pair.second);
100 for (
auto message : setMessages) {
103 obj.
push_back(Pair(
"Asset Name", message.strName));
106 obj.
push_back(Pair(
"Block Height", message.nBlockHeight));
110 if (message.nExpiredTime)
111 obj.
push_back(Pair(
"Expire Time", date));
113 obj.
push_back(Pair(
"Expire UTC Time", message.nExpiredTime));
125 throw std::runtime_error(
126 "viewallmessagechannels \n" 128 "\nView all message channels the wallet is subscribed to\n" 131 "\"Asset Name\" (string) The asset channel name\n" 140 ret.
push_back(
"Messaging is disabled. To enable messaging, run the wallet without -disablemessaging or remove disablemessaging from your raven.conf");
146 ret.
push_back(
"Messaging channel database and cache are having problems (a wallet restart might fix this issue)");
150 std::set<std::string> setChannels;
157 setChannels.erase(name);
161 setChannels.insert(name);
166 for (
auto name : setChannels) {
175 throw std::runtime_error(
176 "subscribetochannel \n" 178 "\nSubscribe to a certain message channel\n" 181 "1. \"channel_name\" (string, required) The channel name to subscribe to, it must end with '!' or have an '~' in the name\n" 191 throw JSONRPCError(
RPC_DATABASE_ERROR,
"Messaging is disabled. To enable messaging, run the wallet without -disablemessaging or remove disablemessaging from your raven.conf");
215 RPC_INVALID_PARAMETER,
"Channel Name must be a owner asset, or a message channel asset e.g OWNER!, MSG_CHANNEL~123.");
219 return "Subscribed to channel: " + channel_name;
225 throw std::runtime_error(
226 "unsubscribefromchannel \n" 228 "\nUnsubscribe from a certain message channel\n" 231 "1. \"channel_name\" (string, required) The channel name to unsubscribe from, must end with '!' or have an '~' in the name\n" 241 throw JSONRPCError(
RPC_DATABASE_ERROR,
"Messaging is disabled. To enable messaging, run the wallet without -disablemessaging or remove disablemessaging from your raven.conf");
266 RPC_INVALID_PARAMETER,
"Channel Name must be a owner asset, or a message channel asset e.g OWNER!, MSG_CHANNEL~123.");
270 return "Unsubscribed from channel: " + channel_name;
275 throw std::runtime_error(
278 "\nDelete current database of messages\n" 288 throw JSONRPCError(
RPC_DATABASE_ERROR,
"Messaging is disabled. To enable messaging, run the wallet without -disablemessaging or remove disablemessaging from your raven.conf");
304 return "Erased " + std::to_string(count) +
" Messages from the database and cache";
309 throw std::runtime_error(
310 "sendmessage \"channel_name\" \"ipfs_hash\" (expire_time)\n" 312 "\nCreates and broadcasts a message transaction to the network for a channel this wallet owns" 315 "1. \"channel_name\" (string, required) Name of the channel that you want to send a message with (message channel, administrator asset), if a non administrator asset name is given, the administrator '!' will be added to it\n" 316 "2. \"ipfs_hash\" (string, required) The IPFS hash of the message\n" 317 "3. \"expire_time\" (numeric, optional) UTC timestamp of when the message expires\n" 324 +
HelpExampleCli(
"sendmessage",
"\"ASSET_NAME!\" \"QmTqu3Lk3gmTsQVtjU7rYYM37EAW4xNmbuEAp2Mjr4AV7E\" 15863654")
325 +
HelpExampleCli(
"sendmessage",
"\"ASSET_NAME!\" \"QmTqu3Lk3gmTsQVtjU7rYYM37EAW4xNmbuEAp2Mjr4AV7E\" 15863654")
341 if (ipfs_hash.length() != 46)
343 if (ipfs_hash.substr(0, 2) !=
"Qm")
346 int64_t expire_time = 0;
352 std::string strNameError;
363 std::pair<int, std::string>
error;
364 std::vector< std::pair<CAssetTransfer, std::string> >vTransfers;
366 std::map<std::string, std::vector<COutput> > mapAssetCoins;
369 if (!mapAssetCoins.count(asset_name)) {
375 ExtractDestination(mapAssetCoins.at(asset_name)[0].tx->tx->vout[mapAssetCoins.at(asset_name)[0].i].scriptPubKey, dest);
407 {
"messages",
"sendmessage", &
sendmessage, {
"channel",
"ipfs_hash",
"expire_time"}},
413 for (
unsigned int vcidx = 0; vcidx <
ARRAYLEN(commands); vcidx++)
std::set< COutPoint > setDirtyMessagesRemove
#define OWNER_ASSET_AMOUNT
void AddChannel(const std::string &name)
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
Raven RPC command dispatcher.
bool LoadMessages(std::set< CMessage > &setMessages)
CCriticalSection cs_wallet
bool CreateTransferAssetTransaction(CWallet *pwallet, const CCoinControl &coinControl, const std::vector< std::pair< CAssetTransfer, std::string > >vTransfers, const std::string &changeAddress, std::pair< int, std::string > &error, CWalletTx &wtxNew, CReserveKey &reservekey, CAmount &nFeeRequired, std::vector< std::pair< CNullAssetTxData, std::string > > *nullAssetTxData, std::vector< CNullAssetTxData > *nullGlobalRestrictionData)
Create a transfer asset transaction.
bool EnsureWalletIsAvailable(CWallet *const pwallet, bool avoidException)
std::string DateTimeStrFormat(const char *pszFormat, int64_t nTime)
CMessageChannelDB * pmessagechanneldb
Global variable that points to the message channel database (protected by cs_main) ...
CCriticalSection cs_main
Global state.
const std::string & get_str() const
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
UniValue clearmessages(const JSONRPCRequest &request)
int64_t get_int64() const
UniValue viewallmessagechannels(const JSONRPCRequest &request)
bool EraseAllMessages(int &count)
bool appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
CLRUCache< std::string, int > * pMessageSubscribedChannelsCache
Global variable that points to the subscribed channel LRU Cache (protected by cs_main) ...
Invalid, missing or duplicate parameter.
int64_t CAmount
Amount in corbies (Can be negative)
CLRUCache< std::string, CMessage > * pMessagesCache
Global variable that points to the subscribed channel LRU Cache (protected by cs_main) ...
bool AreMessagingDeployed()
std::set< std::string > setDirtyChannelsRemove
bool IsAssetNameValid(const std::string &name, AssetType &assetType, std::string &error)
std::string DecodeAssetData(std::string encoded)
Decode and Encode IPFS hashes, or OIP hashes.
bool push_back(const UniValue &val)
CMessageDB * pmessagedb
Global variable that points to the messages database (protected by cs_main)
std::map< COutPoint, CMessage > mapDirtyMessagesOrphaned
std::string MessageActivationWarning()
UniValue sendmessage(const JSONRPCRequest &request)
bool LoadMyMessageChannels(std::set< std::string > &setChannels)
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
void RegisterMessageRPCCommands(CRPCTable &t)
Register message RPC commands.
bool SendAssetTransaction(CWallet *pwallet, CWalletTx &transaction, CReserveKey &reserveKey, std::pair< int, std::string > &error, std::string &txid)
Send any type of asset transaction to the network.
std::map< COutPoint, CMessage > mapDirtyMessagesAdd
A transaction with a bunch of additional info that only the owner cares about.
void AvailableAssets(std::map< std::string, std::vector< COutput > > &mapAssetCoins, bool fOnlySafe=true, const CCoinControl *coinControl=nullptr, const CAmount &nMinimumAmount=1, const CAmount &nMaximumAmount=MAX_MONEY, const CAmount &nMinimumSumAmount=MAX_MONEY, const uint64_t &nMaximumCount=0, const int &nMinDepth=0, const int &nMaxDepth=9999999) const
Helper function that calls AvailableCoinsAll, used for transfering assets.
std::string EncodeDestination(const CTxDestination &dest)
A key allocated from the key pool.
std::string MessageStatusToString(MessageStatus status)
UniValue viewallmessages(const JSONRPCRequest &request)
UniValue subscribetochannel(const JSONRPCRequest &request)
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
const UniValue NullUniValue
CWallet * GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
bool error(const char *fmt, const Args &... args)
std::set< std::string > setDirtyChannelsAdd
UniValue JSONRPCError(int code, const std::string &message)
void RemoveChannel(const std::string &name)
std::string EncodeAssetData(std::string decoded)
void EnsureWalletIsUnlocked(CWallet *const pwallet)
UniValue unsubscribefromchannel(const JSONRPCRequest &request)