Skip to content

Instantly share code, notes, and snippets.

View Warchant's full-sized avatar
🐻
C++ go brrr

Bohdan Warchant

🐻
C++ go brrr
View GitHub Profile
@Warchant
Warchant / geoip.md
Last active March 31, 2024 14:31
Geoip capabilities with iptables/ufw + automatic IP addr db updates
  1. sudo apt install curl perl unzip xtables-addons-common libtext-csv-xs-perl libmoosex-types-netaddr-ip-perl
  2. Put this into /usr/local/bin/geoip-update.sh
#!/bin/bash -e

WORKDIR=`mktemp -d`
if [[ ! "$WORKDIR" || ! -d "$WORKDIR" ]]; then
        echo "Could not create temp dir"
        exit 1
fi
@Warchant
Warchant / materialize_headers_aspect.bzl
Created December 16, 2023 13:00
Create headers for a target
def _impl(target, ctx):
deps = [target]
if hasattr(ctx.rule.attr, "elf"):
deps.append(ctx.rule.attr.elf)
if hasattr(ctx.rule.attr, "srcs"):
deps.extend(ctx.rule.attr.srcs)
if hasattr(ctx.rule.attr, "deps"):
deps.extend(ctx.rule.attr.deps)
all_header_files = []
@Warchant
Warchant / BUILD
Created February 27, 2023 20:42
Script to generate html report for Bazel C/C++ projects on Linux
package(default_visibility = ["//visibility:public"])
sh_binary(
name = "coverage_linux",
srcs = ["coverage_linux.sh"],
exec_compatible_with = ["@platforms//os:linux"],
tags = [
"block-network",
"local",
"no-cache",
@Warchant
Warchant / grpc.cmake
Last active April 8, 2024 10:57
Protobuf and GRPC automatically downloaded and built with CMake FetchContent
cmake_minimum_required(VERSION 3.16)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0074 NEW)
set(FETCHCONTENT_QUIET OFF)
set(ABSL_PROPAGATE_CXX_STD ON)
set(ABSL_ENABLE_INSTALL ON)
find_package(ZLIB REQUIRED)
FetchContent_Declare(
@Warchant
Warchant / tn2mn.py
Last active May 18, 2023 19:08
Convert testnet private key to mainnet private key in Bitcoin
#!/usr/bin/env python
import base58
import hashlib
main = bytes([128])
test = bytes([239])
def decodeSecret(key, network):
assert isinstance(network, bytes), network
k = base58.b58decode_check(key)
@Warchant
Warchant / blocks.txt
Last active September 15, 2020 11:55
both testnet
popbtcstartheight=1832644
popbtcblocks=00000020DE1649D778B21589051A33B6492091385D66713CA70BEA7A4F00000000000000EC614355165EF6C08C11E96E95C492D166BE4BF68D8CBFE8670D32C5EC25C5A9CD43595F02A6021A681B2B42,0000002043E5CD37B034FDAA4FD7BCA7C201790534F575416B69D348C6010000000000001EBA1686276E1DFCC9F1FF4E7CAB17D24DAFC455DC6E67015ACD2223534D3F071344595F02A6021A457EC1F4,00000020AEC1A982A1F146919C4313F7D18AC1CD9A7635592E38D7C1F901000000000000E4C028A6C080875B8979127F69240D2A68C0CFC4023D8D1036AC49F8ABAB81FEB745595F02A6021A2D05A894,0000C020130BB01BC19301DC1183C65E9411D850542002C844733ADB8702000000000000DE79705A8EFF721A2E646E91F7572D2CD96D67C1EB49A022EBD0E036135ED715B247595F02A6021A054E79D2,00000020A2652B8E8B448A91CC4B63883268C9AC598E7758FE8629CB140100000000000008F530CF2CF653F53C08D71B5B55A4D803A325049D8BDB5C630FD20FFD4914F6FC47595F02A6021A42E282D1,00004020598735F7CA451BEE43250DC90727BF21BEF50B6F267B364B840100000000000077C195153AC2D19570E4C1CE387E3925C5B3608E3AFB9AF1E05E7504651109B29648595F02A6021A4BAAC17B,00000

Running functional tests in vBTC

Ubuntu 18.04 is recommended.

0. Install dependencies

These are dependencies for pypopminer and vbtc build. pypopminer depends on boost-python and python3, vbtc on everything else.

020289020116677996ABBA5C2DBB1E86173B8643E59E3AF3B510713E400009DC1000025303425AF3FE2AB6AC4D5145745BF6C7C66F2E0D6F08BCA1CB161E101967179BB0A082DAFE9212F92804FA5D36E15EFC03190503C07760962B2C01AE0100000001588883A02E563AC310F1915DE165372CC76C320517E645E6B6416D8E6F5BF0520100000000FFFFFFFF020000000000000000536A4C500009DC1000025303425AF3FE2AB6AC4D5145745BF6C7C66F2E0D6F08BCA1CB161E101967179BB0A082DAFE9212F92804FA5D36E15EFC03190503C07760962B2C4F75662BE062DF035A8AA8C6F56DBA301E270400000000001600147673D8D7B18AB3457CFFD3B8E80D00ABE975FBC90000000001D90400000022040000000604000000040000002020E7E15E10EE6B5AB96F1AA71CE85D46964BF9546D669D5D437A63CC39B7E3150B20DAAACA664444521862AAC434BB27F5D8FE211F2B51720BD0D55265A1ED1F8E6720850B46212FC004563181ACEEFAB5C9E9D63BD5AF50A9AB3E50E54D27DD16F60C20844531173567DD3F43DF2ECC09265F4800460E915628B273B9EB7C6E3F54611920D297574069FCD38D015D2C8D856AFB4CADA2E3126968ABDACF1C57415C87B0222092A3728D59A3B64E2BF2B985800D7E644D2E0BAB67F82670651DE2CCFA814BD65000000020AC9BDB60B2D2FD9BF87D7C1C2D7ECC06B1551C
#!/bin/bash -xe
ATV="01F7AA01011667FC9C51C77624DCD81709007D8C92DB6E29935374F80303C4D800010301D4033AE6CA015000000020D9F80B499E1B51117A231981EFBDB1B7237034A142526977614E4CCF06000000283CE1250D90FA23E476060C5E212813592F5C82066793807E73B15BC8FD4E82E4DA995EFFFF7F1D4B107A00016400000001D9F80B499E1B51117A231981EFBDB1B7237034A142526977614E4CCF060000000000000000000000000000000000000000000000000000000000000000000000D894D973E68AD2643DF6A30BC6735AED603C584BA77345AE1B5378A4658148020116001494EBE2911FDC5800D7007C362D339F97676099AB473045022001C222AEECF250EAF7B2D7FC76A3DFE18526BEAACC907EEF00FB2539EEB43F12022100BB3A921CC31CB498366B0BA481D635BC029E8BF65C3E8E4F71AE01DC06334C41583056301006072A8648CE3D020106052B8104000A034200049997CAF150E03AA2AE54E7C08C23DC389B6AA56C6EE6101818AF621B73808E2A6E19360A262382422603AD6B5C38F5D9C0398AC655FE3C82ABA373DEEB0C542E0400000001040000000020FB7191904178A41C05C208ED02BFE8D633E299F0BABEE0531CBAF1B4B5C4AD1C040000000320411E4670D92ABFC5921947E0B2EC524CBCE7386573B4D7D696DE9703C0C5103020000000000000000000