@@ -1879,8 +1879,10 @@ def make_unsigned_transaction(
1879
1879
# make sure we don't try to spend change from the tx-to-be-replaced:
1880
1880
coins = [c for c in coins if c .prevout .txid .hex () != base_tx .txid ()]
1881
1881
is_local = self .adb .get_tx_height (base_tx .txid ()).height == TX_HEIGHT_LOCAL
1882
- base_tx = PartialTransaction .from_tx (base_tx )
1883
- base_tx .add_info_from_wallet (self )
1882
+ if not isinstance (base_tx , PartialTransaction ):
1883
+ # don't do this with a PartialTransaction, as this is destructive
1884
+ base_tx = PartialTransaction .from_tx (base_tx )
1885
+ base_tx .add_info_from_wallet (self )
1884
1886
base_tx_fee = base_tx .get_fee ()
1885
1887
base_feerate = Decimal (base_tx_fee )/ base_tx .estimated_size ()
1886
1888
relayfeerate = Decimal (self .relayfee ()) / 1000
@@ -2550,11 +2552,13 @@ def sign_transaction(self, tx: Transaction, password, *, ignore_warnings: bool =
2550
2552
2551
2553
for i , txin in enumerate (tx .inputs ()):
2552
2554
if hasattr (txin , 'make_witness' ):
2555
+ self .logger .info (f'sign_transaction: adding witness using make_witness' )
2553
2556
privkey = txin .privkey
2554
2557
sig = tx .sign_txin (i , privkey )
2555
2558
assert sig
2556
2559
assert txin .witness_script
2557
2560
txin .witness = txin .make_witness (sig )
2561
+ assert txin .is_complete ()
2558
2562
2559
2563
# check if signing is dangerous
2560
2564
sh_danger = self .check_sighash (tx )
@@ -3339,6 +3343,18 @@ def to_sweep_after(self, tx):
3339
3343
tx_prevouts = set (txin .prevout for txin in tx .inputs ())
3340
3344
return dict ((k ,v ) for k ,v in self .batch_inputs .items () if k not in tx_prevouts )
3341
3345
3346
+ def should_bump_fee (self , base_tx ):
3347
+ # fixme: since batch_txs is not persisted, we do not bump after a restart
3348
+ # fixme: we use estimated_size because create_transaction returns a PartialTransaction
3349
+ if base_tx is None :
3350
+ return False
3351
+ base_tx_fee = base_tx .get_fee ()
3352
+ recommended_fee = self .config .estimate_fee (base_tx .estimated_size (), allow_fallback_to_static_rates = True )
3353
+ should_bump_fee = base_tx_fee * 1.1 < recommended_fee
3354
+ if should_bump_fee :
3355
+ self .logger .info (f'base tx fee too low { base_tx_fee } < { recommended_fee } . we will bump the fee' )
3356
+ return should_bump_fee
3357
+
3342
3358
@log_exceptions
3343
3359
async def manage_batch_payments (self ):
3344
3360
#
@@ -3386,7 +3402,7 @@ async def manage_batch_payments(self):
3386
3402
to_pay = self .to_pay_after (base_tx )
3387
3403
to_sweep = self .to_sweep_after (base_tx )
3388
3404
to_sweep_now = dict ([(k ,v ) for k ,v in to_sweep .items () if self .can_broadcast (v )[0 ] is True ])
3389
- if not to_pay and not to_sweep_now :
3405
+ if not to_pay and not to_sweep_now and not self . should_bump_fee ( base_tx ) :
3390
3406
continue
3391
3407
try :
3392
3408
tx = self .create_batch_tx (base_tx , to_sweep_now , to_pay , password )
0 commit comments