electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit ba649fa8ab61a758a2a8bdb7f3c4d0f6ddee17a6
parent 2c7da6afde82cb690955b1599cc69dd5f034c14f
Author: MrNaif2018 <39452697+MrNaif2018@users.noreply.github.com>
Date:   Tue,  1 Sep 2020 22:25:36 +0300

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 
Diffstat:
Melectrum/commands.py | 16++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/electrum/commands.py b/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,