24 #include <jsonrpccpp/common/errors.h> 25 #include <jsonrpccpp/common/exception.h> 39 Whisper::Whisper(
WebThreeDirect& _web3, std::vector<dev::KeyPair>
const& _accounts): m_web3(_web3)
48 m_ids[i.pub()] = i.secret();
64 cwarn <<
"Silently signing message from identity" << m.
from() <<
": User validation hook goes here.";
74 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
93 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
117 m_watches.insert(make_pair(ret, w.second));
122 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
135 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
147 if (!pub ||
m_ids.count(pub))
154 cwarn <<
"Silently decrypting message from identity" << pub <<
": User validation hook goes here.";
155 m =
e.open(
shh()->fullTopics(
id),
m_ids[pub]);
158 m =
e.open(
shh()->fullTopics(
id));
168 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
180 if (!pub ||
m_ids.count(pub))
187 cwarn <<
"Silently decrypting message from identity" << pub <<
": User validation hook goes here.";
188 m =
e.open(
shh()->fullTopics(
id),
m_ids[pub]);
191 m =
e.open(
shh()->fullTopics(
id));
200 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
virtual std::string shh_newFilter(Json::Value const &_json) override
virtual bool shh_uninstallFilter(std::string const &_filterId) override
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
virtual h256s checkWatch(unsigned _watchId)=0
virtual Envelope envelope(h256 _m) const =0
shh::Interface * shh() const
virtual h256s watchMessages(unsigned _watchId)=0
virtual void setIdentities(std::vector< dev::KeyPair > const &_ids)
virtual void uninstallWatch(unsigned _watchId)=0
pair< shh::Topics, Public > toWatch(Json::Value const &_json)
Simple class that represents a "key pair".
static KeyPair create()
Create a new, randomly generated object.
std::hash for asio::adress
Main API hub for interfacing with Web 3 components.
Secret const & secret() const
virtual bool shh_post(Json::Value const &_json) override
virtual std::string shh_newIdentity() override
Public const & pub() const
Retrieve the public key.
virtual std::string shh_newGroup(std::string const &_id, std::string const &_who) override
virtual Json::Value shh_getFilterChanges(std::string const &_filterId) override
std::shared_ptr< shh::WhisperHost > whisper() const
std::string toJS(FixedHash< S > const &_h)
virtual std::string shh_addToGroup(std::string const &_group, std::string const &_who) override
Public jsToPublic(std::string const &_s)
Leniently convert string to Public (h512). Accepts integers, "0x" prefixing, non-exact length...
virtual void inject(Envelope const &_m, WhisperPeer *_from=nullptr)=0
virtual bool shh_hasIdentity(std::string const &_identity) override
Json::Value toJson(unordered_map< u256, u256 > const &_storage)
virtual unsigned installWatch(Topics const &_filter)=0
An (unencrypted) message, constructed from the combination of an Envelope, and, potentially, a Secret key to decrypt the Message.
shh::Message toMessage(Json::Value const &_json)
virtual Json::Value shh_getMessages(std::string const &_filterId) override
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< N *8, N *8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void > > jsToInt(std::string const &_s)
Convert a string representation of a number to an int String can be a normal decimal number...
shh::Envelope toSealed(Json::Value const &_json, shh::Message const &_m, Secret const &_from)
std::map< unsigned, dev::Public > m_watches
std::map< dev::Public, dev::Secret > m_ids