Skip to content

Commit

Permalink
GUI/NetWatch: Update for Bech32
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Sep 29, 2021
1 parent 04fa671 commit 3fbc22b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/qt/netwatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ NetWatchLogSearch::NetWatchLogSearch(const QString& query, int display_unit) :

m_check_type = m_query.length() < 4 && reType.exactMatch(m_query);
m_check_id = m_query.length() <= 64 && reHex.exactMatch(m_query);
m_check_addr = m_query.length() <= nLongestAddress;
m_check_addr = m_query.length() <= LONGEST_BECH32_ADDRESS;
CAmount val;
m_check_value = BitcoinUnits::parse(display_unit, m_query, &val) && val >= 0 && val <= BitcoinUnits::maxMoney();
}
Expand Down Expand Up @@ -704,7 +704,11 @@ QVariant NetWatchLogTestModel::data(const QModelIndex& index, int role) const
case NWLMH_ID:
return QString(64, '0');
case NWLMH_ADDR:
return QString(nLongestAddress, 'W');
if (index.row()) {
return QString{"bc1" + QString(LONGEST_BECH32_ADDRESS-3, 'x')};
} else {
return QString(LONGEST_BASE58_ADDRESS, 'W');
}
case NWLMH_VALUE:
return "20000000.00000000";
}
Expand Down
5 changes: 3 additions & 2 deletions src/qt/netwatch.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017 The Bitcoin Core developers
// Copyright (c) 2017-2021 The Bitcoin Core developers
// Copyright (c) 2011-2013 David Krauss (std::align substitute from c-plus)
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
Expand All @@ -25,7 +25,8 @@ class LogEntry;
class NetworkStyle;
class PlatformStyle;

static const int nLongestAddress = 35;
static constexpr int LONGEST_BASE58_ADDRESS{35};
static constexpr int LONGEST_BECH32_ADDRESS{62}; // NOTE: Up to 74 in theory, but 62 in practice

class LogEntry {
private:
Expand Down

0 comments on commit 3fbc22b

Please sign in to comment.