openoms / joininbox

A terminal based graphical menu for JoinMarket
MIT License
154 stars 21 forks source link

txCast to broadcast payments at random times over Tor #48

Open openoms opened 3 years ago

openoms commented 3 years ago

https://twitter.com/6102bitcoin/status/1389332245765369856?s=19

https://github.com/txCastOrg/txCast/

openoms commented 3 years ago

an alternative solution which better suits the joininbox environment is scheduling the torthistx command.

Example of broadcasting a raw transaction with the Blockstream.info API via Tor an hour later: nohup bash -c "sleep $((1*60*60)) ; torthistx RAW_TRANSACTION" &

nyxnor commented 3 years ago

change circuits

sudo apt-get install python-stem python3-stem

Call tor.newcircuit.py

import sys,os
from stem import Signal
from stem.control import Controller
port = sys.argv[1]
port_int = int(port)
print(port_int)

with Controller.from_port(port = port_int) as controller:
  controller.authenticate()
  controller.signal(Signal.NEWNYM)

tor.newaddress.sh [bitcoin | lnd | cln]

#!/bin/bash

service=${1}
if [ "${service}" = "bitcoin" ]; then
  port=9050
  controlPort=9051
elif [ "${service}" = "lnd" ]; then
  port=9070
  controlPort=9071
elif [ "${service}" = "cln" ]; then
  port=9090
  controlPort=9091
else
  echo "Invalid service ${1}"
fi

oldID=$(curl --connect-timeout 15 --socks5-hostname 127.0.0.1:${port} ifconfig.me 2>/dev/null)

echo "Requesting new identity for ${1}..."
sudo python tor.newcircuit.py ${controlPort}

sleep 5

newID=$(curl --connect-timeout 15 --socks5-hostname 127.0.0.1:${port} ifconfig.me 2>/dev/null)

echo
if [ ${oldID} = ${newID} ]; then
  echo "Fail !!!: Identity for ${service} did not change. Read error message above."
else
  echo "Success !!!"
  echo "${1} --> Old id: " ${oldID} "> New id: " ${newID}
fi
openoms commented 3 years ago

Thanks @nyxnor , this is great. Happy to take it as a PR. The two Tor scripts can be place to scripts/standalone so they don't interfere with the scripts on the raspiblitz.

nyxnor commented 3 years ago

Do it. :100:

ouch, I thouht you wanted to PR, misunderstood. Will work on it (to add time between tx)

openoms commented 3 years ago

@nyxnor just these two simple scripts can be useful, no need to add anything to start.

nyxnor commented 3 years ago

Ok, will do.

Just points for improvements next time, I understand the structure he did that was to be compatible with different implementations, but here are a few points to fit the project

openoms commented 3 years ago

I think TxCast is still in the experimental phase, good to keep an eye on it, but for now I'd just extend the torthistx command with the tor circuit renewal on every send.

nyxnor commented 3 years ago

Stem will help a lot doing all of this.... https://stem.torproject.org/tutorials/down_the_rabbit_hole.html

sudo tor-prompt --run '/help'
sudo tor-prompt --run 'SIGNAL NEWNYM'
sudo tor-prompt --interface 9051

One line command to work with the destined control port

sudo -u debian-tor tor-prompt --run 'SIGNAL NEWNYM' -i 9071

If not mentioning the control port, will use default 9051.

nyxnor commented 2 years ago

With knowledge, rereading this thread makes me feel noob.

There is no need to signal newnym.

There are various ways this can be done. As the tool here is cURL, and we are always reaching the same DestAddr and DestPort basically, we can use a different SOCKSAuth to isolate the requests via the isolation flag IsolateSOCKSAuth.

example:

curl -x socks5h://$RANDOM:$RANDOM@127.0.0.1:9050 https://check.torproject.org/api/ip
## or
curl -U $RANDOM:$RANDOM -x socks5h://127.0.0.1:9050 https://check.torproject.org/api/ip

The random variable is used in place of the user and password, which tor does not validate, just check if it is different then before.

The above only covers stream isolation, not broadcasting at random times.