Skip to content
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

Add "manual" tx_broadcast method #414

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion jmclient/jmclient/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,11 @@ def jm_single():
# spends from unconfirmed inputs, which may then get malleated or double-spent!
# other counterparties are likely to reject unconfirmed inputs... don't do it.

# options: self, random-peer, not-self (note: currently, ONLY 'self' works).
# options: self, random-peer, not-self, manual (note: currently, ONLY 'self' and 'manual' works).
# self = broadcast transaction with your bitcoin node's ip
# random-peer = everyone who took part in the coinjoin has a chance of broadcasting
# not-self = never broadcast with your own ip
# manual = don't broadcast at all, output tx data for manual broadcast by the user
tx_broadcast = self

# If makers do not respond while creating a coinjoin transaction,
Expand Down
8 changes: 6 additions & 2 deletions jmclient/jmclient/taker.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from jmbitcoin import SerializationError, SerializationTruncationError
import jmbitcoin as btc
from jmclient.configure import jm_single, validate_address
from jmbase.support import get_log
from jmbase.support import get_log, jmprint
from jmclient.support import (calc_cj_fee, weighted_order_choose, choose_orders,
choose_sweep_orders)
from jmclient.wallet import estimate_tx_fee
Expand Down Expand Up @@ -819,8 +819,12 @@ def push(self):
else:
nick_to_use = list(self.maker_utxo_data.keys())[i]
pushed = True
elif tx_broadcast == 'manual':
jmprint("Transaction data for manual broadcast:")
jmprint(tx)
pushed = True
else:
jlog.info("Only self, random-peer and not-self broadcast "
jlog.info("Only self, random-peer, not-self and manual broadcast "
"methods supported. Reverting to self-broadcast.")
pushed = jm_single().bc_interface.pushtx(tx)
if not pushed:
Expand Down
12 changes: 9 additions & 3 deletions jmclient/jmclient/taker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ def direct_send(wallet_service, amount, mixdepth, destaddr, answeryes=False,
log.info(tx)
actual_amount = amount if amount != 0 else total_inputs_val - fee_est
log.info("Sends: " + str(actual_amount) + " satoshis to address: " + destaddr)
if not answeryes:

tx_broadcast = jm_single().config.get('POLICY', 'tx_broadcast')

if not answeryes and tx_broadcast != "manual":
if not accept_callback:
if input('Would you like to push to the network? (y/n):')[0] != 'y':
log.info("You chose not to broadcast the transaction, quitting.")
Expand All @@ -95,9 +98,12 @@ def direct_send(wallet_service, amount, mixdepth, destaddr, answeryes=False,
fee_est)
if not accepted:
return False
jm_single().bc_interface.pushtx(tx)
txid = txhash(tx)
successmsg = "Transaction sent: " + txid
if tx_broadcast != "manual":
jm_single().bc_interface.pushtx(tx)
successmsg = "Transaction sent: " + txid
else:
successmsg = "Broadcast manually:\n\n" + tx + "\n\nTransaction id: " + txid
cb = log.info if not info_callback else info_callback
cb(successmsg)
return txid
Expand Down
4 changes: 2 additions & 2 deletions scripts/qtsupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
"consider switching to DEBUG in case of problems.",
"absurd_fee_per_kb": "maximum satoshis/kilobyte you are willing to pay,\n" +
"whatever the fee estimate currently says.",
"tx_broadcast": "Options: self, random-peer, not-self (note: random-maker\n" +
"is not currently supported).\n" +
"tx_broadcast": "Options: self, random-peer, not-self, manual\n" +
"(note: only self and manual is currently supported).\n" +
"self = broadcast transaction with your own ip\n" +
"random-peer = everyone who took part in the coinjoin has\n" +
"a chance of broadcasting.\n" +
Expand Down