commit f4fb464ef8a44f6617debde9275d90ae0830e5e6
parent 4c55ff7d576c58dab2e0c8ee3ac22c5e6f0ef78a
Author: William Casarin <jb55@jb55.com>
Date: Sat, 29 Oct 2022 06:12:19 -0700
monad changes
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
18 files changed, 149 insertions(+), 9 deletions(-)
diff --git a/bin/btc-fetchblocks b/bin/btc-fetchblocks
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+
+BITCOIN_RPCUSER=rpcuser
+BITCOIN_RPCPASS=rpcpass
+BITCOIN_RPCPORT=${BITCOIN_RPCPORT:-8332}
+BITCOIN_HOST=${BITCOIN_HOST:-127.0.0.1}
+
+mkreq () {
+ (
+ printf '['
+ echo ${1#","}
+ printf ']'
+ )
+}
+
+doreq() {
+ local host="http://${BITCOIN_HOST}:${BITCOIN_RPCPORT}"
+ mkreq "$1" |
+ curl -s -u $BITCOIN_RPCUSER:$BITCOIN_RPCPASS \
+ --data-binary @- \
+ -H 'content-type: text/plain;' "$host"
+}
+
+make_hash_reqs() {
+ xargs printf ',{"jsonrpc": "1.0", "id":"blockhashes", "method": "getblockhash", "params": [%d] }\n'
+}
+
+make_block_reqs() {
+ xargs printf ',{"jsonrpc": "1.0", "id":"blocks", "method": "getblock", "params": ["%s", 2] }\n'
+}
+
+block_reqs=$(
+doreq "$(make_hash_reqs)" |
+jq -cr '.[].result' |
+make_block_reqs
+)
+
+doreq "$block_reqs" | jq -cr '.[].result'
diff --git a/bin/btc-fetchtxs b/bin/btc-fetchtxs
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+
+BITCOIN_RPCUSER=rpcuser
+BITCOIN_RPCPASS=rpcpass
+BITCOIN_RPCPORT=${BITCOIN_RPCPORT:-8332}
+BITCOIN_HOST=${BITCOIN_HOST:-127.0.0.1}
+
+mkreq () {
+ (
+ printf '['
+ echo ${1#","}
+ printf ']'
+ )
+}
+
+doreq() {
+ local host="http://${BITCOIN_HOST}:${BITCOIN_RPCPORT}"
+ mkreq "$1" |
+ curl -s -u $BITCOIN_RPCUSER:$BITCOIN_RPCPASS \
+ --data-binary @- \
+ -H 'content-type: text/plain;' "$host"
+}
+
+make_reqs() {
+ xargs printf ',{"jsonrpc": "1.0", "id":"get_txids", "method": "getrawtransaction", "params": ["%s", 1] }\n'
+}
+
+txid_reqs=$(make_reqs)
+
+doreq "$txid_reqs" | jq '.[].result'
diff --git a/bin/btc-mempooltxs b/bin/btc-mempooltxs
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+bcli getrawmempool false | jq -r '.[]' | btc-fetchtxs
diff --git a/bin/ffdesktop b/bin/ffdesktop
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+ffmpeg -f x11grab -s 1920x1080 -i :0.0 -preset ultrafast -vcodec libx264 -tune zerolatency -b 900k -f mpegts udp://192.168.87.100:55000
diff --git a/bin/ffkms b/bin/ffkms
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+
+ffmpeg \
+ -f kmsgrab \
+ -thread_queue_size 64 \
+ -i - \
+ -vf 'hwmap=derive_device=vaapi,hwdownload,format=bgr0,scale=1280:720' \
+ -c:v libx264 \
+ -preset:v superfast \
+ -tune zerolatency \
+ -intra-refresh 1 \
+ -f mpegts \
+ -b:v 3M \
+ udp://10.100.0.2:55000
+
+ #-f pulse \
+ #-i 'alsa_output.pci-0000_26_00.1.hdmi-stereo.monitor' \
diff --git a/bin/lnaddress b/bin/lnaddress
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+name=$(cut -f1 -d@ <<<"$1")
+host=$(cut -f2 -d@ <<<"$1")
+
+curl -sL "https://$host/.well-known/lnurlp/$name" | jq
diff --git a/bin/lnlink b/bin/lnlink
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+nodehost=$(lightning-cli getinfo | jq -r '. as $r | .address[0] | "\($r.id)@\(.address):\(.port)"')
+token=$(lightning-cli commando-rune "$@" | jq -r '.rune | @uri')
+echo "lnlink:$nodehost?token=$token"
diff --git a/bin/nannypay b/bin/nannypay
@@ -7,8 +7,6 @@ if [ -z "$NANNY" ]; then
exit 1
fi
-pay=20
-
if [ -z $pay ]; then
printf "unknown pay for %s\n" "$NANNY"
exit 1
@@ -16,6 +14,8 @@ fi
CSV="${NANNYPAY_CSV:-$HOME/.local/share/nannypay/${NANNY}.tsv}"
+
+set -e
mkdir -p "$(dirname "$CSV")"
if [ ! -f "$CSV" ]; then
touch "$CSV"
diff --git a/bin/nctor b/bin/nctor
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+nc -v -w 1 -x 127.0.0.1:9050 -z "$@"
diff --git a/bin/nostril b/bin/nostril
Binary files differ.
diff --git a/bin/relayer b/bin/relayer
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+POST="$(cat)"
+
+printf "using post '%s'\n" "$POST" >&2
+
+for relay in $(cat ~/dotfiles/relays)
+do
+ echo "$POST" | websocat "$relay" &
+done
+
+wait
diff --git a/dotfiles/relays b/dotfiles/relays
@@ -0,0 +1,5 @@
+wss://relay.damus.io
+wss://nostr.bitcoiner.social
+wss://nostr-relay.wlvs.space
+wss://nostr-relay.freeberty.net
+wss://nostr-pub.wellorder.net
diff --git a/nix-config/environment/default.nix b/nix-config/environment/default.nix
@@ -35,7 +35,7 @@ let jb55pkgs = import <jb55pkgs> { inherit pkgs; };
tut
python3Packages.num2words
- python3Packages.howdoi
+ #python3Packages.howdoi
tree
datefmt
nncp
diff --git a/nix-config/environment/desktop/default.nix b/nix-config/environment/desktop/default.nix
@@ -41,7 +41,7 @@ let gtk2rc = pkgs.writeText "gtk2rc" ''
colorpicker
dasht
dmenu
- dragon-drop
+ xdragon
dunst
dynamic-colors
feh
diff --git a/nix-config/hardware/desktop/default.nix b/nix-config/hardware/desktop/default.nix
@@ -84,7 +84,7 @@ in
EndSection
'';
- services.printing.drivers = [ pkgs.cups-brother-hll2370dw ];
+ #services.printing.drivers = [ pkgs.cups-brother-hll2370dw ];
boot.blacklistedKernelModules = ["dvb_usb_rtl28xxu"];
fileSystems."/media/kindle" =
diff --git a/nix-config/machines/monad/bitcoin/default.nix b/nix-config/machines/monad/bitcoin/default.nix
@@ -2,6 +2,10 @@ extra:
{ config, lib, pkgs, ... }:
let
+ jb55pkgs = import <jb55pkgs> { inherit pkgs; };
+
+ nostril = jb55pkgs.nostril;
+
nix-bitcoin = import (pkgs.fetchFromGitHub {
owner = "fort-nix";
repo = "nix-bitcoin";
@@ -34,7 +38,7 @@ let
addr = extra.private.btc-supplier-addr;
};
- walletemail = import ./walletemail.nix { inherit pkgs bcli; };
+ walletemail = import ./walletemail.nix { inherit pkgs bcli nostril; inherit (extra) private; };
spark-module = import ./modules/spark-wallet.nix nix-bitcoin.spark-wallet;
spark-port = 9962;
@@ -55,6 +59,14 @@ in
server_name wallet.jb55.com;
+ location /core/ {
+ alias /var/www/lnlink-core/;
+ }
+
+ location /cln/ {
+ alias /var/www/btcmerchant/;
+ }
+
location / {
proxy_pass http://127.0.0.1:9962;
diff --git a/nix-config/machines/monad/bitcoin/walletemail.nix b/nix-config/machines/monad/bitcoin/walletemail.nix
@@ -1,4 +1,4 @@
-{ pkgs, bcli }:
+{ pkgs, private, bcli, nostril }:
pkgs.writeScript "walletemail" ''
#!${pkgs.bash}/bin/bash
@@ -26,8 +26,10 @@ received="$(date -d @$(${pkgs.jq}/bin/jq -r '.timereceived' <<<"$tx"))"
export GNUPGHOME=/zbig/bitcoin/gpg
-msg="$(printf "txid: %s\n\naddress: %s\n\namount: %s\n\nconfirmations: %d\n\nwallet: %s\n\ntime: %s\n\nreceived: %s\n\nkeypath: %s\n\n%s\n\n\n%s" \
- "$txid" "$address" "$amount" "$confs" "$wallet" "$time" "$received" "$keypath" "$details" "$tx" )"
+msg="$(printf "txid: %s\n\naddress: %s\n\namount: %s\n\nconfirmations: %d\n\nwallet: %s\n\ntime: %s\n\nreceived: %s\n\nkeypath: %s\n\n%s\n" \
+ "$txid" "$address" "$amount" "$confs" "$wallet" "$time" "$received" "$keypath" "$details" )"
+
+${nostril}/bin/nostril --sec ${private.wallet-nostr} --envelope -p 32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245 --content "$msg" | ${pkgs.websocat}/bin/websocat ws://127.0.0.1:8080
enctx="$(printf "Content-Type: text/plain\n\n%s\n" "$msg" | ${pkgs.gnupg}/bin/gpg --yes --always-trust --encrypt --armor $keys)"
diff --git a/nix-config/machines/monad/default.nix b/nix-config/machines/monad/default.nix
@@ -416,6 +416,14 @@ in
# '';
# };
+ # for kmsgrab streaming
+ security.wrappers.ffmpeg = {
+ source = "${pkgs.ffmpeg}/bin/ffmpeg";
+ capabilities = "cap_sys_admin+ep";
+ owner = "root";
+ group = "root";
+ };
+
# security.pam.u2f = {
# enable = true;
# interactive = true;