Jump to Building on macOS - /dash/src now contains the compiled Dash binaries, and /dash/src/qt contains the Dash GUI wallet. MacOS Native¶.

Authors: Mike Linford and Matthew Gillett

Bitcoin is a popular cryptocurrency, which is a form of electronic cash, in which a ledger of all transactions is stored as a blockchain. In this article we will show how to compile your own local copy of the Bitcoin client, run it, and add custom commands in order to inspect various attributes of the underlying blockchain.

Compile

First, you will want to clone the Bitcoin source code repository from Github: https://github.com/bitcoin/bitcoin

Then, based on your operating system, you will want to follow the instructions found in the “doc” folder of the Bitcoin repository, where the file starts with “build-” followed by the operating system.

For Mac OS, installing the dependent libraries is very easy using the “homebrew” tool mentioned in the build instructions. Note that after installing libraries with “homebrew” there may be instructions given in the result for more commands to run – make sure you run those.

Building Bitcoin Core on Windows is slightly more complicated since Bitcoin Core is mostly developed on Linux-based or other Unix-like operating systems. Below is a summary of build-windows.md to build Bitcoin Core on Windows 64-bit

  1. Install dependencies
  2. Configure for cross-compilation
  3. Select the option that includes `posix`, e.g. `/usr/bin/x86_64-w64-mingw32-g++-posix`
  4. Fetch the project with Git
  5. Build the project (this can take a long time, maybe a half an hour or more)
  6. Install the built project

Instead of installing you can also go to the build directory directly. This will be in a location like: `C:UsersUserAppDataLocalPackagesCanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgscLocalStaterootfshomeuserbitcoin`

Run

Once the code is built using autogen.sh, configure, and make, you can start the Bitcoin Core with the “./src/bitcoind” command. Bitcoin Core will attempt to download the entire blockchain, which could take a long time and hard drive space. If you are interested in only inspecting a portion of the blockchain, or want to keep the blockchain at a certain point without updating it, you can exit out of the Bitcoin Core while it is downloading, then run “./src/bitcoind -noconnect” to prevent connection to any nodes.

In addition to the `-noconnect` option described above it is also possible to test using two smaller blockchains, testnet and regtest (short for 'regression test'). You can start the client with one of these chains with `bitcoind -testnet` or `bitcoind -regtest` respectively. Both chains are used exclusively for testing, so coins on them have no monetary value. The testnet chain is still pretty big (about 23 GB as of Feb. 2019), but behaves much more closely to the real Bitcoin network. The regtest network is a private chain used in Bitcoin's functional regression tests (written in Python). There are RPC commands available only for regtest, `setgenerate` and `generate` that allow you to quickly generate coins.

Customize

Now that we have a runnable Bitcoin Core and some (or all) of a blockchain downloaded, we can see how to run some commands to inspect the blockchain. If you run “./src/bitcoin-cli help” while the Bitcoin Core is running, you can see a list of available commands. To get the hash of a certain block in the chain, you can run “./src/bitcoin-cli getblockhash <height>” where <height> is the ordinal number of the location of the block in the chain. Then to get detailed data on the block, you can run “./src/bitcoin-cli getblock <hash> <verbosity>” where <hash> is the block hash returned from the previous command and <verbosity> is the amount of detail you want returned (use 2 for the most detail).

The available commands that can be used to inspect the blockchain are nice, but let’s see how we can implement our own commands. The relevant command code can be found in the source file “/src/rpc/blockchain.cpp”. To see the total value of all transactions contained in a specific block in the block chain, we could add the following code:

In order to run this command, we just need to add it to the commands[] array at the bottom of the file:

Once the updates above are made to the source file, go ahead and run the “make” command again to rebuild (it won’t take as long this time around since only one file was modified).

This can be done during checkout, by typing “Please ship CD” in the Notes section. Quickbooks 2 for mac pro. QuickBooks Desktop Mac 2-user 2020 is reliable, flexible, and ready to go—just upload your data and begin.NEW features for QuickBooks Desktop for Mac 2020: Modernizing Reporting, Dark Mode, Improved Company Snapshot, Invoice e-Payments, Bounced Check Processing, and iPhone Scanner.After purchase, you will receive an email that contains a download link, license number, and product key. We can ship a CD for FREE upon request.

Now let’s try running our new command. First, obtain a block with multiple transactions (this example is on the main blockchain – you will need to make sure you download at least up to block 110000 for this command to return successfully):

Then run our new command with the resulting hash value:

This returns the total number of transactions in the block (12) and the total value of transactions in the block (754.57000000).

If you would like to verify that the new command is working properly, you can run the following to see each transaction and individual value for the block:

Now that we have implemented a custom command to derive some information from the blockchain, try implementing your own custom commands to derive any additional data that you might want to from the blockchain.

Below is information about some of the important Bitcoin data types that you might encounter while developing a custom command:

  • uint256: Stores 256-bit hashes generated by Bitcoin's hashing algorithm, SHA-256
  • CBlockIndex: Used to locate a block within the block chain. Includes the block's hash, a pointer to the block before it, and other fields.
  • CBlock: Represents a block itself, including the header and its transactions (in the form of a vector of CTransaction smart pointers)
  • CTransaction: A transaction in a block, including inputs, outputs, and hashes
  • CTxIn: A single input to a transaction. This will correspond to the output of an earlier transaction.
  • CTxMemPool: Stores transactions that are waiting to be added to a mined block.
  • Coin: Represents Bitcoin that has not been spent yet
  • CAmount: An integer representing a number of satoshis (the smallest unit of Bitcoin, 10^-8)
  • UniValue: Represents a JSON value, such as in an RPC response

The commands in this guide should be executed in a Terminal application.The built-in one is located in /Applications/Utilities/Terminal.app.

Preparation

Install the macOS command line tools:

xcode-select --install

When the popup appears, click Install.

Then install Homebrew.

Dependencies

See dependencies.md for a complete overview.

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

Berkeley DB

It is recommended to use Berkeley DB 4.8. If you have to build it yourself,you can use the installation script included in contrib/like so:

from the root of the repository.

Note: You only need Berkeley DB if the wallet is enabled (see Disable-wallet mode).

Build PIVX Core

  1. Clone the PIVX Core source code:

  2. Make the Homebrew OpenSSL headers visible to the configure script (do brew info openssl to find out why this is necessary, or if you use Homebrew with installation folders different from the default).

  3. Build PIVX Core:

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

  5. You can also create a .dmg that contains the .app bundle (optional):

Disable-wallet mode

Note: This functionality is not yet completely implemented, and compilation using the below option will currently fail.

When the intention is to run only a P2P node without a wallet, PIVX Core may be compiled indisable-wallet mode with:

In this case there is no dependency on Berkeley DB 4.8.

Running

PIVX Core is now available at ./src/pivxd

Before running, you may create an empty configuration file:

The first time you run pivxd, it will start downloading the blockchain. This process could take many hours, or even days on slower than average systems.

You can monitor the download process by looking at the debug.log file:

Other commands:

Notes

  • Tested on OS X 10.10 Yosemite through macOS 10.13 High Sierra on 64-bit Intel processors only.

  • Building with downloaded Qt binaries is not officially supported. See the notes in #7714

Deterministic macOS DMG Notes

Working macOS DMGs are created in Linux by combining a recent clang,the Apple binutils (ld, ar, etc) and DMG authoring tools.

Apple uses clang extensively for development and has upstreamed the necessaryfunctionality so that a vanilla clang can take advantage. It supports the useof -F, -target, -mmacosx-version-min, and --sysroot, which are all necessarywhen building for macOS.

Apple's version of binutils (called cctools) contains lots of functionalitymissing in the FSF's binutils. In addition to extra linker options forframeworks and sysroots, several other tools are needed as well such asinstall_name_tool, lipo, and nmedit. These do not build under linux, so theyhave been patched to do so. The work here was used as a starting point:mingwandroid/toolchain4.

In order to build a working toolchain, the following source packages are neededfrom Apple: cctools, dyld, and ld64.

These tools inject timestamps by default, which produce non-deterministicbinaries. The ZERO_AR_DATE environment variable is used to disable that.

This version of cctools has been patched to use the current version of clang'sheaders and its libLTO.so rather than those from llvmgcc, as it wasoriginally done in toolchain4.

To complicate things further, all builds must target an Apple SDK. These SDKsare free to download, but not redistributable.To obtain it, register for a developer account, then download the Xcode 7.3.1 dmg.

This file is several gigabytes in size, but only a single directory inside isneeded:

Unfortunately, the usual linux tools (7zip, hpmount, loopback mount) are incapable of opening this file.To create a tarball suitable for Gitian input, there are two options:

Using macOS, you can mount the dmg, and then create it with:

Alternatively, you can use 7zip and SleuthKit to extract the files one by one.The script contrib/macdeploy/extract-osx-sdk.sh automates this. First ensurethe dmg file is in the current directory, and then run the script. You may wishto delete the intermediate 5.hfs file and MacOSX10.11.sdk (the directory) whenyou've confirmed the extraction succeeded.

The Gitian descriptors build 2 sets of files: Linux tools, then Apple binarieswhich are created using these tools. The build process has been designed toavoid including the SDK's files in Gitian's outputs. All interim tarballs arefully deterministic and may be freely redistributed.

genisoimage is used to create the initial DMG. It is not deterministic as-is,so it has been patched. A system genisoimage will work fine, but it will notbe deterministic because the file-order will change between invocations.The patch can be seen here: theuni/osx-cross-depends.No effort was made to fix this cleanly, so it likely leaks memory badly. Butit's only used for a single invocation, so that's no real concern.

genisoimage cannot compress DMGs, so afterwards, the 'dmg' tool from thelibdmg-hfsplus project is used to compress it. There are several bugs in thistool and its maintainer has seemingly abandoned the project. It has been forkedand is available (with fixes) here: theuni/libdmg-hfsplus.

The 'dmg' tool has the ability to create DMGs from scratch as well, but thisfunctionality is broken. Only the compression feature is currently used.Ideally, the creation could be fixed and genisoimage would no longer be necessary.

How do you compile qt wallet for mac pro

Background images and other features can be added to DMG files by inserting a.DS_Store before creation. This is generated by the scriptcontrib/macdeploy/custom_dsstore.py.

As of OS X 10.9 Mavericks, using an Apple-blessed key to sign binaries is arequirement in order to satisfy the new Gatekeeper requirements. Because thisprivate key cannot be shared, we'll have to be a bit creative in order for thebuild process to remain somewhat deterministic. Here's how it works:

  • Builders use Gitian to create an unsigned release. This outputs an unsigneddmg which users may choose to bless and run. It also outputs an unsigned appstructure in the form of a tarball, which also contains all of the toolsthat have been previously (deterministically) built in order to create afinal dmg.
  • The Apple keyholder uses this unsigned app to create a detached signature,using the script that is also included there. Detached signatures are available from this repository.
  • Builders feed the unsigned app + detached signature back into Gitian. Ituses the pre-built tools to recombine the pieces into a deterministic dmg.

Popular Posts