1 class Bitcoin < Formula
2 desc "Decentralized, peer to peer payment network"
3 homepage "https://bitcoincore.org/"
4 url "https://bitcoincore.org/bin/bitcoin-core-28.1/bitcoin-28.1.tar.gz"
5 sha256 "c5ae2dd041c7f9d9b7c722490ba5a9d624f7e9a089c67090615e1ba4ad0883ba"
8 "BSD-3-Clause", # src/crc32c, src/leveldb
9 "BSL-1.0", # src/tinyformat.h
10 "Sleepycat", # resource("bdb")
12 head "https://github.com/bitcoin/bitcoin.git", branch: "master"
15 url "https://bitcoincore.org/en/download/"
16 regex(/latest version.*?v?(\d+(?:\.\d+)+)/i)
20 sha256 cellar: :any, arm64_sequoia: "3b8dd7b2f87fdd035a1a43fb33d815ca5d1b579051f39be65abdea52207787e4"
21 sha256 cellar: :any, arm64_sonoma: "a194275ef4a83ec4ba833598c7e5ae6b90aaee12e3e48141563d4d5c3db58f7c"
22 sha256 cellar: :any, arm64_ventura: "6b7ae606988258139e4b8d97d662758d10c4c93c34cc3d05242f274c971cd387"
23 sha256 cellar: :any, sonoma: "448277b6d5eea93cf8fed2417f752034f720b851cb5eae337863646af75bd78b"
24 sha256 cellar: :any, ventura: "3f3dd8b5c72068db2277535f3c449a9338a2079b398376aeebc3963ba78c6f1c"
25 sha256 cellar: :any_skip_relocation, x86_64_linux: "a5bf3062a9b43ad8e522cf102e21496973249ca5dedada6620e659bec5dc1ae5"
28 depends_on "autoconf" => :build
29 depends_on "automake" => :build
30 depends_on "boost" => :build
31 depends_on "libtool" => :build
32 depends_on "pkgconf" => :build
34 depends_on macos: :big_sur
35 depends_on "miniupnpc"
38 uses_from_macos "sqlite"
41 depends_on "util-linux" => :build # for `hexdump`
46 cause "Requires C++ 20"
49 # berkeley db should be kept at version 4
50 # https://github.com/bitcoin/bitcoin/blob/master/doc/build-osx.md
51 # https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md
53 url "https://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz"
54 sha256 "12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef"
56 # Fix build with recent clang
58 url "https://raw.githubusercontent.com/Homebrew/formula-patches/4c55b1/berkeley-db%404/clang.diff"
59 sha256 "86111b0965762f2c2611b302e4a95ac8df46ad24925bbb95a1961542a1542e40"
61 # Fix -flat_namespace being used on Big Sur and later.
63 url "https://raw.githubusercontent.com/Homebrew/formula-patches/03cf8088210822aa2c1ab544ed58ea04c897d9c4/libtool/configure-pre-0.4.2.418-big_sur.diff"
64 sha256 "83af02f2aa2b746bb7225872cab29a253264be49db0ecebb12f841562d9a2923"
69 # Skip two tests that currently fail in the brew CI
71 url "https://github.com/fanquake/bitcoin/commit/9b03fb7603709395faaf0fac409465660bbd7d81.patch?full_index=1"
72 sha256 "1d56308672024260e127fbb77f630b54a0509c145e397ff708956188c96bbfb3"
76 # https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md#berkeley-db
77 # https://github.com/bitcoin/bitcoin/blob/master/depends/packages/bdb.mk
78 resource("bdb").stage do
79 with_env(CFLAGS: ENV.cflags) do
80 # Fix compile with newer Clang
81 ENV.append "CFLAGS", "-Wno-implicit-function-declaration" if DevelopmentTools.clang_build_version >= 1200
82 # BerkeleyDB requires you to build everything from the build_unix subdirectory
84 system "../dist/configure", "--disable-replication",
87 *std_configure_args(prefix: buildpath/"bdb")
88 system "make", "libdb_cxx-4.8.a", "libdb-4.8.a"
89 system "make", "install_lib", "install_include"
95 system "./configure", "--disable-silent-rules",
96 "--with-boost-libdir=#{Formula["boost"].opt_lib}",
97 "BDB_LIBS=-L#{buildpath}/bdb/lib -ldb_cxx-4.8",
98 "BDB_CFLAGS=-I#{buildpath}/bdb/include",
100 system "make", "install"
101 pkgshare.install "share/rpcauth"
105 run opt_bin/"bitcoind"
109 system bin/"test_bitcoin"
111 # Test that we're using the right version of `berkeley-db`.
113 bitcoind = spawn bin/"bitcoind", "-regtest", "-rpcport=#{port}", "-listen=0", "-datadir=#{testpath}",
114 "-deprecatedrpc=create_bdb"
116 # This command will fail if we have too new a version.
117 system bin/"bitcoin-cli", "-regtest", "-datadir=#{testpath}", "-rpcport=#{port}",
118 "createwallet", "test-wallet", "false", "false", "", "false", "false"
120 Process.kill "TERM", bitcoind