Allow sending transactions with relaying disabled

This commit is contained in:
Michał Sałaban 2018-01-31 00:21:53 +01:00
parent c073a9d1a3
commit 323746b80a
2 changed files with 5 additions and 3 deletions

View file

@ -27,10 +27,10 @@ class JSONRPCDaemon(object):
info = self.raw_jsonrpc_request('get_info')
return info
def send_transaction(self, blob):
def send_transaction(self, blob, relay=True):
res = self.raw_request('/sendrawtransaction', {
'tx_as_hex': blob,
'do_not_relay': False})
'do_not_relay': not relay})
if res['status'] == 'OK':
return res
raise exceptions.TransactionBroadcastError(

View file

@ -22,6 +22,8 @@ argsparser.add_argument('-v', dest='verbosity', action='count', default=0,
help="Verbosity (repeat to increase; -v for INFO, -vv for DEBUG")
argsparser.add_argument('-i', dest='tx_filenames', nargs='+', default=None,
help="Files with transaction data. Will read from stdin if not given.")
argsparser.add_argument('--no-relay', dest='relay', action='store_false',
help="Do not relay the transaction (it will stay at the node unless mined or expired)")
args = argsparser.parse_args()
level = logging.WARNING
if args.verbosity == 1:
@ -38,7 +40,7 @@ for name, blob in blobs:
logging.debug("Sending {}".format(name))
tx = Transaction(blob=blob)
try:
res = d.send_transaction(tx)
res = d.send_transaction(tx, relay=args.relay)
except exceptions.TransactionBroadcastError as e:
print("{} not sent, reason: {}".format(name, e.details['reason']))
logging.debug(e.details)