Electroneum
Loading...
Searching...
No Matches
MyWalletListener Struct Reference
Inheritance diagram for MyWalletListener:
Collaboration diagram for MyWalletListener:

Public Member Functions

 MyWalletListener (Electroneum::Wallet *wallet)
void reset ()
virtual void etnSpent (const string &txId, uint64_t amount)
 etnSpent - called when etn spent
virtual void etnReceived (const string &txId, uint64_t amount)
 etnReceived - called when etn received
virtual void unconfirmedETNReceived (const string &txId, uint64_t amount)
 unconfirmedETNReceived - called when payment arrived in tx pool
virtual void newBlock (uint64_t height)
 newBlock - called when new block received
virtual void updated ()
 updated - generic callback, called when any event (sent/received/block reveived/etc) happened with the wallet;
virtual void refreshed ()
 refreshed - called when wallet refreshed by background thread or explicitly refreshed by calling "refresh" synchronously
Public Member Functions inherited from Electroneum::WalletListener
virtual ~WalletListener ()=0
virtual void onDeviceButtonRequest (uint64_t code)
 called by device if the action is required
virtual void onDeviceButtonPressed ()
 called by device if the button was pressed
virtual optional< std::string > onDevicePinRequest ()
 called by device when PIN is needed
virtual optional< std::string > onDevicePassphraseRequest (bool on_device)
 called by device when passphrase entry is needed
virtual void onDeviceProgress (const DeviceProgress &event)
 Signalizes device operation progress.
virtual void onSetWallet (Wallet *wallet)
 If the listener is created before the wallet this enables to set created wallet object.

Public Attributes

Electroneum::Walletwallet
uint64_t total_tx
uint64_t total_rx
boost::mutex mutex
boost::condition_variable cv_send
boost::condition_variable cv_receive
boost::condition_variable cv_update
boost::condition_variable cv_refresh
boost::condition_variable cv_newblock
bool send_triggered
bool receive_triggered
bool newblock_triggered
bool update_triggered
bool refresh_triggered

Detailed Description

Definition at line 789 of file main.cpp.

Constructor & Destructor Documentation

◆ MyWalletListener()

MyWalletListener::MyWalletListener ( Electroneum::Wallet * wallet)
inline

Definition at line 809 of file main.cpp.

810 : total_tx(0), total_rx(0)
811 {
812 reset();
813
814 this->wallet = wallet;
815 this->wallet->setListener(this);
816 }
Electroneum::Wallet * wallet
Definition main.cpp:792
uint64_t total_rx
Definition main.cpp:794
uint64_t total_tx
Definition main.cpp:793
Here is the call graph for this function:

Member Function Documentation

◆ etnReceived()

virtual void MyWalletListener::etnReceived ( const string & txId,
uint64_t amount )
inlinevirtual

etnReceived - called when etn received

Parameters
txId- transaction id
amount- amount

Implements Electroneum::WalletListener.

Definition at line 832 of file main.cpp.

833 {
834 std::cout << "wallet: " << wallet->mainAddress() << "**** just received ETN ("
835 << txId << ", " << wallet->displayAmount(amount) << ")" << std::endl;
836 total_rx += amount;
837 receive_triggered = true;
838 cv_receive.notify_one();
839 }
bool receive_triggered
Definition main.cpp:802
boost::condition_variable cv_receive
Definition main.cpp:797

◆ etnSpent()

virtual void MyWalletListener::etnSpent ( const string & txId,
uint64_t amount )
inlinevirtual

etnSpent - called when etn spent

Parameters
txId- transaction id
amount- amount

Implements Electroneum::WalletListener.

Definition at line 823 of file main.cpp.

824 {
825 std::cerr << "wallet: " << wallet->mainAddress() << "**** just spent ETN ("
826 << txId << ", " << wallet->displayAmount(amount) << ")" << std::endl;
827 total_tx += amount;
828 send_triggered = true;
829 cv_send.notify_one();
830 }
boost::condition_variable cv_send
Definition main.cpp:796
bool send_triggered
Definition main.cpp:801

◆ newBlock()

virtual void MyWalletListener::newBlock ( uint64_t height)
inlinevirtual

newBlock - called when new block received

Parameters
height- block height

Implements Electroneum::WalletListener.

Definition at line 851 of file main.cpp.

852 {
853// std::cout << "wallet: " << wallet->mainAddress()
854// <<", new block received, blockHeight: " << height << std::endl;
855 static int bc_height = wallet->daemonBlockChainHeight();
856 std::cout << height
857 << " / " << bc_height/* 0*/
858 << std::endl;
859 newblock_triggered = true;
860 cv_newblock.notify_one();
861 }
uint64_t height
bool newblock_triggered
Definition main.cpp:803
boost::condition_variable cv_newblock
Definition main.cpp:800

◆ refreshed()

virtual void MyWalletListener::refreshed ( )
inlinevirtual

refreshed - called when wallet refreshed by background thread or explicitly refreshed by calling "refresh" synchronously

Implements Electroneum::WalletListener.

Definition at line 870 of file main.cpp.

871 {
872 std::cout << __FUNCTION__ << "Wallet refreshed";
873 refresh_triggered = true;
874 cv_refresh.notify_one();
875 }
bool refresh_triggered
Definition main.cpp:805
boost::condition_variable cv_refresh
Definition main.cpp:799

◆ reset()

void MyWalletListener::reset ( )
inline

Definition at line 818 of file main.cpp.

Here is the caller graph for this function:

◆ unconfirmedETNReceived()

virtual void MyWalletListener::unconfirmedETNReceived ( const string & txId,
uint64_t amount )
inlinevirtual

unconfirmedETNReceived - called when payment arrived in tx pool

Parameters
txId- transaction id
amount- amount

Implements Electroneum::WalletListener.

Definition at line 841 of file main.cpp.

842 {
843 std::cout << "wallet: " << wallet->mainAddress() << "**** just received unconfirmed ETN ("
844 << txId << ", " << wallet->displayAmount(amount) << ")" << std::endl;
845 // Don't trigger receive until tx is mined
846 // total_rx += amount;
847 // receive_triggered = true;
848 // cv_receive.notify_one();
849 }

◆ updated()

virtual void MyWalletListener::updated ( )
inlinevirtual

updated - generic callback, called when any event (sent/received/block reveived/etc) happened with the wallet;

Implements Electroneum::WalletListener.

Definition at line 863 of file main.cpp.

864 {
865 std::cout << __FUNCTION__ << "Wallet updated";
866 update_triggered = true;
867 cv_update.notify_one();
868 }
boost::condition_variable cv_update
Definition main.cpp:798

Member Data Documentation

◆ cv_newblock

boost::condition_variable MyWalletListener::cv_newblock

Definition at line 800 of file main.cpp.

◆ cv_receive

boost::condition_variable MyWalletListener::cv_receive

Definition at line 797 of file main.cpp.

◆ cv_refresh

boost::condition_variable MyWalletListener::cv_refresh

Definition at line 799 of file main.cpp.

◆ cv_send

boost::condition_variable MyWalletListener::cv_send

Definition at line 796 of file main.cpp.

◆ cv_update

boost::condition_variable MyWalletListener::cv_update

Definition at line 798 of file main.cpp.

◆ mutex

boost::mutex MyWalletListener::mutex

Definition at line 795 of file main.cpp.

◆ newblock_triggered

bool MyWalletListener::newblock_triggered

Definition at line 803 of file main.cpp.

◆ receive_triggered

bool MyWalletListener::receive_triggered

Definition at line 802 of file main.cpp.

◆ refresh_triggered

bool MyWalletListener::refresh_triggered

Definition at line 805 of file main.cpp.

◆ send_triggered

bool MyWalletListener::send_triggered

Definition at line 801 of file main.cpp.

◆ total_rx

uint64_t MyWalletListener::total_rx

Definition at line 794 of file main.cpp.

◆ total_tx

uint64_t MyWalletListener::total_tx

Definition at line 793 of file main.cpp.

◆ update_triggered

bool MyWalletListener::update_triggered

Definition at line 804 of file main.cpp.

◆ wallet

Electroneum::Wallet* MyWalletListener::wallet

Definition at line 792 of file main.cpp.


The documentation for this struct was generated from the following file:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/tests/libwallet_api_tests/main.cpp