From eb0a738d6759698ba5d4c670db6606dfa87c4a66 Mon Sep 17 00:00:00 2001 From: chris-belcher Date: Fri, 9 Apr 2021 01:37:09 +0100 Subject: [PATCH] Add interest rate option to config file --- jmclient/jmclient/__init__.py | 2 +- jmclient/jmclient/configure.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/jmclient/jmclient/__init__.py b/jmclient/jmclient/__init__.py index df33de0..741ab7c 100644 --- a/jmclient/jmclient/__init__.py +++ b/jmclient/jmclient/__init__.py @@ -24,7 +24,7 @@ from .configure import (load_test_config, process_shutdown, load_program_config, jm_single, get_network, update_persist_config, validate_address, is_burn_destination, get_irc_mchannels, get_blockchain_interface_instance, set_config, is_segwit_mode, - is_native_segwit_mode, JMPluginService) + is_native_segwit_mode, JMPluginService, get_interest_rate) from .blockchaininterface import (BlockchainInterface, RegtestBitcoinCoreInterface, BitcoinCoreInterface) from .snicker_receiver import SNICKERError, SNICKERReceiver diff --git a/jmclient/jmclient/configure.py b/jmclient/jmclient/configure.py index 8caa7c2..900de39 100644 --- a/jmclient/jmclient/configure.py +++ b/jmclient/jmclient/configure.py @@ -88,6 +88,8 @@ required_options = {'BLOCKCHAIN': ['blockchain_source', 'network'], 'POLICY': ['absurd_fee_per_kb', 'taker_utxo_retries', 'taker_utxo_age', 'taker_utxo_amtpercent']} +_DEFAULT_INTEREST_RATE = "0.015" + defaultconfig = \ """ [DAEMON] @@ -291,6 +293,14 @@ minimum_makers = 4 # whatever the value of it, and this is set with the value -1. max_sats_freeze_reuse = -1 +# Interest rate used when calculating the value of fidelity bonds created +# by locking bitcoins in timelocked addresses +# See also: +# https://gist.github.com/chris-belcher/87ebbcbb639686057a389acb9ab3e25b#determining-interest-rate-r +# Set as a real number, i.e. 1 = 100% and 0.01 = 1% +interest_rate = """ + _DEFAULT_INTEREST_RATE + """ + + ############################## #THE FOLLOWING SETTINGS ARE REQUIRED TO DEFEND AGAINST SNOOPERS. #DON'T ALTER THEM UNLESS YOU UNDERSTAND THE IMPLICATIONS. @@ -538,6 +548,10 @@ _BURN_DESTINATION = "BURN" def is_burn_destination(destination): return destination == _BURN_DESTINATION +def get_interest_rate(): + return float(global_singleton.config.get('POLICY', 'interest_rate', + fallback=_DEFAULT_INTEREST_RATE)) + def remove_unwanted_default_settings(config): for section in config.sections(): if section.startswith('MESSAGING:'):