[int(utxo_to_spend["value"] * XEC) for utxo_to_spend in utxos_to_spend]
),
)
if target_size:
pad_tx(tx, target_size)
txid = tx.rehash()
return {
"new_utxos": [
self._create_utxo(
txid=txid,
vout=i,
value=Decimal(tx.vout[i].nValue) / XEC,
height=0,
coinbase=False,
confirmations=0,
)
for i in range(len(tx.vout))
],
"fee": fee,
"txid": txid,
"hex": tx.serialize().hex(),
"tx": tx,
}
def create_self_transfer(
self,
*,
fee_rate=Decimal("3000.00"),
fee=Decimal("0"),
utxo_to_spend=None,
locktime=0,
sequence=0,
target_size=0,
confirmed_only=False,
):
"""Create and return a tx with the specified fee. If fee is 0, use fee_rate, where the resulting fee may be exact or at most one satoshi higher than needed."""
utxo_to_spend = utxo_to_spend or self.get_utxo(confirmed_only=confirmed_only)
assert fee_rate >= 0
assert fee >= 0
if self._mode == MiniWalletMode.ADDRESS_OP_TRUE:
# anyone-can-spend, the size will be enforced by pad_tx()