specter-desktop/docs/extensions/nodes.md
k9ert de8f5af619
Feature: several things for Spectrum preparation (#1913)
* change Node persistence format

* Removing the Singleton

* mainly refactoring

* intermediate commit

* fix test

* Updated diagram

* fix tests

* removing simplejsons references

* fix tests

* remove update, tests working

* abstract Node

* refining Migration framework: run migrations until they suceed

* BrokenCoreConnectionException added to handle lost RPC + some minor error handling fixes

* clicking redirects to node config if there is no node connection

* AbstractNode

* BrokenCoreConnectionException added to handle lost RPC + some minor error handling fixes

* clicking redirects to node config if there is no node connection

* handling broken connection when there is no other error superseding (i.e. no wallets)

* Abstract Node improvements and issue fixing

* improving node_info handling

* fix test results, property device_manager in user, bcce in get_rpc in node, improved rpc property in node

* typos

* provide data_folders for extensions

* parametrizing include for node_info

* Remove initial_node_contribution refactoring welcome

* adding convenience methods

* extension data-storage

* Tests green

* Better failure resistence

* Enabling Node settings

* error handling

* adjust_view_model callback

* exception Handling

* Shielding core from extension flaws

* More consistent logging

* Refactoring wallets endpoints

* Make wallet_overview extendable

* butgifex and cleanup

* feedback by Manolis

* rename BusinessObject to PersistentObject

* fix Error-management and rollback information

* Nodes.md corrections

* frontend-aspects.md (small) corrections

* fix tests and address feedback and errormanagement

* fix tests, proper error-handling

* Fix test_util_reflection

* just some little addons to test_util_reflection

* fix cleanup_on_exit

* migration fix

* remove check, add redirect after saving node

* fix test (not that cool but what to do?)

* upgrade Flask as Flask-SQLAlchemy needs higher Flask version

* Revert "upgrade Flask as Flask-SQLAlchemy needs higher Flask version"

This reverts commit bf24120f89.

* update bug fixed + node manager added to node test

* cleanup external_node

Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-10-29 15:54:34 +02:00

1.7 KiB

Adding Nodes or NodeTypes

The whole programming-model is based on the Bitcoin-Core API. So we need Bitcoin Core nodes or elements nodes or at least something which behaves like that. So for the Spectrum Integration, we made extending the node possible. This is a short description of how that has been done and which extensionpoints might be helpfull here.

So to create your own Node, derive from AbstractNode:

from cryptoadvance.specter.node import AbstractNode

class MyNode(AbstractNode):
    # [...]
    @classmethod
    def from_json(cls, node_dict, *args, **kwargs):
      [...]

    def node_info_template(self):
      return "spectrum/components/spectrum_info.jinja"

That class will need its own fromJson method. Overwrite the node_info_template method to specify your own template for the info-page which comes up if you click on a fully configured and functional node in the upper left corner. In order to smuggle your node into existence, you could potentially use the callback_after_serverpy_init_app callback. Have a look how the spectrum-extension did it here. Alternatively, you could create your own frontend in your controller and maybe additionally adjust the WelcomeVm model class as described in the frontend section.

If the node_settings are clicked for that node, we also expect that you have a node_settings endpoint in your controller. Otherwise there will be errors. Something like:

@yourextension_endpoint.route("node/<node_alias>/", methods=["GET", "POST"])
@login_required
def node_settings(node_alias=None):
    [...]
    return render_template(...