diff --git a/doc/tapyrus/colored_coin_gui.md b/doc/tapyrus/colored_coin_gui.md new file mode 100644 index 0000000000..e9b8a2461d --- /dev/null +++ b/doc/tapyrus/colored_coin_gui.md @@ -0,0 +1,27 @@ +## Tapyrus core GUI + +Tapyrus GUI has been enhanced to allow Token transactions. Following are the changes made + +### Overview Page +Overview in the new Tapyrus GUI shows tokens as well. _Prev_ and _Next_ buttons can be used to scroll through all the available tokens. Only TPC is shown when no other tokens are available. + +![Overview Page with token](./images/Tapyrus-overview-token.png) + +### Send Token +Sending a token is the same as sending TPC except that the new address must have been generated with the colorid + +> ./src/tapyrus-cli -conf=~/.tapyrus/ getnewaddress "NFT" c3b8b7e3a2684c746d367420bd0899104005cfeeb59705a3f402fa37312f402624 + +Then the token lable would be populated automatically and "TOKEN" would be set in the token type drop down. +![Send coin page with token](./images/Tapyrus-send-token.png) + +### Receive Token +Receiving tokens is also similar to receiving TPC. In addition to lable, message and amount, Token should also be populated. +![Receive token page](./images/Tapyrus-receive-token.png) + +A new entry is added to the payment history table after the address is generated. +![Received payment dialog](./images/Tapyrus-receive-dialog.png) + +A new column called Token is added to the transaction table. It shows the token name or TPC for every transaction output. Amount column for TPC is formatted according to wallet setting. For tokens, it is always the number of tokens. + +![Transaction page](./images/Tapyrus-transaction-page.png) \ No newline at end of file diff --git a/doc/tapyrus/images/Tapyrus-overview-token.png b/doc/tapyrus/images/Tapyrus-overview-token.png new file mode 100644 index 0000000000..9e60ece524 Binary files /dev/null and b/doc/tapyrus/images/Tapyrus-overview-token.png differ diff --git a/doc/tapyrus/images/Tapyrus-receive-token.png b/doc/tapyrus/images/Tapyrus-receive-token.png new file mode 100644 index 0000000000..7af9ae3ed5 Binary files /dev/null and b/doc/tapyrus/images/Tapyrus-receive-token.png differ diff --git a/doc/tapyrus/images/Tapyrus-send-token.png b/doc/tapyrus/images/Tapyrus-send-token.png new file mode 100644 index 0000000000..8ce67bfbcc Binary files /dev/null and b/doc/tapyrus/images/Tapyrus-send-token.png differ diff --git a/doc/tapyrus/images/Tapyrus-transaction-page.png b/doc/tapyrus/images/Tapyrus-transaction-page.png new file mode 100644 index 0000000000..ee9553779a Binary files /dev/null and b/doc/tapyrus/images/Tapyrus-transaction-page.png differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e10770814a..b13ca3b93c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,9 +15,7 @@ option(BUILD_TAPYRUS_SEEDER "Build tapyrus-seeder" ON) option(BUILD_TAPYRUS_CLI "Build tapyrus-cli" ON) option(BUILD_TAPYRUS_GENESIS "Build tapyrus-genesis" ON) option(BUILD_TAPYRUS_TX "Build tapyrus-tx" ON) - -# TODO: Fix qt building problem and turn ON. -option(BUILD_TAPYRUS_QT "Build tapyrus-qt" ON) +option(ENABLE_QRCODE "Build QR support in wallet" OFF) # Ensure that WINDRES_PREPROC is enabled when using windres. if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") @@ -308,4 +306,4 @@ if(BUILD_TAPYRUS_QT) add_subdirectory(qt) endif() -message(status "BUILD_TAPYRUS_QT=${BUILD_TAPYRUS_QT}") \ No newline at end of file +message(STATUS "BUILD_TAPYRUS_QT=${BUILD_TAPYRUS_QT}") \ No newline at end of file diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt index 0293f3b631..82f9e2ea92 100644 --- a/src/config/CMakeLists.txt +++ b/src/config/CMakeLists.txt @@ -150,5 +150,12 @@ set(ENABLE_WALLET ${BUILD_TAPYRUS_WALLET}) # Activate ZeroMQ set(ENABLE_ZMQ ${BUILD_TAPYRUS_ZMQ}) +# Try to find libqrencode + # Only used in the wallet GUI + if(ENABLE_QRCODE AND BUILD_BITCOIN_WALLET AND BUILD_BITCOIN_QT) + find_package(QREncode REQUIRED) + set(USE_QRCODE 1 CACHE INTERNAL "QR code is enabled") + endif() + # Generate the config configure_file(bitcoin-config.h.cmake.in bitcoin-config.h ESCAPE_QUOTES) diff --git a/src/config/bitcoin-config.h.cmake.in b/src/config/bitcoin-config.h.cmake.in index 0acdedcd99..249deccfb2 100644 --- a/src/config/bitcoin-config.h.cmake.in +++ b/src/config/bitcoin-config.h.cmake.in @@ -60,5 +60,6 @@ #cmakedefine ENABLE_WALLET 1 #cmakedefine ENABLE_ZMQ 1 +#cmakedefine ENABLE_QRCODE 0 #endif // BITCOIN_BITCOIN_CONFIG_H diff --git a/src/interfaces/node.h b/src/interfaces/node.h index 77f587e33b..f5f7f09f33 100644 --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -9,6 +9,7 @@ #include // For CAmount #include // For CConnman::NumConnections #include // For Network +#include #include #include @@ -21,7 +22,6 @@ class CCoinControl; class CFeeRate; class CNodeStats; -class Coin; class RPCTimerInterface; class UniValue; class proxyType; diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp index ef6d0a1b80..3a15be24a4 100644 --- a/src/interfaces/wallet.cpp +++ b/src/interfaces/wallet.cpp @@ -58,7 +58,7 @@ class PendingWalletTxImpl : public PendingWalletTx }; //! Construct wallet tx struct. -WalletTx MakeWalletTx(CWallet& wallet, const CWalletTx& wtx) +WalletTx MakeWalletTx(Node& node, CWallet& wallet, const CWalletTx& wtx) { WalletTx result; result.tx = wtx.tx; @@ -83,11 +83,13 @@ WalletTx MakeWalletTx(CWallet& wallet, const CWalletTx& wtx) result.time = wtx.GetTxTime(); result.value_map = wtx.mapValue; result.is_coinbase = wtx.IsCoinBase(); + result.is_tokenInput = result.isTokenInput(node); + result.is_tokenOutput = result.isTokenOutput(); return result; } //! Construct wallet tx status struct. -WalletTxStatus MakeWalletTxStatus(const CWalletTx& wtx) +WalletTxStatus MakeWalletTxStatus(Node& node, const CWalletTx& wtx) { WalletTxStatus result; auto mi = ::mapBlockIndex.find(wtx.hashBlock); @@ -274,26 +276,26 @@ class WalletImpl : public Wallet } return {}; } - WalletTx getWalletTx(const uint256& txid) override + WalletTx getWalletTx(Node& node, const uint256& txid) override { LOCK2(::cs_main, m_wallet.cs_wallet); auto mi = m_wallet.mapWallet.find(txid); if (mi != m_wallet.mapWallet.end()) { - return MakeWalletTx(m_wallet, mi->second); + return MakeWalletTx(node, m_wallet, mi->second); } return {}; } - std::vector getWalletTxs() override + std::vector getWalletTxs(Node& node) override { LOCK2(::cs_main, m_wallet.cs_wallet); std::vector result; result.reserve(m_wallet.mapWallet.size()); for (const auto& entry : m_wallet.mapWallet) { - result.emplace_back(MakeWalletTx(m_wallet, entry.second)); + result.emplace_back(MakeWalletTx(node, m_wallet, entry.second)); } return result; } - bool tryGetTxStatus(const uint256& txid, + bool tryGetTxStatus(Node& node, const uint256& txid, interfaces::WalletTxStatus& tx_status, int& num_blocks, int64_t& adjusted_time) override @@ -312,10 +314,10 @@ class WalletImpl : public Wallet } num_blocks = ::chainActive.Height(); adjusted_time = GetAdjustedTime(); - tx_status = MakeWalletTxStatus(mi->second); + tx_status = MakeWalletTxStatus(node, mi->second); return true; } - WalletTx getWalletTxDetails(const uint256& txid, + WalletTx getWalletTxDetails(Node& node, const uint256& txid, WalletTxStatus& tx_status, WalletOrderForm& order_form, bool& in_mempool, @@ -329,8 +331,8 @@ class WalletImpl : public Wallet adjusted_time = GetAdjustedTime(); in_mempool = mi->second.InMempool(); order_form = mi->second.vOrderForm; - tx_status = MakeWalletTxStatus(mi->second); - return MakeWalletTx(m_wallet, mi->second); + tx_status = MakeWalletTxStatus(node, mi->second); + return MakeWalletTx(node, m_wallet, mi->second); } return {}; } @@ -358,10 +360,10 @@ class WalletImpl : public Wallet num_blocks = ::chainActive.Height(); return true; } - CAmount getBalance() override { return m_wallet.GetBalance()[ColorIdentifier()]; } - CAmount getAvailableBalance(const CCoinControl& coin_control) override + CAmount getBalance(ColorIdentifier colorId) override { return m_wallet.GetBalance()[colorId]; } + CAmount getAvailableBalance(const CCoinControl& coin_control, ColorIdentifier colorId) override { - return m_wallet.GetAvailableBalance(&coin_control)[ColorIdentifier()]; + return m_wallet.GetAvailableBalance(&coin_control)[colorId]; } isminetype txinIsMine(const CTxIn& txin) override { diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index 7a1c3efec5..9f337c65c4 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -11,6 +11,7 @@ #include