def sanitize_tx_meta(tx: TransactionType, coin: CoinInfo) -> TransactionType: tx.version = tx.version if tx.version is not None else 1 tx.lock_time = tx.lock_time if tx.lock_time is not None else 0 tx.inputs_cnt = tx.inputs_cnt if tx.inputs_cnt is not None else 0 tx.outputs_cnt = tx.outputs_cnt if tx.outputs_cnt is not None else 0 if coin.extra_data: tx.extra_data_len = tx.extra_data_len if tx.extra_data_len is not None else 0 elif tx.extra_data_len: raise wire.DataError("Extra data not enabled on this coin.") if coin.decred or coin.overwintered: tx.expiry = tx.expiry if tx.expiry is not None else 0 elif tx.expiry: raise wire.DataError("Expiry not enabled on this coin.") if coin.timestamp and not tx.timestamp: raise wire.DataError("Timestamp must be set.") elif not coin.timestamp and tx.timestamp: raise wire.DataError("Timestamp not enabled on this coin.") if coin.overwintered and tx.version_group_id is None: raise wire.DataError("Version group ID must be set.") elif not coin.overwintered: if tx.version_group_id is not None: raise wire.DataError("Version group ID not enabled on this coin.") if tx.branch_id is not None: raise wire.DataError("Branch ID not enabled on this coin.") return tx
def sanitize_tx_meta(tx: TransactionType) -> TransactionType: tx.version = tx.version if tx.version is not None else 1 tx.lock_time = tx.lock_time if tx.lock_time is not None else 0 tx.inputs_cnt = tx.inputs_cnt if tx.inputs_cnt is not None else 0 tx.outputs_cnt = tx.outputs_cnt if tx.outputs_cnt is not None else 0 tx.extra_data_len = tx.extra_data_len if tx.extra_data_len is not None else 0 return tx
def sanitize_tx_meta(tx: TransactionType) -> TransactionType: tx.version = tx.version if tx.version is not None else 1 tx.lock_time = tx.lock_time if tx.lock_time is not None else 0 tx.inputs_cnt = tx.inputs_cnt if tx.inputs_cnt is not None else 0 tx.outputs_cnt = tx.outputs_cnt if tx.outputs_cnt is not None else 0 tx.extra_data_len = tx.extra_data_len if tx.extra_data_len is not None else 0 tx.expiry = tx.expiry if tx.expiry is not None else 0 tx.overwintered = tx.overwintered if tx.overwintered is not None else False tx.timestamp = tx.timestamp if tx.timestamp is not None else 0 return tx
def sanitize_tx_meta(tx: TransactionType, coin: CoinInfo) -> TransactionType: tx.version = tx.version if tx.version is not None else 1 tx.lock_time = tx.lock_time if tx.lock_time is not None else 0 tx.inputs_cnt = tx.inputs_cnt if tx.inputs_cnt is not None else 0 tx.outputs_cnt = tx.outputs_cnt if tx.outputs_cnt is not None else 0 if coin.extra_data: tx.extra_data_len = tx.extra_data_len if tx.extra_data_len is not None else 0 elif tx.extra_data_len: raise SigningError(FailureType.DataError, "Extra data not enabled on this coin.") if coin.decred or coin.overwintered: tx.expiry = tx.expiry if tx.expiry is not None else 0 elif tx.expiry: raise SigningError(FailureType.DataError, "Expiry not enabled on this coin.") if coin.timestamp and not tx.timestamp: raise SigningError(FailureType.DataError, "Timestamp must be set.") elif not coin.timestamp and tx.timestamp: raise SigningError(FailureType.DataError, "Timestamp not enabled on this coin.") return tx