Skip to content

Instantly share code, notes, and snippets.

View bbrtj's full-sized avatar
🐪

Bartosz Jarzyna bbrtj

🐪
View GitHub Profile
@bbrtj
bbrtj / btc_tx.pl
Created September 20, 2023 17:00
Bitcoin::Crypto transaction signing
use v5.38;
use Bitcoin::Crypto qw(btc_transaction btc_utxo btc_prv);
use Bitcoin::Crypto::Util qw(to_format);
my $tx = btc_transaction->new;
btc_utxo->extract([hex => '010000000001025c86bc8650181835c3853d685cf11f6fa42a8eb9e59cb25b2de64ae33ccdb9e00000000000ffffffffeb42cef4d898b0c1d93dd0aca91ef140ba2df35d5b722a18b2d88d3c255278de0000000000ffffffff021027000000000000160014dbabdc8a9a03e3e7268e7e87f99f1af235e7bebb4594000000000000160014df212a4c455f96199371a616ee30f9cd1b55c0b402483045022100e14daab47feff38dca3acbd04eb0036a1c64efdd3c5bd34c6a06a3612543422102201816503f77b3595fc7d829bbfd82282d9bc5b37bb7771070d0f7d74381fa8ccd0121037e01f2929a9219a7862fc25848a85df69b6a8ef49b7edbebfa64a095e136897d024730440220017703b6a4b0f6cc7799b0b7cae24f1a65188d0f40c28bb118b5c56de6f050ba022029f2e64ab5a6e9b04c07ac56bd46b07068d9ffe2b41fa6ff8f958d7dfa09be0c012103f97e2a442ed2bd4cb01fbf7c2ee8d0bd30dac47478671fb3a3bbef23ca57c71000000000']);
$tx->add_input(
utxo => [[hex => 'a40c8709df98bcdc33619c937730bb15bace2133cff233730601bae352751f38'], 0],
@bbrtj
bbrtj / .gutctags
Last active December 12, 2022 17:37 — forked from sgur/.ctags
Free pascal / Object pascal Universal ctags config
--regex-pascal=/^\s*(\w+)\s*=\s*\(\s*\w\s*\)/\1/t,Type/
--regex-pascal=/^\s*(\w+)\s*=\s*class/\1/c,Class/
--regex-pascal=/^constructor\s+(T[a-zA-Z0-9_]+(<[a-zA-Z0-9_, ]+>)?\.)([a-zA-Z0-9_<>, ]+)(.*)+/\1\3/n,Constructor/
--regex-pascal=/^destructor\s+(T[a-zA-Z0-9_]+(<[a-zA-Z0-9_, ]+>)?\.)([a-zA-Z0-9_<>, ]+)(.*)+/\1\3/d,Destructor/
--regex-pascal=/^(procedure|function)\s+T[a-zA-Z0-9_<>, ]+\.([a-zA-Z0-9_<>, ]+)(.*)/\2/m,Method/
@bbrtj
bbrtj / bench.pl
Created November 19, 2022 15:05
Mouse vs Moose vs Moo
package T1 {
use Moo;
has 'f1' => (
is => 'ro'
);
}
package TMoose {
use Moose;
use v5.20;
use warnings;
use File::Copy;
# ldd BINARY | perl extract_shared.pl
die 'files directory already exists' if -d 'files';
mkdir 'files';
while (my $line = <STDIN>) {
@bbrtj
bbrtj / spaces.pl
Created October 16, 2021 09:00
Recursively replace space indentation with tabs
use v5.12;
use warnings;
use autodie;
use File::Copy qw(move);
# spaces.pl path/to/dir spaces_num
my $dir = shift;
my $spaces = shift() // 4;
my $spaces_str = ' ' x $spaces;
@bbrtj
bbrtj / paperwallet.pl
Last active November 1, 2021 21:01
Bitcoin paper wallet generator
# Only here for historic reasons. Use instead: https://metacpan.org/dist/App-Bitcoin-PaperWallet/view/bin/paper-wallet
use v5.24;
use warnings;
use utf8;
use Text::QRCode;
use Bitcoin::Crypto qw(btc_extprv);
use List::Util qw(pairs);
use Digest::SHA qw(sha256);
@bbrtj
bbrtj / sign.pl
Created June 12, 2021 09:33
Sign and verify a message
use v5.20;
use warnings;
use Bitcoin::Crypto qw(btc_prv);
my $wif = 'KzTvd4uwnyRsFyoyTUWicxvP1HVQhTfsNLGVeyZSD6eajpTYvaRk';
my $private_key = btc_prv->from_wif($wif);
my $message = 'I own this Bitcoin address! ' . $private_key->get_public_key->get_legacy_address;
my $signature = $private_key->sign_message($message);
@bbrtj
bbrtj / bitcoin.pl
Created June 12, 2021 08:24
Describe a Bitcoin wallet
use v5.20;
use warnings;
use Bitcoin::Crypto qw(btc_prv);
use Math::BigInt;
# generated on https://learnmeabitcoin.com/technical/wif
my $wif = 'KzTvd4uwnyRsFyoyTUWicxvP1HVQhTfsNLGVeyZSD6eajpTYvaRk';
my $private_key = btc_prv->from_wif($wif);