Skip to content

Sync with the main repo #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 87 commits into from
Oct 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
5e42f2a
build: Make <QtBaseDir> default name Qt and VS versions agnostic
hebasto Sep 4, 2021
5faa7dd
[move-only] Move CAddrMan function definitions to cpp
amitiuttarwar Sep 24, 2021
f2e5f38
[move-only] Match ordering of CAddrMan declarations and definitions
amitiuttarwar Sep 28, 2021
8af5b54
[addrman] Introduce CAddrMan::Impl to encapsulate addrman implementat…
amitiuttarwar Sep 1, 2021
7cba9d5
[net, addrman] Remove external dependencies on CAddrInfo objects
amitiuttarwar Aug 25, 2021
e3f1ea6
[move-only] Move CAddrInfo to test-only header file
amitiuttarwar Sep 4, 2021
7cf41bb
[addrman] Change CAddrInfo access
amitiuttarwar Sep 10, 2021
40acd6f
[move-only] Move constants to test-only header
amitiuttarwar Sep 4, 2021
14f9e00
[refactor] Update GetAddr_() function signature
amitiuttarwar Sep 22, 2021
29727c2
[doc] Update comments
amitiuttarwar Sep 4, 2021
3c263d3
[includes] Fix up included files
amitiuttarwar Sep 10, 2021
dd8f7f2
scripted-diff: Rename CAddrMan to AddrMan
amitiuttarwar Sep 11, 2021
3757503
scripted-diff: Rename CAddrInfo to AddrInfo
amitiuttarwar Sep 11, 2021
021f869
[style] Run changed files through clang formatter.
amitiuttarwar Sep 11, 2021
429b493
test: introduce script_util helper for creating P2PK scripts
theStack Sep 28, 2021
06c5ce9
Re-include RBF replacement txs in fee estimation
darosior Jul 23, 2021
74c0d81
test: use miniwallet in test_rpc() function in feature_rbf.py
Shubhankar-Gambhir Sep 21, 2021
053415b
qa: split run_test into smaller parts
darosior Sep 21, 2021
4556406
qa: test fee estimation with replacement transactions
darosior Sep 21, 2021
3b61372
Add release notes for fee est with replacement txs
darosior Sep 24, 2021
a00eb38
Allow CInputCoin to also be constructed with COutPoint and CTxOut
achow101 Oct 18, 2019
d5cfb86
Allow Coin Selection be able to take external inputs
achow101 Oct 18, 2019
d09071d
[MOVEONLY] consensus: move amount.h into consensus
fanquake Sep 11, 2021
863e52f
consensus: make COIN & MAX_MONEY constexpr
fanquake Sep 11, 2021
9d0379c
consensus: use <cstdint> over <stdint.h> in amount.h
fanquake Sep 11, 2021
c4139f0
doc: Replace a link to Qt precompiled binaries with compile instructions
hebasto Sep 4, 2021
6bc4398
doc: Suggest using jom instead of nmake
hebasto Sep 4, 2021
4343f11
Replace use of locale dependent atoi(…) with locale-independent std::…
practicalswift Sep 30, 2021
4747da3
Add syscall sandboxing (seccomp-bpf)
practicalswift Oct 1, 2021
fa3cd28
refactor: Remove unused ParsePrechecks from ParseIntegral
Oct 1, 2021
a6d9675
contrib: Ask for captcha in signet getcoins.py
laanwj Oct 1, 2021
502f50d
Test transactions conflicted by double spend in listtransactions
jonatack Sep 30, 2021
38f5642
allow fundtx rpcs to work with external inputs
achow101 Oct 18, 2019
e39b5a5
Tests for funding with external inputs
achow101 Oct 21, 2019
928af61
allow send rpc take external inputs and solving data
achow101 Jan 12, 2021
fa9d72a
Remove unused ParseDouble and ParsePrechecks
Oct 4, 2021
573b462
Merge bitcoin/bitcoin#17211: Allow fundrawtransaction and walletcreat…
meshcollider Oct 4, 2021
c6f710e
Merge bitcoin/bitcoin#23052: test: use miniwallet in test_rpc functio…
Oct 4, 2021
cdb4dfc
Merge bitcoin/bitcoin#20452: util: Replace use of locale dependent at…
laanwj Oct 4, 2021
fafff13
doc: Extract FundTxDoc
Oct 4, 2021
42fedb4
Merge bitcoin/bitcoin#23156: refactor: Remove unused ParsePrechecks a…
Oct 4, 2021
9e530c6
Merge bitcoin/bitcoin#20487: Add syscall sandboxing using seccomp-bpf…
laanwj Oct 4, 2021
ee08741
sandbox: add newfstatat to allowed filesystem syscalls
fanquake Oct 5, 2021
44d77d2
sandbox: add copy_file_range to allowed filesystem syscalls
fanquake Oct 5, 2021
ef15c57
build: add python3.10 alias to AC_PATH_PROGS call in configure
fanquake Oct 5, 2021
8289d19
util: Define SECCOMP_RET_KILL_PROCESS if not provided by the headers
laanwj Oct 4, 2021
816e15e
Merge bitcoin/bitcoin#22951: consensus: move amount.h into consensus
Oct 5, 2021
371f0ae
Merge bitcoin/bitcoin#23182: build: add python3.10 alias to AC_PATH_P…
Oct 5, 2021
c79d9fb
Merge bitcoin/bitcoin#23179: sandbox: add `newfstatat` & `copy_file_r…
Oct 5, 2021
faa5e17
RPCConsole: Throw when overflowing size_t type for array indices
Oct 5, 2021
2d02799
util: Make sure syscall numbers used in profile are defined
laanwj Oct 5, 2021
c4fc899
Merge bitcoin/bitcoin#22950: [p2p] Pimpl AddrMan to abstract implemen…
Oct 5, 2021
89b9107
Merge bitcoin/bitcoin#23178: util: Fix GUIX build with syscall sandbox
laanwj Oct 5, 2021
113b863
Merge bitcoin/bitcoin#23162: contrib: Ask for captcha in signet getco…
laanwj Oct 5, 2021
56303e3
[fuzz] Create a FastRandomContext in addrman fuzz tests
jnewbery Sep 21, 2021
491975c
[fuzz] Pass FuzzedDataProvider& into Fill() in addrman fuzz tests
jnewbery Sep 21, 2021
90ad8ad
[fuzz] Make RandAddr() a free function in fuzz/addrman.cpp
jnewbery Sep 21, 2021
640476e
[fuzz] Make Fill() a free function in fuzz/addrman.cpp
jnewbery Sep 21, 2021
4445211
[fuzz] Update comment in FillAddrman()
jnewbery Sep 21, 2021
64085b3
util: Add __NR_copy_file_range syscall constant for sandbox
laanwj Oct 5, 2021
ac402e7
util: Conditionalize some syscalls in syscall name table
laanwj Oct 5, 2021
4356878
External input fund support cleanups
instagibbs Oct 5, 2021
eb02dbb
Use self.generate not node.generate throughout tests
meshcollider Oct 5, 2021
75a9305
Fix intermittent test failures due to missing sync_all
meshcollider Oct 5, 2021
66d11b1
Merge bitcoin/bitcoin#23200: Fix intermittent failure in wallet_send.…
Oct 6, 2021
fab360a
util: Add mremap syscall to AllowAddressSpaceAccess
Oct 6, 2021
01bff8f
qt: Fix WalletControllerActivity progress dialog title
shaavan Aug 24, 2021
fa3ab7b
test: Avoid RPC roundtrip in MiniWallet get_descriptor()
Oct 6, 2021
fa2ac58
test: Replace satoshi_round with int() or Decimal()
Oct 6, 2021
bb8550b
Merge bitcoin/bitcoin#23209: test: Avoid RPC roundtrip in MiniWallet …
Oct 6, 2021
7962c97
Merge bitcoin-core/gui#446: RPCConsole: Throw when overflowing size_t…
Oct 6, 2021
fa1477e
test: Add ParseMoney and ParseScript tests
Oct 5, 2021
577b0ff
Merge bitcoin-core/gui#409: Fix window title of wallet loading window
hebasto Oct 6, 2021
a68de12
Merge bitcoin/bitcoin#22890: doc: Replace a link to Qt precompiled bi…
fanquake Oct 7, 2021
0500a22
Merge bitcoin/bitcoin#23208: util: Add mremap syscall to AllowAddress…
fanquake Oct 7, 2021
f8911de
Merge bitcoin/bitcoin#23172: doc: Extract FundTxDoc in rpcwallet
fanquake Oct 7, 2021
b4437d7
Merge bitcoin/bitcoin#23210: test: Replace satoshi_round with int() o…
Oct 7, 2021
c0b6c96
Merge bitcoin/bitcoin#23146: Test transactions conflicted by double s…
Oct 7, 2021
6f0cbc7
Merge bitcoin/bitcoin#22539: Re-include RBF replacement txs in fee es…
laanwj Oct 7, 2021
6334ff7
Merge bitcoin/bitcoin#23196: util: Make syscall sandbox compilable wi…
laanwj Oct 7, 2021
991753e
Merge bitcoin/bitcoin#23118: test: refactor: introduce `script_util` …
laanwj Oct 7, 2021
d54ec27
qt: Add helper to load font
promag Oct 6, 2021
99e5396
Merge bitcoin/bitcoin#23188: wallet: fund transaction external input …
fanquake Oct 7, 2021
97e2435
Merge bitcoin/bitcoin#23053: [fuzz] Use public methods in addrman fuz…
fanquake Oct 8, 2021
9275869
Merge bitcoin/bitcoin#23185: test: Add ParseMoney and ParseScript tests
Oct 8, 2021
15587b4
Merge bitcoin-core/gui#448: Add helper to load font
hebasto Oct 9, 2021
a8dbc01
Sync with the main repo up to 15587b4f1d21bbf7f5f2743f15599eb718d8a3e6
hebasto Oct 9, 2021
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
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ task:
QT_DOWNLOAD_URL: 'https://download.qt.io/official_releases/qt/5.12/5.12.11/single/qt-everywhere-src-5.12.11.zip'
QT_LOCAL_PATH: 'C:\qt-everywhere-src-5.12.11.zip'
QT_SOURCE_DIR: 'C:\qt-everywhere-src-5.12.11'
QTBASEDIR: 'C:\Qt5.12.11_x64_static_vs2019_160900'
QTBASEDIR: 'C:\Qt_static'
x64_NATIVE_TOOLS: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"'
IgnoreWarnIntDirInTempDetected: 'true'
merge_script:
Expand Down
66 changes: 32 additions & 34 deletions build_msvc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,65 @@ Building Bitcoin Core with Visual Studio

Introduction
---------------------
Solution and project files to build the Bitcoin Core applications `msbuild` or Visual Studio can be found in the `build_msvc` directory. The build has been tested with Visual Studio 2019 (building with earlier versions of Visual Studio should not be expected to work).
Solution and project files to build Bitcoin Core with `msbuild` or Visual Studio can be found in the `build_msvc` directory. The build has been tested with Visual Studio 2019 (building with earlier versions of Visual Studio should not be expected to work).

Building with Visual Studio is an alternative to the Linux based [cross-compiler build](https://github.com/bitcoin/bitcoin/blob/master/doc/build-windows.md).
To build Bitcoin Core from the command-line, it is sufficient to only install the Visual Studio Build Tools component.

Quick Start
---------------------
The minimal steps required to build Bitcoin Core with the msbuild toolchain are below. More detailed instructions are contained in the following sections.
Building with Visual Studio is an alternative to the Linux based [cross-compiler build](../doc/build-windows.md).

```
cd build_msvc
py -3 msvc-autogen.py
msbuild /m bitcoin.sln /p:Platform=x64 /p:Configuration=Release /t:build
```

Dependencies
Prerequisites
---------------------
A number of [open source libraries](https://github.com/bitcoin/bitcoin/blob/master/doc/dependencies.md) are required in order to be able to build Bitcoin Core.
To build [dependencies](../doc/dependencies.md) (except for [Qt](#qt)),
the default approach is to use the [vcpkg](https://docs.microsoft.com/en-us/cpp/vcpkg) package manager from Microsoft:

Options for installing the dependencies in a Visual Studio compatible manner are:
1. [Install](https://vcpkg.io/en/getting-started.html) vcpkg.

- Use Microsoft's [vcpkg](https://docs.microsoft.com/en-us/cpp/vcpkg) to download the source packages and build locally. This is the recommended approach.
- Download the source code, build each dependency, add the required include paths, link libraries and binary tools to the Visual Studio project files.
- Use [nuget](https://www.nuget.org/) packages with the understanding that any binary files have been compiled by an untrusted third party.
2. By default, vcpkg makes both `release` and `debug` builds for each package.
To save build time and disk space, one could skip `debug` builds (example uses PowerShell):
```powershell

The [external dependencies](https://github.com/bitcoin/bitcoin/blob/master/doc/dependencies.md) required for building are listed in the `build_msvc/vcpkg.json` file. To ensure `msbuild` project files automatically install the `vcpkg` dependencies use:

```
vcpkg integrate install
Add-Content -Path "vcpkg\triplets\x64-windows-static.cmake" -Value "set(VCPKG_BUILD_TYPE release)"
```

Qt
---------------------
In order to build Bitcoin Core a static build of Qt is required. The runtime library version (e.g. v142) and platform type (x86 or x64) must also match.
To build Bitcoin Core with the GUI, a static build of Qt is required.

1. Download a single ZIP archive of Qt source code from https://download.qt.io/official_releases/qt/ (e.g., [`qt-everywhere-src-5.12.11.zip`](https://download.qt.io/official_releases/qt/5.12/5.12.11/single/qt-everywhere-src-5.12.11.zip)), and expand it into a dedicated folder. The following instructions assume that this folder is `C:\dev\qt-source`.

2. Open "x64 Native Tools Command Prompt for VS 2019", and input the following commands:
```cmd
cd C:\dev\qt-source
mkdir build
cd build
..\configure -release -silent -opensource -confirm-license -opengl desktop -no-shared -static -static-runtime -mp -qt-zlib -qt-pcre -qt-libpng -no-libjpeg -nomake examples -nomake tests -nomake tools -no-dbus -no-libudev -no-icu -no-gtk -no-opengles3 -no-angle -no-sql-sqlite -no-sql-odbc -no-sqlite -no-libudev -no-vulkan -skip qt3d -skip qtactiveqt -skip qtandroidextras -skip qtcanvas3d -skip qtcharts -skip qtconnectivity -skip qtdatavis3d -skip qtdeclarative -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmacextras -skip qtmultimedia -skip qtnetworkauth -skip qtpurchasing -skip qtquickcontrols -skip qtquickcontrols2 -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip qtx11extras -skip qtxmlpatterns -no-openssl -no-feature-sql -no-feature-sqlmodel -prefix C:\Qt_static
nmake
nmake install
```

Some prebuilt x64 versions of Qt can be downloaded from [here](https://github.com/sipsorcery/qt_win_binary/releases). Please be aware these downloads are NOT officially sanctioned by Bitcoin Core and are provided for developer convenience only. They should NOT be used for builds that will be used in a production environment or with real funds.
One could speed up building with [`jom`](https://wiki.qt.io/Jom), a replacement for `nmake` which makes use of all CPU cores.

To determine which Qt prebuilt version to download open the `.cirrus.yml` file and note the `QT_DOWNLOAD_URL`. When extracting the zip file the destination path must be set to `C:\`. This is due to the way that Qt includes, libraries and tools use internal paths.
To build Bitcoin Core without Qt, unload or disable the `bitcoin-qt`, `libbitcoin_qt` and `test_bitcoin-qt` projects.

To build Bitcoin Core without Qt unload or disable the `bitcoin-qt`, `libbitcoin_qt` and `test_bitcoin-qt` projects.

Building
---------------------
The instructions below use `vcpkg` to install the dependencies.

- Install [`vcpkg`](https://github.com/Microsoft/vcpkg).

- Use Python to generate `*.vcxproj` from Makefile
1. Use Python to generate `*.vcxproj` from Makefile:

```
PS >py -3 msvc-autogen.py
```

- An optional step is to adjust the settings in the `build_msvc` directory and the `common.init.vcxproj` file. This project file contains settings that are common to all projects such as the runtime library version and target Windows SDK version. The Qt directories can also be set.
2. An optional step is to adjust the settings in the `build_msvc` directory and the `common.init.vcxproj` file. This project file contains settings that are common to all projects such as the runtime library version and target Windows SDK version. The Qt directories can also be set. To specify a non-default path to a static Qt package directory, use the `QTBASEDIR` environment variable.

- To build from the command line with the Visual Studio 2019 toolchain use:
3. To build from the command-line with the Visual Studio 2019 toolchain use:

```
msbuild /m bitcoin.sln /p:Platform=x64 /p:Configuration=Release /t:build
```cmd
msbuild -property:Configuration=Release -maxCpuCount -verbosity:minimal bitcoin.sln
```

- Alternatively, open the `build_msvc/bitcoin.sln` file in Visual Studio 2019.
Alternatively, open the `build_msvc/bitcoin.sln` file in Visual Studio 2019.

Security
---------------------
Expand Down
2 changes: 1 addition & 1 deletion build_msvc/common.qt.init.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup Label="QtGlobals">
<QtBaseDir>C:\Qt5.12.11_x64_static_vs2019_160900</QtBaseDir>
<QtBaseDir Condition="'$(QTBASEDIR)' == ''">C:\Qt_static</QtBaseDir>
<QtPluginsLibraryDir>$(QtBaseDir)\plugins</QtPluginsLibraryDir>
<QtLibraryDir>$(QtBaseDir)\lib</QtLibraryDir>
<QtIncludeDir>$(QtBaseDir)\include</QtIncludeDir>
Expand Down
1 change: 1 addition & 0 deletions ci/test/00_setup_env_i686_multiprocess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export DEP_OPTS="DEBUG=1 MULTIPROCESS=1"
export GOAL="install"
export BITCOIN_CONFIG="--enable-debug CC='clang -m32' CXX='clang++ -m32' LDFLAGS='--rtlib=compiler-rt -lgcc_s'"
export TEST_RUNNER_ENV="BITCOIND=bitcoin-node"
export TEST_RUNNER_EXTRA="--nosandbox"
export PIP_PACKAGES="lief"
39 changes: 38 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ case $host in
;;
esac

AC_ARG_WITH([seccomp],
[AS_HELP_STRING([--with-seccomp],
[enable experimental syscall sandbox feature (-sandbox), default is yes if seccomp-bpf is detected under Linux x86_64])],
[seccomp_found=$withval],
[seccomp_found=auto])

dnl Require C++17 compiler (no GNU extensions)
AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])

Expand Down Expand Up @@ -101,7 +107,7 @@ AC_PATH_TOOL(GCOV, gcov)
AC_PATH_TOOL(LLVM_COV, llvm-cov)
AC_PATH_PROG(LCOV, lcov)
dnl Python 3.6 is specified in .python-version and should be used if available, see doc/dependencies.md
AC_PATH_PROGS([PYTHON], [python3.6 python3.7 python3.8 python3.9 python3 python])
AC_PATH_PROGS([PYTHON], [python3.6 python3.7 python3.8 python3.9, python3.10, python3 python])
AC_PATH_PROG(GENHTML, genhtml)
AC_PATH_PROG([GIT], [git])
AC_PATH_PROG(CCACHE,ccache)
Expand Down Expand Up @@ -1432,6 +1438,36 @@ if test "x$use_external_signer" != xno; then
fi
AM_CONDITIONAL([ENABLE_EXTERNAL_SIGNER], [test "x$use_external_signer" = "xyes"])

dnl Do not compile with syscall sandbox support when compiling under the sanitizers.
dnl The sanitizers introduce use of syscalls that are not typically used in bitcoind
dnl (such as execve when the sanitizers execute llvm-symbolizer).
if test x$use_sanitizers != x; then
AC_MSG_WARN(Specifying --with-sanitizers forces --without-seccomp since the sanitizers introduce use of syscalls not allowed by the bitcoind syscall sandbox (-sandbox=<mode>).)
seccomp_found=no
fi
if test "x$seccomp_found" != "xno"; then
AC_MSG_CHECKING([for seccomp-bpf (Linux x86-64)])
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
@%:@include <linux/seccomp.h>
]], [[
#if !defined(__x86_64__)
# error Syscall sandbox is an experimental feature currently available only under Linux x86-64.
#endif
]])],[
AC_MSG_RESULT(yes)
seccomp_found="yes"
AC_DEFINE(USE_SYSCALL_SANDBOX, 1, [Define this symbol to build with syscall sandbox support.])
],[
AC_MSG_RESULT(no)
seccomp_found="no"
])
fi
dnl Currently only enable -sandbox=<mode> feature if seccomp is found.
dnl In the future, sandboxing could be also be supported with other
dnl sandboxing mechanisms besides seccomp.
use_syscall_sandbox=$seccomp_found
AM_CONDITIONAL([ENABLE_SYSCALL_SANDBOX], [test "x$use_syscall_sandbox" != "xno"])

dnl Check for reduced exports
if test x$use_reduce_exports = xyes; then
AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[CXXFLAGS="$CXXFLAGS -fvisibility=hidden"],
Expand Down Expand Up @@ -1925,6 +1961,7 @@ echo
echo "Options used to compile and link:"
echo " external signer = $use_external_signer"
echo " multiprocess = $build_multiprocess"
echo " with experimental syscall sandbox support = $use_syscall_sandbox"
echo " with libs = $build_bitcoin_libs"
echo " with wallet = $enable_wallet"
if test "x$enable_wallet" != "xno"; then
Expand Down
94 changes: 91 additions & 3 deletions contrib/signet/getcoins.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,77 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

import argparse
import io
import requests
import subprocess
import sys
import requests

DEFAULT_GLOBAL_FAUCET = 'https://signetfaucet.com/claim'
DEFAULT_GLOBAL_CAPTCHA = 'https://signetfaucet.com/captcha'
GLOBAL_FIRST_BLOCK_HASH = '00000086d6b2636cb2a392d45edc4ec544a10024d30141c9adf4bfd9de533b53'

# braille unicode block
BASE = 0x2800
BIT_PER_PIXEL = [
[0x01, 0x08],
[0x02, 0x10],
[0x04, 0x20],
[0x40, 0x80],
]
BW = 2
BH = 4

# imagemagick or compatible fork (used for converting SVG)
CONVERT = 'convert'

class PPMImage:
'''
Load a PPM image (Pillow-ish API).
'''
def __init__(self, f):
if f.readline() != b'P6\n':
raise ValueError('Invalid ppm format: header')
line = f.readline()
(width, height) = (int(x) for x in line.rstrip().split(b' '))
if f.readline() != b'255\n':
raise ValueError('Invalid ppm format: color depth')
data = f.read(width * height * 3)
stride = width * 3
self.size = (width, height)
self._grid = [[tuple(data[stride * y + 3 * x:stride * y + 3 * (x + 1)]) for x in range(width)] for y in range(height)]

def getpixel(self, pos):
return self._grid[pos[1]][pos[0]]

def print_image(img, threshold=128):
'''Print black-and-white image to terminal in braille unicode characters.'''
x_blocks = (img.size[0] + BW - 1) // BW
y_blocks = (img.size[1] + BH - 1) // BH

for yb in range(y_blocks):
line = []
for xb in range(x_blocks):
ch = BASE
for y in range(BH):
for x in range(BW):
try:
val = img.getpixel((xb * BW + x, yb * BH + y))
except IndexError:
pass
else:
if val[0] < threshold:
ch |= BIT_PER_PIXEL[y][x]
line.append(chr(ch))
print(''.join(line))

parser = argparse.ArgumentParser(description='Script to get coins from a faucet.', epilog='You may need to start with double-dash (--) when providing bitcoin-cli arguments.')
parser.add_argument('-c', '--cmd', dest='cmd', default='bitcoin-cli', help='bitcoin-cli command to use')
parser.add_argument('-f', '--faucet', dest='faucet', default=DEFAULT_GLOBAL_FAUCET, help='URL of the faucet')
parser.add_argument('-g', '--captcha', dest='captcha', default=DEFAULT_GLOBAL_CAPTCHA, help='URL of the faucet captcha, or empty if no captcha is needed')
parser.add_argument('-a', '--addr', dest='addr', default='', help='Bitcoin address to which the faucet should send')
parser.add_argument('-p', '--password', dest='password', default='', help='Faucet password, if any')
parser.add_argument('-n', '--amount', dest='amount', default='0.001', help='Amount to request (0.001-0.1, default is 0.001)')
parser.add_argument('-i', '--imagemagick', dest='imagemagick', default=CONVERT, help='Path to imagemagick convert utility')
parser.add_argument('bitcoin_cli_args', nargs='*', help='Arguments to pass on to bitcoin-cli (default: -signet)')

args = parser.parse_args()
Expand Down Expand Up @@ -43,14 +102,43 @@ def bitcoin_cli(rpc_command_and_params):
if curr_signet_hash != GLOBAL_FIRST_BLOCK_HASH:
print('The global faucet cannot be used with a custom Signet network. Please use the global signet or setup your custom faucet to use this functionality.\n')
exit(1)
else:
# For custom faucets, don't request captcha by default.
if args.captcha == DEFAULT_GLOBAL_CAPTCHA:
args.captcha = ''

if args.addr == '':
# get address for receiving coins
args.addr = bitcoin_cli(['getnewaddress', 'faucet', 'bech32'])

data = {'address': args.addr, 'password': args.password}
data = {'address': args.addr, 'password': args.password, 'amount': args.amount}

# Store cookies
# for debugging: print(session.cookies.get_dict())
session = requests.Session()

if args.captcha != '': # Retrieve a captcha
try:
res = session.get(args.captcha)
except:
print('Unexpected error when contacting faucet:', sys.exc_info()[0])
exit(1)

# Convert SVG image to PPM, and load it
try:
rv = subprocess.run([args.imagemagick, '-', '-depth', '8', 'ppm:-'], input=res.content, check=True, capture_output=True)
except FileNotFoundError:
print('The binary', args.imagemagick, 'could not be found. Please make sure ImageMagick (or a compatible fork) is installed and that the correct path is specified.')
exit(1)
img = PPMImage(io.BytesIO(rv.stdout))

# Terminal interaction
print_image(img)
print('Enter captcha: ', end='')
data['captcha'] = input()

try:
res = requests.post(args.faucet, data=data)
res = session.post(args.faucet, data=data)
except:
print('Unexpected error when contacting faucet:', sys.exc_info()[0])
exit(1)
Expand Down
8 changes: 8 additions & 0 deletions doc/release-notes-22539.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Notable changes
===============

P2P and network changes
-----------------------

- Fee estimation now takes the feerate of replacement (RBF) transactions into
account.
5 changes: 4 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ endif
BITCOIN_CORE_H = \
addrdb.h \
addrman.h \
addrman_impl.h \
attributes.h \
banman.h \
base58.h \
Expand Down Expand Up @@ -261,6 +262,7 @@ BITCOIN_CORE_H = \
util/sock.h \
util/spanparsing.h \
util/string.h \
util/syscall_sandbox.h \
util/system.h \
util/thread.h \
util/threadnames.h \
Expand Down Expand Up @@ -498,9 +500,9 @@ crypto_libbitcoin_crypto_shani_a_SOURCES = crypto/sha256_shani.cpp
libbitcoin_consensus_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
libbitcoin_consensus_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_consensus_a_SOURCES = \
amount.h \
arith_uint256.cpp \
arith_uint256.h \
consensus/amount.h \
consensus/merkle.cpp \
consensus/merkle.h \
consensus/params.h \
Expand Down Expand Up @@ -611,6 +613,7 @@ libbitcoin_util_a_SOURCES = \
util/spanparsing.cpp \
util/strencodings.cpp \
util/string.cpp \
util/syscall_sandbox.cpp \
util/time.cpp \
util/tokenpipe.cpp \
$(BITCOIN_CORE_H)
Expand Down
3 changes: 2 additions & 1 deletion src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ BITCOIN_TESTS =\
test/sanity_tests.cpp \
test/scheduler_tests.cpp \
test/script_p2sh_tests.cpp \
test/script_tests.cpp \
test/script_parse_tests.cpp \
test/script_standard_tests.cpp \
test/script_tests.cpp \
test/scriptnum_tests.cpp \
test/serfloat_tests.cpp \
test/serialize_tests.cpp \
Expand Down
Loading