Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions doc/tapyrus/colored_coin_gui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## 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. TPC is in view when the gui starts. _Prev_ and _Next_ buttons can be used to scroll through all the available tokens. When no other tokens are available only TPC is visible.

![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)

Binary file added doc/tapyrus/images/Tapyrus-overview-token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/tapyrus/images/Tapyrus-send-token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -308,4 +306,4 @@ if(BUILD_TAPYRUS_QT)
add_subdirectory(qt)
endif()

message(status "BUILD_TAPYRUS_QT=${BUILD_TAPYRUS_QT}")
message(STATUS "BUILD_TAPYRUS_QT=${BUILD_TAPYRUS_QT}")
7 changes: 7 additions & 0 deletions src/config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions src/config/bitcoin-config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@

#cmakedefine ENABLE_WALLET 1
#cmakedefine ENABLE_ZMQ 1
#cmakedefine ENABLE_QRCODE 0

#endif // BITCOIN_BITCOIN_CONFIG_H
6 changes: 3 additions & 3 deletions src/interfaces/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,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
{
Expand Down
70 changes: 60 additions & 10 deletions src/interfaces/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ class Wallet
virtual bool tryGetBalances(WalletBalances& balances, int& num_blocks) = 0;

//! Get balance.
virtual CAmount getBalance() = 0;
virtual CAmount getBalance(ColorIdentifier colorId = ColorIdentifier()) = 0;

//! Get available balance.
virtual CAmount getAvailableBalance(const CCoinControl& coin_control) = 0;
virtual CAmount getAvailableBalance(const CCoinControl& coin_control, ColorIdentifier colorId = ColorIdentifier()) = 0;

//! Return whether transaction input belongs to wallet.
virtual isminetype txinIsMine(const CTxIn& txin) = 0;
Expand Down Expand Up @@ -311,32 +311,35 @@ struct WalletBalances
bool have_watch_only;
TxColoredCoinBalancesMap watch_only_balances;
TxColoredCoinBalancesMap unconfirmed_watch_only_balances;
std::set<ColorIdentifier> tokens;
std::set<ColorIdentifier>::iterator tokenIndex;

WalletBalances(){
have_watch_only = false;
tokenIndex = tokens.begin();
}

CAmount getBalance(const ColorIdentifier& colorId = ColorIdentifier()) const
CAmount getBalance() const
{
auto it = balances.find(colorId);
auto it = balances.find(*tokenIndex);
return it != balances.end() ? it->second : 0;
}

CAmount getUnconfirmedBalance(const ColorIdentifier& colorId = ColorIdentifier()) const
CAmount getUnconfirmedBalance() const
{
auto it = unconfirmed_balances.find(colorId);
auto it = unconfirmed_balances.find(*tokenIndex);
return it != unconfirmed_balances.end() ? it->second : 0;
}

CAmount getWatchOnlyBalance(const ColorIdentifier& colorId = ColorIdentifier()) const
CAmount getWatchOnlyBalance() const
{
auto it = watch_only_balances.find(colorId);
auto it = watch_only_balances.find(*tokenIndex);
return it != watch_only_balances.end() ? it->second : 0;
}

CAmount getUnconfirmedWatchOnlyBalance(const ColorIdentifier& colorId = ColorIdentifier()) const
CAmount getUnconfirmedWatchOnlyBalance() const
{
auto it = unconfirmed_watch_only_balances.find(colorId);
auto it = unconfirmed_watch_only_balances.find(*tokenIndex);
return it != unconfirmed_watch_only_balances.end() ? it->second : 0;
}

Expand All @@ -346,6 +349,53 @@ struct WalletBalances
watch_only_balances != prev.watch_only_balances ||
unconfirmed_watch_only_balances != prev.unconfirmed_watch_only_balances;
}

//collect all tokens in the wallet from all the balance lists
void refreshTokens() {
tokens.clear();

for(auto pair:balances)
tokens.insert(pair.first);
for(auto pair:unconfirmed_balances)
tokens.insert(pair.first);
for(auto pair:watch_only_balances)
tokens.insert(pair.first);
for(auto pair:unconfirmed_watch_only_balances)
tokens.insert(pair.first);

tokenIndex = tokens.begin();
}

void prev()
{
if(tokenIndex != tokens.begin())
tokenIndex--;
else
{
tokenIndex = tokens.end();
tokenIndex--;
}
}

void next()
{
if(tokenIndex != tokens.end())
{
tokenIndex++;
if(tokenIndex == tokens.end())
tokenIndex = tokens.begin();
}
}

bool isToken()
{
return (*tokenIndex).type != TokenTypes::NONE;
}

std::string getTokenName()
{
return (*tokenIndex).toHexString();
}
};

// Wallet transaction information.
Expand Down
18 changes: 18 additions & 0 deletions src/key_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,21 @@ bool IsValidDestinationString(const std::string& str)
{
return IsValidDestinationString(str, Params());
}

bool IsColoredDestination(const std::string& str, ColorIdentifier* colorId)
{
CTxDestination dest = DecodeDestination(str, Params());
if(dest.which() == 3)
{
if(colorId)
*colorId = boost::get<CColorKeyID>(dest).color;
return true;
}
else if(dest.which() == 4)
{
if(colorId)
*colorId = boost::get<CColorScriptID>(dest).color;
return true;
}
return false;
}
1 change: 1 addition & 0 deletions src/key_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ std::string EncodeDestination(const CTxDestination& dest);
CTxDestination DecodeDestination(const std::string& str);
bool IsValidDestinationString(const std::string& str);
bool IsValidDestinationString(const std::string& str, const CChainParams& params);
bool IsColoredDestination(const std::string& str, ColorIdentifier* colorId);

#endif // BITCOIN_KEY_IO_H
42 changes: 28 additions & 14 deletions src/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
project(tapyrus-qt)

# This ensure that AUTOMOC doesn't run on generated files.
cmake_policy(SET CMP0071 OLD)
cmake_policy(SET CMP0071 NEW)

include(BrewHelper)
find_brew_prefix(QT5_PREFIX qt5)

set(QT_REQUIRED_COMPONENTS Core Widgets Network DBus Test)
find_package(Qt5 COMPONENTS ${QT_REQUIRED_COMPONENTS} REQUIRED HINTS "${QT5_PREFIX}")

find_package(QREncode REQUIRED)

# Find out more about Qt. This is similar to
# http://code.qt.io/cgit/qt/qtwebkit.git/tree/Source/cmake/OptionsQt.cmake
get_target_property(QT_CORE_TYPE Qt5::Core TYPE)
Expand Down Expand Up @@ -157,30 +155,41 @@ add_library(tapyrus-qt-base
qrc_tapyrus_locale.cpp
)

# Linux support
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
list(APPEND QT_PLUGIN_COMPONENTS QXcbIntegrationPlugin)
list(APPEND QT_PLUGIN_PLATFORM_DEFINITIONS -DQT_QPA_PLATFORM_XCB=1)
endif()
# Windows support
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
list(APPEND QT_PLUGIN_COMPONENTS QWindowsIntegrationPlugin)
list(APPEND QT_PLUGIN_PLATFORM_DEFINITIONS -DQT_QPA_PLATFORM_WINDOWS=1)
target_sources(tapyrus-qt-base PRIVATE winshutdownmonitor.cpp)
endif()

target_include_directories(tapyrus-qt-base
PUBLIC
.
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/forms
)
# OSX support
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
list(APPEND QT_PLUGIN_COMPONENTS QCocoaIntegrationPlugin)
list(APPEND QT_PLUGIN_PLATFORM_DEFINITIONS -DQT_QPA_PLATFORM_COCOA=1)
target_sources(tapyrus-qt-base PRIVATE
macdockiconhandler.mm
macnotificationhandler.mm
)
set_property(TARGET tapyrus-qt-base PROPERTY AUTOMOC_MOC_OPTIONS "-DQ_OS_MAC")
target_link_libraries(tapyrus-qt-base
"-framework Foundation"
"-framework ApplicationServices"
"-framework AppKit"
)
endif()

target_link_libraries(tapyrus-qt-base
server
rpcclient
Qt5::Widgets
Qt5::Network
Qt5::DBus
qrencode
)

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set_property(TARGET tapyrus-qt-base PROPERTY AUTOMOC_MOC_OPTIONS "-DQ_OS_MAC")
endif()

# Wallet
if(BUILD_TAPYRUS_WALLET)
Expand Down Expand Up @@ -218,6 +227,11 @@ if(BUILD_TAPYRUS_WALLET)
)

target_link_libraries(tapyrus-qt-base wallet)

if(ENABLE_QRCODE)
find_package(QREncode REQUIRED)
target_link_libraries(tapyrus-qt-base QREncode::qrencode)
endif()
endif()

# The executable
Expand Down
2 changes: 1 addition & 1 deletion src/qt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Represents the view to a single wallet.

* UI elements like BitcoinAmountField, which inherit from QWidget.
* `bitcoinstrings.cpp`: automatically generated
* `bitcoinunits.(h/cpp)`: TPC / mTPC / etc handling
* `TapyrusUnits.(h/cpp)`: TPC / mTPC / etc handling
* `callback.h`
* `guiconstants.h`: UI colors, app name, etc
* `guiutil.h`: several helper functions
Expand Down
10 changes: 5 additions & 5 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,13 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, int heig
void ClientModel::subscribeToCoreSignals()
{
// Connect signals to client
m_handler_show_progress = m_node.handleShowProgress(boost::bind(ShowProgress, this, _1, _2));
m_handler_notify_num_connections_changed = m_node.handleNotifyNumConnectionsChanged(boost::bind(NotifyNumConnectionsChanged, this, _1));
m_handler_notify_network_active_changed = m_node.handleNotifyNetworkActiveChanged(boost::bind(NotifyNetworkActiveChanged, this, _1));
m_handler_show_progress = m_node.handleShowProgress(boost::bind(ShowProgress, this, boost::placeholders::_1, boost::placeholders::_2));
m_handler_notify_num_connections_changed = m_node.handleNotifyNumConnectionsChanged(boost::bind(NotifyNumConnectionsChanged, this, boost::placeholders::_1));
m_handler_notify_network_active_changed = m_node.handleNotifyNetworkActiveChanged(boost::bind(NotifyNetworkActiveChanged, this, boost::placeholders::_1));
m_handler_notify_alert_changed = m_node.handleNotifyAlertChanged(boost::bind(NotifyAlertChanged, this));
m_handler_banned_list_changed = m_node.handleBannedListChanged(boost::bind(BannedListChanged, this));
m_handler_notify_block_tip = m_node.handleNotifyBlockTip(boost::bind(BlockTipChanged, this, _1, _2, _3, _4, false));
m_handler_notify_header_tip = m_node.handleNotifyHeaderTip(boost::bind(BlockTipChanged, this, _1, _2, _3, _4, true));
m_handler_notify_block_tip = m_node.handleNotifyBlockTip(boost::bind(BlockTipChanged, this, boost::placeholders::_1, boost::placeholders::_2, boost::placeholders::_3, boost::placeholders::_4, false));
m_handler_notify_header_tip = m_node.handleNotifyHeaderTip(boost::bind(BlockTipChanged, this, boost::placeholders::_1, boost::placeholders::_2, boost::placeholders::_3, boost::placeholders::_4, true));
}

void ClientModel::unsubscribeFromCoreSignals()
Expand Down
16 changes: 8 additions & 8 deletions src/qt/coincontroldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void CoinControlDialog::showMenu(const QPoint &point)
// context menu action: copy amount
void CoinControlDialog::copyAmount()
{
GUIUtil::setClipboard(BitcoinUnits::removeSpaces(contextMenuItem->text(COLUMN_AMOUNT)));
GUIUtil::setClipboard(TapyrusUnits::removeSpaces(contextMenuItem->text(COLUMN_AMOUNT)));
}

// context menu action: copy label
Expand Down Expand Up @@ -535,7 +535,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
}

// actually update labels
int nDisplayUnit = BitcoinUnits::TPC;
int nDisplayUnit = TapyrusUnits::TPC;
if (model && model->getOptionsModel())
nDisplayUnit = model->getOptionsModel()->getDisplayUnit();

Expand All @@ -555,12 +555,12 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)

// stats
l1->setText(QString::number(nQuantity)); // Quantity
l2->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAmount)); // Amount
l3->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nPayFee)); // Fee
l4->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAfterFee)); // After Fee
l2->setText(TapyrusUnits::formatWithUnit(nDisplayUnit, nAmount)); // Amount
l3->setText(TapyrusUnits::formatWithUnit(nDisplayUnit, nPayFee)); // Fee
l4->setText(TapyrusUnits::formatWithUnit(nDisplayUnit, nAfterFee)); // After Fee
l5->setText(((nBytes > 0) ? ASYMP_UTF8 : "") + QString::number(nBytes)); // Bytes
l7->setText(fDust ? tr("yes") : tr("no")); // Dust
l8->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nChange)); // Change
l8->setText(TapyrusUnits::formatWithUnit(nDisplayUnit, nChange)); // Change
if (nPayFee > 0)
{
l3->setText(ASYMP_UTF8 + l3->text());
Expand Down Expand Up @@ -682,7 +682,7 @@ void CoinControlDialog::updateView()
}

// amount
itemOutput->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, out.txout.nValue));
itemOutput->setText(COLUMN_AMOUNT, TapyrusUnits::format(nDisplayUnit, out.txout.nValue));
itemOutput->setData(COLUMN_AMOUNT, Qt::UserRole, QVariant((qlonglong)out.txout.nValue)); // padding so that sorting works correctly

// date
Expand Down Expand Up @@ -716,7 +716,7 @@ void CoinControlDialog::updateView()
if (treeMode)
{
itemWalletAddress->setText(COLUMN_CHECKBOX, "(" + QString::number(nChildren) + ")");
itemWalletAddress->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, nSum));
itemWalletAddress->setText(COLUMN_AMOUNT, TapyrusUnits::format(nDisplayUnit, nSum));
itemWalletAddress->setData(COLUMN_AMOUNT, Qt::UserRole, QVariant((qlonglong)nSum));
}
}
Expand Down
Loading