Skip to content
Draft
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ qrc_*.cpp
# Mac specific
.DS_Store
build
db4/
background.tiff
background.tiff.png
background.tiff@2x.png

#lcov
*.gcno
Expand Down
2 changes: 2 additions & 0 deletions contrib/install_db4.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ sha256_check() {
#
if check_exists sha256sum; then
echo "${1} ${2}" | sha256sum -c
elif check_exists shasum; then
echo "${1} ${2}" | shasum -a 256 -c
elif check_exists sha256; then
if [ "$(uname)" = "FreeBSD" ]; then
sha256 -c "${1}" "${2}"
Expand Down
31 changes: 29 additions & 2 deletions contrib/macdeploy/macdeployqtplus
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class FrameworkInfo(object):
info.sourceResourcesDirectory = os.path.join(info.frameworkPath, "Resources")
info.sourceContentsDirectory = os.path.join(info.frameworkPath, "Contents")
info.sourceVersionContentsDirectory = os.path.join(info.frameworkPath, "Versions", info.version, "Contents")
info.destinationResourcesDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, "Resources")
info.destinationResourcesDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, "Versions", info.version, "Resources")
info.destinationContentsDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, "Contents")
info.destinationVersionContentsDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, "Versions", info.version, "Contents")

Expand Down Expand Up @@ -289,6 +289,18 @@ def copyFramework(framework, path, verbose):
os.symlink(linkto, linkfrom)
if verbose >= 2:
print("Linked:", linkfrom, "->", linkto)

frameworkPath = os.path.join(path, "Contents", "Frameworks", framework.frameworkName)
frameworkLinks = (
(framework.binaryName, os.path.join("Versions", "Current", framework.binaryName)),
("Resources", os.path.join("Versions", "Current", "Resources")),
)
for linkName, linkTarget in frameworkLinks:
linkPath = os.path.join(frameworkPath, linkName)
if not os.path.lexists(linkPath):
os.symlink(linkTarget, linkPath)
if verbose >= 2:
print("Linked:", linkPath, "->", linkTarget)
fromResourcesDir = framework.sourceResourcesDirectory
if os.path.exists(fromResourcesDir):
toResourcesDir = os.path.join(path, framework.destinationResourcesDirectory)
Expand Down Expand Up @@ -322,6 +334,10 @@ def deployFrameworks(frameworks, bundlePath, binaryPath, strip, verbose, deploym

while len(frameworks) > 0:
framework = frameworks.pop(0)
if framework.frameworkName in deploymentInfo.deployedFrameworks:
if verbose >= 2:
print(framework.frameworkName, "already deployed, skipping.")
continue
deploymentInfo.deployedFrameworks.append(framework.frameworkName)

if verbose >= 2:
Expand Down Expand Up @@ -352,6 +368,16 @@ def deployFrameworks(frameworks, bundlePath, binaryPath, strip, verbose, deploym
changeIdentification(framework.deployedInstallName, deployedBinaryPath, verbose)
# Check for framework dependencies
dependencies = getFrameworks(deployedBinaryPath, verbose)

# Homebrew libraries commonly refer to sibling dylibs via @rpath.
# Resolve those references from the original library directory when
# copying dependencies into the application bundle.
sourceDirectory = os.path.dirname(framework.sourceFilePath)
for dependency in dependencies:
if dependency.sourceFilePath.startswith("@rpath/"):
sourceFilePath = os.path.join(sourceDirectory, os.path.basename(dependency.sourceFilePath))
if os.path.exists(sourceFilePath):
dependency.sourceFilePath = sourceFilePath

for dependency in dependencies:
changeInstallName(dependency.installName, dependency.deployedInstallName, deployedBinaryPath, verbose)
Expand Down Expand Up @@ -551,7 +577,8 @@ if len(config.fancy) == 1:
sys.exit(1)

try:
fancy = plistlib.readPlist(p)
with open(p, "rb") as plist_file:
fancy = plistlib.load(plist_file)
except:
if verbose >= 1:
sys.stderr.write("Error: Could not parse fancy disk image plist at \"%s\"\n" % (p))
Expand Down
70 changes: 57 additions & 13 deletions doc/build-osx.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Mac OS X Build Instructions and Notes
====================================
macOS Build Instructions and Notes
==================================
The commands in this guide should be executed in a Terminal application.
The built-in one is located in `/Applications/Utilities/Terminal.app`.

Expand All @@ -14,12 +14,18 @@ When the popup appears, click `Install`.
Then install [Homebrew](https://brew.sh).

Dependencies
----------------------
------------

brew install automake berkeley-db4 libtool boost miniupnpc openssl pkg-config protobuf python3 qt libevent
brew install automake libtool boost@1.85 openssl@3 pkg-config protobuf python3 qt@5 libevent

See [dependencies.md](dependencies.md) for a complete overview.

Berkeley DB 4.8 is required for wallet compatibility. Build the pinned version
with the repository helper instead of installing the current Homebrew Berkeley
DB release:

./contrib/install_db4.sh "$(pwd)"

If you want to build the disk image with `make deploy` (.dmg / optional), you need RSVG

brew install librsvg
Expand All @@ -28,7 +34,8 @@ If you want to build with ZeroMQ support

brew install zeromq

NOTE: Building with Qt4 is still supported, however, could result in a broken UI. Building with Qt5 is recommended.
Current MiniUPnPc releases are not compatible with this older codebase. The
Apple Silicon configuration below disables UPnP. Qt 5 is recommended.

Build Garlicoin Core
------------------------
Expand All @@ -38,32 +45,67 @@ Build Garlicoin Core
git clone https://github.com/GarlicoinOrg/Garlicoin
cd garlicoin

2. Build garlicoin-core:
2. Generate the configure script:

./autogen.sh

3. Build Garlicoin Core:

Configure and build the headless garlicoin binaries as well as the GUI (if Qt is found).

You can disable the GUI build by passing `--without-gui` to configure.

./autogen.sh
./configure
make

3. It is recommended to build and run the unit tests:
On Apple Silicon with current Homebrew packages, use the following
configuration. C++17 is needed by current Protobuf/Abseil headers, while
Berkeley DB remains pinned to 4.8 for wallet compatibility.

BDB_PREFIX="$PWD/db4"
BOOST_PREFIX="$(brew --prefix boost@1.85)"
OPENSSL_PREFIX="$(brew --prefix openssl@3)"
LIBEVENT_PREFIX="$(brew --prefix libevent)"
QT_PREFIX="$(brew --prefix qt@5)"

./configure \
BDB_LIBS="-L$BDB_PREFIX/lib -ldb_cxx-4.8" \
BDB_CFLAGS="-I$BDB_PREFIX/include" \
CXXFLAGS="-std=c++17 -g -O2" \
CFLAGS="-Wno-error=implicit-function-declaration" \
CPPFLAGS="-I$BDB_PREFIX/include -I$BOOST_PREFIX/include -I$OPENSSL_PREFIX/include -I$LIBEVENT_PREFIX/include" \
LDFLAGS="-L$BDB_PREFIX/lib -L$BOOST_PREFIX/lib -L$OPENSSL_PREFIX/lib -L$LIBEVENT_PREFIX/lib" \
PKG_CONFIG_PATH="$QT_PREFIX/lib/pkgconfig:$OPENSSL_PREFIX/lib/pkgconfig" \
--with-boost="$BOOST_PREFIX" \
--with-miniupnpc=no \
--with-gui=qt5

make -j"$(sysctl -n hw.logicalcpu)"

4. It is recommended to build and run the unit tests:

make check

4. You can also create a .dmg that contains the .app bundle (optional):
5. You can also create a `.dmg` containing a self-contained `.app` bundle
(optional):

make deploy

5. Installation into user directories (optional):
The results are `dist/Garlicoin-Qt.app` and `Garlicoin-Qt.dmg`. For local
testing, apply an ad-hoc signature after deployment:

codesign --force --deep --sign - dist/Garlicoin-Qt.app

Public releases should use a Developer ID signature and notarization.

6. Installation into user directories (optional):

make install

or

cd ~/garlicoin/src
cp litecoind /usr/local/bin/
cp garlicoind /usr/local/bin/
cp garlicoin-cli /usr/local/bin/

Running
Expand Down Expand Up @@ -103,13 +145,15 @@ Uncheck everything except Qt Creator during the installation process.
5. Leave the file selection as it is
6. Confirm the "summary page"
7. In the "Projects" tab select "Manage Kits..."
8. Select the default "Desktop" kit and select "Clang (x86 64bit in /usr/bin)" as compiler
8. Select the default "Desktop" kit and the Apple Clang compiler for your architecture
9. Select LLDB as debugger (you might need to set the path to your installation)
10. Start debugging with Qt Creator

Notes
-----

* Tested on OS X 10.8 through 10.13 on 64-bit Intel processors only.
* The Apple Silicon instructions were tested on macOS 27 with Homebrew arm64
packages. The legacy build was previously tested on OS X 10.8 through 10.13
on 64-bit Intel processors.

* Building with downloaded Qt binaries is not officially supported. See the notes in [#7714](https://github.com/bitcoin/bitcoin/issues/7714)
2 changes: 1 addition & 1 deletion share/qt/Info.plist.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<key>LSArchitecturePriority</key>
<array>
<string>x86_64</string>
<string>arm64</string>
</array>

<key>CFBundleIconFile</key>
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/scrypt-sse2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void scrypt_N_1_1_256_sp_sse2(const char *input, char *output, char *scratchpad,

for (k = 0; k < 2; k++) {
for (i = 0; i < 16; i++) {
X.u32[k * 16 + i] = le32dec(&B[(k * 16 + (i * 5 % 16)) * 4]);
X.u32[k * 16 + i] = scrypt_le32dec(&B[(k * 16 + (i * 5 % 16)) * 4]);
}
}

Expand All @@ -132,7 +132,7 @@ void scrypt_N_1_1_256_sp_sse2(const char *input, char *output, char *scratchpad,

for (k = 0; k < 2; k++) {
for (i = 0; i < 16; i++) {
le32enc(&B[(k * 16 + (i * 5 % 16)) * 4], X.u32[k * 16 + i]);
scrypt_le32enc(&B[(k * 16 + (i * 5 % 16)) * 4], X.u32[k * 16 + i]);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/crypto/scrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
#include <cpuid.h>
#endif
#endif
static inline uint32_t be32dec(const void *pp)
static inline uint32_t scrypt_be32dec(const void *pp)
{
const uint8_t *p = (uint8_t const *)pp;
return ((uint32_t)(p[3]) + ((uint32_t)(p[2]) << 8) +
((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24));
}

static inline void be32enc(void *pp, uint32_t x)
static inline void scrypt_be32enc(void *pp, uint32_t x)
{
uint8_t *p = (uint8_t *)pp;
p[3] = x & 0xff;
Expand Down Expand Up @@ -152,7 +152,7 @@ PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, const uint8_t *salt,
/* Iterate through the blocks. */
for (i = 0; i * 32 < dkLen; i++) {
/* Generate INT(i + 1). */
be32enc(ivec, (uint32_t)(i + 1));
scrypt_be32enc(ivec, (uint32_t)(i + 1));

/* Compute U_1 = PRF(P, S || INT(i)). */
memcpy(&hctx, &PShctx, sizeof(HMAC_SHA256_CTX));
Expand Down Expand Up @@ -264,7 +264,7 @@ void scrypt_N_1_1_256_sp_generic(const char *input, char *output, char *scratchp
PBKDF2_SHA256((const uint8_t *)input, 80, (const uint8_t *)input, 80, 1, B, 128);

for (k = 0; k < 32; k++)
X[k] = le32dec(&B[4 * k]);
X[k] = scrypt_le32dec(&B[4 * k]);

N = (1 << (Nfactor + 1));

Expand All @@ -283,7 +283,7 @@ void scrypt_N_1_1_256_sp_generic(const char *input, char *output, char *scratchp
}

for (k = 0; k < 32; k++)
le32enc(&B[4 * k], X[k]);
scrypt_le32enc(&B[4 * k], X[k]);

PBKDF2_SHA256((const uint8_t *)input, 80, B, 128, 1, (uint8_t *)output, 32);
}
Expand Down
6 changes: 3 additions & 3 deletions src/crypto/scrypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ void
PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, const uint8_t *salt,
size_t saltlen, uint64_t c, uint8_t *buf, size_t dkLen);

static inline uint32_t le32dec(const void *pp)
static inline uint32_t scrypt_le32dec(const void *pp)
{
const uint8_t *p = (uint8_t const *)pp;
return ((uint32_t)(p[0]) + ((uint32_t)(p[1]) << 8) +
((uint32_t)(p[2]) << 16) + ((uint32_t)(p[3]) << 24));
}

static inline void le32enc(void *pp, uint32_t x)
static inline void scrypt_le32enc(void *pp, uint32_t x)
{
uint8_t *p = (uint8_t *)pp;
p[0] = x & 0xff;
p[1] = (x >> 8) & 0xff;
p[2] = (x >> 16) & 0xff;
p[3] = (x >> 24) & 0xff;
}
#endif
#endif
2 changes: 1 addition & 1 deletion src/rpc/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static fs::path GetAuthCookieFile(bool temp=false)
arg += ".tmp";
}
fs::path path(arg);
if (!path.is_complete()) path = GetDataDir() / path;
if (!path.is_absolute()) path = GetDataDir() / path;
return path;
}

Expand Down
4 changes: 2 additions & 2 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ void ClearDatadirCache()
fs::path GetConfigFile(const std::string& confPath)
{
fs::path pathConfigFile(confPath);
if (!pathConfigFile.is_complete())
if (!pathConfigFile.is_absolute())
pathConfigFile = GetDataDir(false) / pathConfigFile;

return pathConfigFile;
Expand Down Expand Up @@ -687,7 +687,7 @@ void ArgsManager::ReadConfigFile(const std::string& confPath)
fs::path GetPidFile()
{
fs::path pathPidFile(gArgs.GetArg("-pid", BITCOIN_PID_FILENAME));
if (!pathPidFile.is_complete()) pathPidFile = GetDataDir() / pathPidFile;
if (!pathPidFile.is_absolute()) pathPidFile = GetDataDir() / pathPidFile;
return pathPidFile;
}

Expand Down
1 change: 1 addition & 0 deletions src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <algorithm>
#include <exception>
#include <list>
#include <map>
#include <set>
#include <stdint.h>
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ bool CDB::VerifyEnvironment(const std::string& walletFile, const fs::path& walle
LogPrintf("Using wallet %s\n", walletFile);

// Wallet file must be a plain filename without a directory
if (walletFile != fs::basename(walletFile) + fs::extension(walletFile))
if (fs::path(walletFile).filename().string() != walletFile)
{
errorStr = strprintf(_("Wallet %s resides outside wallet directory %s"), walletFile, walletDir.string());
return false;
Expand Down Expand Up @@ -714,7 +714,7 @@ bool CWalletDBWrapper::Backup(const std::string& strDest)
return false;
}

fs::copy_file(pathSrc, pathDest, fs::copy_option::overwrite_if_exists);
fs::copy_file(pathSrc, pathDest, fs::copy_options::overwrite_existing);
LogPrintf("copied %s to %s\n", strFile, pathDest.string());
return true;
} catch (const fs::filesystem_error& e) {
Expand Down
4 changes: 3 additions & 1 deletion src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2427,7 +2427,9 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin
std::vector<CInputCoin> vValue;
CAmount nTotalLower = 0;

random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt);
for (size_t i = vCoins.size(); i > 1; --i) {
std::swap(vCoins[i - 1], vCoins[GetRandInt(static_cast<int>(i))]);
}

for (const COutput &output : vCoins)
{
Expand Down
2 changes: 1 addition & 1 deletion test/util/bitcoin-util-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
def main():
config = configparser.ConfigParser()
config.optionxform = str
config.readfp(open(os.path.join(os.path.dirname(__file__), "../config.ini")))
config.read(os.path.join(os.path.dirname(__file__), "../config.ini"))
env_conf = dict(config.items('environment'))

parser = argparse.ArgumentParser(description=__doc__)
Expand Down