Browse Source

Added for_broadcast argument to payto/paytomany (#6532)

The payto command now takes a flag "addtransaction" whether the returned transaction should be added to the wallet history.
Previously payto did not have a side-effect, and as the flag is opt-in, that will stay the default.

closes #6529
patch-4
MrNaif2018 5 years ago
committed by GitHub
parent
commit
ba649fa8ab
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      electrum/commands.py

16
electrum/commands.py

@ -592,7 +592,7 @@ class Commands:
@command('wp')
async def payto(self, destination, amount, fee=None, feerate=None, from_addr=None, from_coins=None, change_addr=None,
nocheck=False, unsigned=False, rbf=None, password=None, locktime=None, wallet: Abstract_Wallet = None):
nocheck=False, unsigned=False, rbf=None, password=None, locktime=None, addtransaction=False, wallet: Abstract_Wallet = None):
"""Create a transaction. """
self.nocheck = nocheck
tx_fee = satoshis(fee)
@ -613,11 +613,14 @@ class Commands:
rbf=rbf,
password=password,
locktime=locktime)
return tx.serialize()
result = tx.serialize()
if addtransaction:
await self.addtransaction(result, wallet=wallet)
return result
@command('wp')
async def paytomany(self, outputs, fee=None, feerate=None, from_addr=None, from_coins=None, change_addr=None,
nocheck=False, unsigned=False, rbf=None, password=None, locktime=None, wallet: Abstract_Wallet = None):
nocheck=False, unsigned=False, rbf=None, password=None, locktime=None, addtransaction=False, wallet: Abstract_Wallet = None):
"""Create a multi-output transaction. """
self.nocheck = nocheck
tx_fee = satoshis(fee)
@ -641,7 +644,10 @@ class Commands:
rbf=rbf,
password=password,
locktime=locktime)
return tx.serialize()
result = tx.serialize()
if addtransaction:
await self.addtransaction(result, wallet=wallet)
return result
@command('w')
async def onchain_history(self, year=None, show_addresses=False, show_fiat=False, wallet: Abstract_Wallet = None):
@ -1208,6 +1214,7 @@ command_options = {
'unsigned': ("-u", "Do not sign transaction"),
'rbf': (None, "Whether to signal opt-in Replace-By-Fee in the transaction (true/false)"),
'locktime': (None, "Set locktime block number"),
'addtransaction': (None,'Whether transaction is to be used for broadcasting afterwards. Adds transaction to the wallet'),
'domain': ("-D", "List of addresses"),
'memo': ("-m", "Description of the request"),
'expiration': (None, "Time in seconds"),
@ -1249,6 +1256,7 @@ arg_types = {
'fee': lambda x: str(Decimal(x)) if x is not None else None,
'amount': lambda x: str(Decimal(x)) if x != '!' else '!',
'locktime': int,
'addtransaction': eval_bool,
'fee_method': str,
'fee_level': json_loads,
'encrypt_file': eval_bool,

Loading…
Cancel
Save