@@ -33,7 +33,7 @@ from electrum import version
|
|||||||
from electrum.wallet import Multisig_Wallet, BIP32_Wallet
|
from electrum.wallet import Multisig_Wallet, BIP32_Wallet
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
from electrum.plugins import BasePlugin, run_hook, hook
|
from electrum.plugins import BasePlugin, run_hook, hook
|
||||||
|
from electrum.util import NotEnoughFunds
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ class Wallet_2fa(Multisig_Wallet):
|
|||||||
def can_sign_without_server(self):
|
def can_sign_without_server(self):
|
||||||
return self.master_private_keys.get('x2/') is not None
|
return self.master_private_keys.get('x2/') is not None
|
||||||
|
|
||||||
def extra_fee(self, tx):
|
def extra_fee(self, tx=None):
|
||||||
if self.can_sign_without_server():
|
if self.can_sign_without_server():
|
||||||
return 0
|
return 0
|
||||||
if self.billing_info.get('tx_remaining'):
|
if self.billing_info.get('tx_remaining'):
|
||||||
@@ -216,7 +216,7 @@ class Wallet_2fa(Multisig_Wallet):
|
|||||||
# trustedcoin won't charge if the total inputs is lower than their fee
|
# trustedcoin won't charge if the total inputs is lower than their fee
|
||||||
price = int(self.price_per_tx.get(1))
|
price = int(self.price_per_tx.get(1))
|
||||||
assert price <= 100000
|
assert price <= 100000
|
||||||
if tx.input_value() < price:
|
if tx and tx.input_value() < price:
|
||||||
self.print_error("not charging for this tx")
|
self.print_error("not charging for this tx")
|
||||||
return 0
|
return 0
|
||||||
return price
|
return price
|
||||||
@@ -226,17 +226,23 @@ class Wallet_2fa(Multisig_Wallet):
|
|||||||
fee += self.extra_fee(tx)
|
fee += self.extra_fee(tx)
|
||||||
return fee
|
return fee
|
||||||
|
|
||||||
def get_tx_fee(self, tx):
|
def make_unsigned_transaction(self, coins, outputs, config,
|
||||||
fee = Multisig_Wallet.get_tx_fee(self, tx)
|
fixed_fee=None, change_addr=None):
|
||||||
fee += self.extra_fee(tx)
|
tx = BIP32_Wallet.make_unsigned_transaction(
|
||||||
return fee
|
self, coins, outputs, config, fixed_fee, change_addr)
|
||||||
|
# Plain TX was good. Now add trustedcoin fee.
|
||||||
def make_unsigned_transaction(self, *args):
|
fee = self.extra_fee()
|
||||||
tx = BIP32_Wallet.make_unsigned_transaction(self, *args)
|
|
||||||
fee = self.extra_fee(tx)
|
|
||||||
if fee:
|
if fee:
|
||||||
address = self.billing_info['billing_address']
|
address = self.billing_info['billing_address']
|
||||||
tx.outputs.append(('address', address, fee))
|
outputs = outputs + [('address', address, fee)]
|
||||||
|
try:
|
||||||
|
return BIP32_Wallet.make_unsigned_transaction(
|
||||||
|
self, coins, outputs, config, fixed_fee, change_addr)
|
||||||
|
except NotEnoughFunds:
|
||||||
|
# trustedcoin won't charge if the total inputs is
|
||||||
|
# lower than their fee
|
||||||
|
if tx.input_value() >= tcoin_fee:
|
||||||
|
raise
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
def sign_transaction(self, tx, password):
|
def sign_transaction(self, tx, password):
|
||||||
|
|||||||
Reference in New Issue
Block a user