Skip to content

Commit

Permalink
Namecoin: Rebrand "satoshi"/"sat" to "swartz"
Browse files Browse the repository at this point in the history
Also add a static analysis check for this.
  • Loading branch information
JeremyRand committed Feb 17, 2020
1 parent c203c88 commit 8a4d8aa
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 18 deletions.
26 changes: 26 additions & 0 deletions contrib/check_nmc_rebranding
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,32 @@ for i in **/*.py; do
exit 1
fi

if ./contrib/print_python_strings "$i" "sat" \
| grep -v "amount_msat" \
| grep -v "amount_sat" \
| grep -v "balance_msat" \
| grep -v "capacity_sat" \
| grep -v "channel_reserve_satoshis" \
| grep -v "dust_limit_sat" \
| grep -v "fee_msat" \
| grep -v "fee_sat" \
| grep -v "fee_base_msat" \
| grep -v "funding_sat" \
| grep -v "htlc_minimum_msat" \
| grep -v "htlc_maximum_msat" \
| grep -v "max_htlc_value_in_flight_msat" \
| grep -v "MAXIMUM_HTLC_MINIMUM_MSAT_ACCEPTED" \
| grep -v "push_msat" \
| grep -v "value_sats" \
| grep -v "satisfied" \
| grep -v "electrum/gui/text.py.*'satoshis'" \
| grep -v "electrum/old_mnemonic.py" \
| grep -v "electrum/util.py.*'Satoshis(%d)'" \
| grep -v "electrum/tests/.*\.py"; then
echo "Rebranding needed"
exit 1
fi

# coldcard plugin uses "b'1234 Electrum Plugin 4321'" as a ping echo blob
# keepkey plugin uses '"electrum pinging device"' as a ping echo blob
# safe_t plugin uses '"electrum pinging device"' as a ping echo blob
Expand Down
2 changes: 1 addition & 1 deletion electrum_nmc/electrum/gui/kivy/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ def format_amount_and_units(self, x):

def format_fee_rate(self, fee_rate):
# fee_rate is in sat/kB
return format_fee_satoshis(fee_rate/1000) + ' sat/byte'
return format_fee_satoshis(fee_rate/1000) + ' swartz/byte'

#@profiler
def update_wallet(self, *dt):
Expand Down
4 changes: 2 additions & 2 deletions electrum_nmc/electrum/gui/kivy/uix/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def get_card(self, tx_item): #tx_hash, tx_mined_status, value, balance):
message = tx_item['label']
fee_msat = tx_item['fee_msat']
fee = int(fee_msat/1000) if fee_msat else None
fee_text = '' if fee is None else 'fee: %d sat'%fee
fee_text = '' if fee is None else 'fee: %d swartz'%fee
else:
tx_hash = tx_item['txid']
conf = tx_item['confirmations']
Expand All @@ -155,7 +155,7 @@ def get_card(self, tx_item): #tx_hash, tx_mined_status, value, balance):
icon = "atlas://electrum_nmc/electrum/gui/kivy/theming/light/" + TX_ICONS[status]
message = tx_item['label'] or tx_hash
fee = tx_item['fee_sat']
fee_text = '' if fee is None else 'fee: %d sat'%fee
fee_text = '' if fee is None else 'fee: %d swartz'%fee
ri = {}
ri['screen'] = self
ri['key'] = key
Expand Down
6 changes: 3 additions & 3 deletions electrum_nmc/electrum/gui/qt/channel_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ def __init__(self, window: 'ElectrumWindow', chan_id: bytes):
form_layout.addRow(_('Funding Outpoint:'), LinkedLabel(funding_label_text, self.show_tx))
form_layout.addRow(_('Short Channel ID:'), SelectableLabel(format_short_channel_id(chan.short_channel_id)))
self.received_label = SelectableLabel()
form_layout.addRow(_('Received (mSAT):'), self.received_label)
form_layout.addRow(_('Received (mSWARTZ):'), self.received_label)
self.sent_label = SelectableLabel()
form_layout.addRow(_('Sent (mSAT):'), self.sent_label)
form_layout.addRow(_('Sent (mSWARTZ):'), self.sent_label)
self.htlc_minimum_msat = SelectableLabel(str(chan.config[REMOTE].htlc_minimum_msat))
form_layout.addRow(_('Minimum HTLC value accepted by peer (mSAT):'), self.htlc_minimum_msat)
form_layout.addRow(_('Minimum HTLC value accepted by peer (mSWARTZ):'), self.htlc_minimum_msat)
self.max_htlcs = SelectableLabel(str(chan.config[REMOTE].max_accepted_htlcs))
form_layout.addRow(_('Maximum number of concurrent HTLCs accepted by peer:'), self.max_htlcs)
self.max_htlc_value = SelectableLabel(self.window.format_amount_and_units(chan.config[REMOTE].max_htlc_value_in_flight_msat / 1000))
Expand Down
2 changes: 1 addition & 1 deletion electrum_nmc/electrum/gui/qt/settings_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def on_outrounding(x):
outrounding_cb.setToolTip(
_('Set the value of the change output so that it has similar precision to the other outputs.') + '\n' +
_('This might improve your privacy somewhat.') + '\n' +
_('If enabled, at most 100 satoshis might be lost due to this, per transaction.'))
_('If enabled, at most 100 swartz might be lost due to this, per transaction.'))
outrounding_cb.setChecked(enable_outrounding)
outrounding_cb.stateChanged.connect(on_outrounding)
tx_widgets.append((outrounding_cb, None))
Expand Down
2 changes: 1 addition & 1 deletion electrum_nmc/electrum/gui/qt/transaction_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ def is_send_feerate_frozen(self):
and (self.feerate_e.text() or self.feerate_e.hasFocus())

def set_feerounding_text(self, num_satoshis_added):
self.feerounding_text = (_('Additional {} satoshis are going to be added.')
self.feerounding_text = (_('Additional {} swartz are going to be added.')
.format(num_satoshis_added))

def get_fee_estimator(self):
Expand Down
4 changes: 2 additions & 2 deletions electrum_nmc/electrum/lnchannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ def _check_can_pay(self, amount_msat: int) -> None:
current_htlc_sum = (htlcsum(self.hm.htlcs_by_direction(LOCAL, SENT).values())
+ htlcsum(self.hm.htlcs_by_direction(LOCAL, RECEIVED).values()))
if current_htlc_sum + amount_msat > self.config[REMOTE].max_htlc_value_in_flight_msat:
raise PaymentFailure(f'HTLC value sum (sum of pending htlcs: {current_htlc_sum/1000} sat plus new htlc: {amount_msat/1000} sat) would exceed max allowed: {self.config[REMOTE].max_htlc_value_in_flight_msat/1000} sat')
raise PaymentFailure(f'HTLC value sum (sum of pending htlcs: {current_htlc_sum/1000} swartz plus new htlc: {amount_msat/1000} swartz) would exceed max allowed: {self.config[REMOTE].max_htlc_value_in_flight_msat/1000} swartz')
if amount_msat < self.config[REMOTE].htlc_minimum_msat:
raise PaymentFailure(f'HTLC value too small: {amount_msat} msat')
raise PaymentFailure(f'HTLC value too small: {amount_msat} mswartz')

def can_pay(self, amount_msat):
try:
Expand Down
8 changes: 4 additions & 4 deletions electrum_nmc/electrum/lnpeer.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,12 +535,12 @@ async def channel_establishment_flow(self, password: Optional[str], funding_tx:
raise Exception(f"Remote Lightning peer reports dust_limit_sat > reserve_sat which is a BOLT-02 protocol violation.")
htlc_min = int.from_bytes(payload['htlc_minimum_msat'], 'big')
if htlc_min > MAXIMUM_HTLC_MINIMUM_MSAT_ACCEPTED:
raise Exception(f"Remote Lightning peer reports htlc_minimum_msat={htlc_min} mSAT," +
f" which is above Electrums required maximum limit of that parameter ({MAXIMUM_HTLC_MINIMUM_MSAT_ACCEPTED} mSAT).")
raise Exception(f"Remote Lightning peer reports htlc_minimum_msat={htlc_min} mSWARTZ," +
f" which is above Electrums required maximum limit of that parameter ({MAXIMUM_HTLC_MINIMUM_MSAT_ACCEPTED} mSWARTZ).")
remote_max = int.from_bytes(payload['max_htlc_value_in_flight_msat'], 'big')
if remote_max < MINIMUM_MAX_HTLC_VALUE_IN_FLIGHT_ACCEPTED:
raise Exception(f"Remote Lightning peer reports max_htlc_value_in_flight_msat at only {remote_max} mSAT" +
f" which is below Electrums required minimum ({MINIMUM_MAX_HTLC_VALUE_IN_FLIGHT_ACCEPTED} mSAT).")
raise Exception(f"Remote Lightning peer reports max_htlc_value_in_flight_msat at only {remote_max} mSWARTZ" +
f" which is below Electrums required minimum ({MINIMUM_MAX_HTLC_VALUE_IN_FLIGHT_ACCEPTED} mSWARTZ).")
max_accepted_htlcs = int.from_bytes(payload["max_accepted_htlcs"], 'big')
if max_accepted_htlcs > 483:
raise Exception("Remote Lightning peer reports max_accepted_htlcs > 483, which is a BOLT-02 protocol violation.")
Expand Down
4 changes: 2 additions & 2 deletions electrum_nmc/electrum/lnworker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1304,8 +1304,8 @@ async def reestablish_peers_and_channels(self):
chan_feerate = chan.get_latest_feerate(LOCAL)
ratio = chan_feerate / self.current_feerate_per_kw()
if ratio < 0.5:
self.logger.warning(f"fee level for channel {bh2u(chan.channel_id)} is {chan_feerate} sat/kiloweight, "
f"current recommended feerate is {self.current_feerate_per_kw()} sat/kiloweight, consider force closing!")
self.logger.warning(f"fee level for channel {bh2u(chan.channel_id)} is {chan_feerate} swartz/kiloweight, "
f"current recommended feerate is {self.current_feerate_per_kw()} swartz/kiloweight, consider force closing!")
# reestablish
if not chan.should_try_to_reestablish_peer():
continue
Expand Down
4 changes: 2 additions & 2 deletions electrum_nmc/electrum/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ def sweep(privkeys, *, network: 'Network', config: 'SimpleConfig',
tx = PartialTransaction.from_io(inputs, outputs)
fee = config.estimate_fee(tx.estimated_size())
if total - fee < 0:
raise Exception(_('Not enough funds on address.') + '\nTotal: %d satoshis\nFee: %d'%(total, fee))
raise Exception(_('Not enough funds on address.') + '\nTotal: %d swartz\nFee: %d'%(total, fee))
if total - fee < dust_threshold(network):
raise Exception(_('Not enough funds on address.') + '\nTotal: %d satoshis\nFee: %d\nDust Threshold: %d'%(total, fee, dust_threshold(network)))
raise Exception(_('Not enough funds on address.') + '\nTotal: %d swartz\nFee: %d\nDust Threshold: %d'%(total, fee, dust_threshold(network)))

outputs = [PartialTxOutput(scriptpubkey=bfh(bitcoin.address_to_script(to_address)),
value=total - fee)]
Expand Down

0 comments on commit 8a4d8aa

Please sign in to comment.