diff --git a/rootfs/standard/usr/bin/mynode_gen_bitcoin_config.sh b/rootfs/standard/usr/bin/mynode_gen_bitcoin_config.sh index e91fb31d..a2ccb30b 100755 --- a/rootfs/standard/usr/bin/mynode_gen_bitcoin_config.sh +++ b/rootfs/standard/usr/bin/mynode_gen_bitcoin_config.sh @@ -61,6 +61,13 @@ else cat /usr/share/mynode/bitcoin_testnet.conf >> /mnt/hdd/mynode/bitcoin/bitcoin.conf fi + # Append BIP setting toggles + if [ -f /mnt/hdd/mynode/settings/.bip37_enabled ]; then + cat /usr/share/mynode/bitcoin_bip37.conf >> /mnt/hdd/mynode/bitcoin/bitcoin.conf + fi + if [ -f /mnt/hdd/mynode/settings/.bip157_enabled ]; then + cat /usr/share/mynode/bitcoin_bip157.conf >> /mnt/hdd/mynode/bitcoin/bitcoin.conf + fi if [ -f /mnt/hdd/mynode/settings/.bip158_enabled ]; then cat /usr/share/mynode/bitcoin_bip158.conf >> /mnt/hdd/mynode/bitcoin/bitcoin.conf fi diff --git a/rootfs/standard/usr/share/mynode/bitcoin.conf b/rootfs/standard/usr/share/mynode/bitcoin.conf index 9a117ed3..b98d22a0 100644 --- a/rootfs/standard/usr/share/mynode/bitcoin.conf +++ b/rootfs/standard/usr/share/mynode/bitcoin.conf @@ -37,7 +37,7 @@ whitelist=download@10.0.0.0/8 whitelist=download@172.16.0.0/12 whitelist=download@192.168.0.0/16 -# Enable Bloom filters +# Enable Bloom filters (local network) whitelist=bloomfilter@127.0.0.1 whitelist=bloomfilter@10.0.0.0/8 whitelist=bloomfilter@172.16.0.0/12 diff --git a/rootfs/standard/usr/share/mynode/bitcoin_bip157.conf b/rootfs/standard/usr/share/mynode/bitcoin_bip157.conf new file mode 100644 index 00000000..4704a28c --- /dev/null +++ b/rootfs/standard/usr/share/mynode/bitcoin_bip157.conf @@ -0,0 +1,3 @@ + +# Enable serving blockfilters (BIP 157) +peerblockfilters=1 diff --git a/rootfs/standard/usr/share/mynode/bitcoin_bip37.conf b/rootfs/standard/usr/share/mynode/bitcoin_bip37.conf new file mode 100644 index 00000000..53369930 --- /dev/null +++ b/rootfs/standard/usr/share/mynode/bitcoin_bip37.conf @@ -0,0 +1,3 @@ + +# Enable serving bloom filters (BIP 37) +peerbloomfilters=1 diff --git a/rootfs/standard/var/www/mynode/bitcoin.py b/rootfs/standard/var/www/mynode/bitcoin.py index 046dce17..b1404680 100644 --- a/rootfs/standard/var/www/mynode/bitcoin.py +++ b/rootfs/standard/var/www/mynode/bitcoin.py @@ -117,6 +117,8 @@ def bitcoin_status_page(): "wallets": walletdata, "bitcoin_whitepaper_exists": bitcoin_whitepaper_exists, "version": version, + "bip37_enabled": is_bip37_enabled(), + "bip157_enabled": is_bip157_enabled(), "bip158_enabled": is_bip158_enabled(), "ui_settings": read_ui_settings() } @@ -221,6 +223,46 @@ def runcmd_page(): response = runcmd(request.form['cmd']) return response +@mynode_bitcoin.route("/bitcoin/toggle_bip37") +def bitcoin_toggle_bip37(): + if request.args.get("enabled") and request.args.get("enabled") == "1": + enable_bip37() + else: + disable_bip37() + + # Trigger reboot + t = Timer(1.0, reboot_device) + t.start() + + # Wait until device is restarted + templateData = { + "title": "myNode Reboot", + "header_text": "Restarting", + "subheader_text": "This will take several minutes...", + "ui_settings": read_ui_settings() + } + return render_template('reboot.html', **templateData) + +@mynode_bitcoin.route("/bitcoin/toggle_bip157") +def bitcoin_toggle_bip157(): + if request.args.get("enabled") and request.args.get("enabled") == "1": + enable_bip157() + else: + disable_bip157() + + # Trigger reboot + t = Timer(1.0, reboot_device) + t.start() + + # Wait until device is restarted + templateData = { + "title": "myNode Reboot", + "header_text": "Restarting", + "subheader_text": "This will take several minutes...", + "ui_settings": read_ui_settings() + } + return render_template('reboot.html', **templateData) + @mynode_bitcoin.route("/bitcoin/toggle_bip158") def bitcoin_toggle_bip158(): check_logged_in() diff --git a/rootfs/standard/var/www/mynode/bitcoin_info.py b/rootfs/standard/var/www/mynode/bitcoin_info.py index 17e20b1a..3defebcd 100644 --- a/rootfs/standard/var/www/mynode/bitcoin_info.py +++ b/rootfs/standard/var/www/mynode/bitcoin_info.py @@ -248,13 +248,29 @@ def restart_bitcoin(): t = Timer(1.0, restart_bitcoin_actual) t.start() +def is_bip37_enabled(): + if os.path.isfile("/mnt/hdd/mynode/settings/.bip37_enabled"): + return True + return False +def enable_bip37(): + touch("/mnt/hdd/mynode/settings/.bip37_enabled") +def disable_bip37(): + delete_file("/mnt/hdd/mynode/settings/.bip37_enabled") + +def is_bip157_enabled(): + if os.path.isfile("/mnt/hdd/mynode/settings/.bip157_enabled"): + return True + return False +def enable_bip157(): + touch("/mnt/hdd/mynode/settings/.bip157_enabled") +def disable_bip157(): + delete_file("/mnt/hdd/mynode/settings/.bip157_enabled") + def is_bip158_enabled(): if os.path.isfile("/mnt/hdd/mynode/settings/.bip158_enabled"): return True return False - def enable_bip158(): touch("/mnt/hdd/mynode/settings/.bip158_enabled") - def disable_bip158(): delete_file("/mnt/hdd/mynode/settings/.bip158_enabled") \ No newline at end of file diff --git a/rootfs/standard/var/www/mynode/templates/bitcoin.html b/rootfs/standard/var/www/mynode/templates/bitcoin.html index 27ef00c3..0b881510 100644 --- a/rootfs/standard/var/www/mynode/templates/bitcoin.html +++ b/rootfs/standard/var/www/mynode/templates/bitcoin.html @@ -24,6 +24,49 @@ $("#copy_rpc_password").show(); } + $('#bip37_checkbox').change(function () { + $("#bip37_save").show(); + }); + $("#bip37_save").on("click", function() { + enabled=$('#bip37_checkbox').is(":checked"); + if (enabled) + { + openConfirmDialog("confirm-dialog", + "Enable Peer Bloom Filters (BIP 37)", + "Are you sure you want to enable bloom filters?

\ + Enabling peer bloom filters may have negative consequences. See https://github.com/bitcoin/bitcoin/issues/9540.", + function(){ + $( this ).dialog( "close" ); + window.location.href='/bitcoin/toggle_bip37?enabled=1'; + }); + } + else + { + window.location.href='/bitcoin/toggle_bip37?enabled=0'; + } + }); + + $('#bip157_checkbox').change(function () { + $("#bip157_save").show(); + }); + $("#bip157_save").on("click", function() { + enabled=$('#bip157_checkbox').is(":checked"); + if (enabled) + { + openConfirmDialog("confirm-dialog", + "Enable Peer Block Filters (BIP 157)", + "Are you sure you want to enable peer block filters?", + function(){ + $( this ).dialog( "close" ); + window.location.href='/bitcoin/toggle_bip157?enabled=1'; + }); + } + else + { + window.location.href='/bitcoin/toggle_bip157?enabled=0'; + } + }); + $('#bip158_checkbox').change(function () { $("#bip158_save").show(); }); @@ -32,12 +75,11 @@ if (enabled) { openConfirmDialog("confirm-dialog", - "Enable block filters (BIP 158)", + "Enable Block Filters (BIP 158)", "Are you sure you want to enable block filters?\ This will take some time to download and occupy about 5GB of storage.", function(){ $( this ).dialog( "close" ); - console.log("Inside callback of enabling BIP 158!!") window.location.href='/bitcoin/toggle_bip158?enabled=1'; }); } @@ -140,6 +182,26 @@ Whitepaper download + + Peer Bloom Filters (BIP 37) + + + + + + + Peer Block Filters (BIP 157) + + + + + Block Filters (BIP 158)