Giter VIP home page Giter VIP logo

nodeguard's Introduction

NodeGuard

GitHub release (release name instead of tag name) GitHub Unit tests Docker image build

NodeGuard is an open-source technology stack developed to simplify treasury operations for lightning nodes, focusing on both Security and UX. It enables the management of lightning treasury funds, adhering to the principles of separation of duties and the principle of least privilege. These principles form the core of NodeGuard's functionality, aiming to eliminate the need for an internal node hot wallet and to separate key management from the actual node operators. At present, NodeGuard supports only LND. For a more detailed understanding, please watch the video below.

Watch the video

Current features of NodeGuard are the following:

  • Asynchronous channel funding leveraging cold multisig wallets and hot wallets
  • Multisig wallet creation and import (BIP39), only segwit for now
  • Liquidity automation by settings rules in tandem with NodeGuard liquidator
  • Optional remote signing through NodeGuard Remote Signer functions for channel funding transactions, separating the NodeGuard keys from the actual software
  • Automatic sweeping of funds in lightning nodes to avoid having funds on the node hot wallets
  • Channel management
  • Channel creation interception with returning address to multisig wallets to avoid having funds on hot wallets
  • Support for hardware wallets to sign the PSBTs for channel funding transactions
  • Minimalistic in-browser wallet with NodeGuard Companion to ease signing of transactions and wallet creation
  • In-browser notification systems for channel approvals
  • Two-factor authentication

Contributing

Check Contributing.md

Roadmap

TODO

Dev environment quickstart

  1. Run polar regtest network with Polar, import devnetwork.zip (in the root of this repo) and start it
  2. Open FundsManager.sln with Visual Studio or your favourite IDE/EDITOR
  3. Set startup project to docker-compose
  4. Run

##Requirements

  • VS Code / Visual Studio
  • Docker desktop
  • Dotnet SDK 6+
  • Dotnet-ef global tool
  • Polar lightning
  • AWS Lambda function + AWS credentials for the Remote FundsManagerSigner, check this

Migrations

This project uses NPGSQL(postgres) database provider for EfCore (ORM). You need to install dotnet-ef global tool

dotnet tool install -g dotnet-ef
  • To update the database (create it & apply migrations) you shall do:
    cd src && dotnet ef database update
    
  • To create a new migration
    cd src && dotnet ef migrations add changeInEntityExampleAddedNewField // This is an example
    
  • To remove a non-applied migration (once a migration is applied, you have to drop the database to remove it)
    cd src && dotnet ef migrations remove
    

Developing

Visual Studio

Launch the FundsManager Docker VS task Launch The FundsManager VS task

Rider/IntelliJ

Import and start devnetwork.polar.zip in polar Launch the FundsManager Docker NOVS task Launch The FundsManager NOVS task

Visual Studio Code

Import and start devnetwork.polar.zip in polar Start docker compose from terminal (see below) Then, start the vscode launch configuration Launch against running docker-compose env (DEV) Navigate to http://localhost:38080/

Starting docker compose from terminal

Start all the dependencies in docker-compose by running:

cd docker
docker-compose -f docker-compose.dev-novs.yml up -d

Security

Check Security.md

LICENSE

This project is licensed under AGPLv3.0. Check LICENSE for more information.

nodeguard's People

Contributors

aleksksoftware avatar cvicenti avatar daliclovr avatar dependabot[bot] avatar dmitri-clovr avatar gcaracuel avatar itek09 avatar jossec101 avatar markettes avatar rodrifs avatar tamaragmartin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nodeguard's Issues

Channel creation for hot wallets

User story

As a Node Manager

I want that the hot wallets work with channel creation functionality

So that the system can automatically use the funds in them to perform channel openings

Benefits

The Node managers will be able to use the hot wallets to quickly open channels without the need of an approval of Finance managers.

Acceptance criteria

  • channel creation operation should work with hot wallets
  • There should be a confirmation message to the user saying “You selected a hot wallet. This means that the system will automatically use the funds in it without the need of manual approval.

NFRs

  • PSBT should still be used
  • we should build the PSBT with SIGHASH_ALL

Channel view validation

What’s wrong

  • You can save the channel settings without any info

Expected outcome

  • Validation rules should kick in and the rule shouldn’t be saved

Steps to reproduce

  1. Go to NodeGuard
  2. Log in (as a node admin)
  3. Go to channels
  4. Select a channel (click on it)
  5. Enable liquidity management
  6. Enter all the fields correctly
  7. Click Save
  8. Click Manage
  9. Erase all fields
  10. Click Save

Environment

  • All

Impact

  • Users can save rules without values

Add new internal keys for new multisig wallets

Add new internal keys for new multisig wallets

Overview

Problem statement

Right now we cannot have access to already setup multisig wallets due to the work introduced by hot wallets, still, this work is needed for the future to support infinite amount of multisig wallets by the same human keys

Proposed work

  • Instead of replacing the old signing internal key, we should create a new internal key for each wallet. This way the old wallets will keep working and the new ones will start from a subderivation path
  • Each key will have it’s xpub that corresponds with the subderivation path

Success criteria

The criteria that must be met in order to consider this project a success.

  • Being able to open channels with old multisig wallets while also using new hot wallets and multisig wallet derivation format (limited without the chrome extension)

New readme, contibuting..

We need a better readme and contributing files

  • Proper naming (NodeGuard)
  • Introduction of the software
  • Github badges (?)

gRPC API

NodeGuard needs a gRPC API for specific uses cases like:

  • Getting information from Liquidity Rules associated to a node and its channels
  • Generating wallet addresses for actions such as submarine swaps.
  • Other: TBD

Modals do not clear data whenever you close them

This happens with most modals, but I'll describe steps for a specific one.

Steps to reproduce:

  • Go to "Channel Requests" page
  • Click on "New" button, it will open a modal
  • Fill out some fields
  • Press on "Cancel" or on "Save" (if you filled the form completely and correctly)
  • After the modal disappeared, click on "New" again
  • Some data from the previous opening is already filled

Rework closing of channels

We need to find a way to extract information from the lightning network in order to know when a channel is closed remotely. The challenge is not only to detect these type of occurrences but to find a way of making it consistent with our data model so we extract and store historical information once it happens

If reliable, this experimental feature could be used to get push notifications to avoid the use of polling.
https://api.lightning.community/#subscribechannelevents

It will require some additional services to implement this feature

Comments:

  • @Jossec101: bump, this is important now that we manage liquidity rules, we should also enhance the closing of channels, right now if the channel was closed outside NG wont even’t realize, we could do in a few ways like polling state or subscribe to channel events endpoint when clicking in close if it no longer exists just dismantle it, polling/subscribe might be better so we can close channels and manager rules
  • @Jossec101: Additionally we should differentiate at db level from channels initiated by us or not

A finance manager can select wallets that dont belong to them

A finance manager can create (but not approve) withdrawals, channels, and also set a node with a return address to a different wallet that the one they own. It would be nice to not display wallets that none of its keys belong to the current logged finance manager.

Allow hot wallet creation

User story

As a Finance Manager

I want to be able to create a hot wallet in NodeGuard

So that the system can automatically use the funds in it to perform automatic swaps

Benefits

The hot wallet in NodeGuard will allow our system to perform automatic swaps (and reverse swaps) without the need of a Finance manager manually approving these transactions.

Acceptance criteria

  • checkbox for 'hot wallet' when creating a wallet

Add incremental backoff to retries of jobs

Whenever a Job fails, it´s retried at an interval. That interval is currently 10 seconds and 20 retries.
We want to implement a list of backoff delays so the first retry is at 1 minutes, then 5 minutes, and then doubles. And we would like to be configurable.

Acceptance Criteria:

  • The Job accepts an array of ints which will be the backoffs
  • Whenever the job fails, it will trigger the job again following the number in the array
  • When there are no more numbers in the array, the job is unscheduled

Quartz Job Serialization error

When opening or clossing a channel, and making a withdrawal, quartz job fails because it cannot serialize recursive objects.

Context problem when closing two channels at the same time

Whenever you close two channels at the same time, you get this error in the terminal

InvalidOperationException: The instance of entity type 'Channel' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked

Add AGPL Licensing

We need to add AGPL headers to all the files and the license file also.

Withdrawals for hot wallets

Context

Please add some context if necessary

User story

As a Node Manager

I want that the hot wallets work with withdrawals

So that I can move money from one wallet to another

Benefits

The Node managers will be able to use the hot wallets to quickly move funds from one wallet to another without the need of an approval from the Finance managers

Acceptance criteria

  • withdrawal operation should work with hot wallets
  • There should be a confirmation message to the user saying “You selected a hot wallet. This means that the transaction will be processed without the need of manual approval.

NFRs

  • PSBT should still be used
  • we should build the PSBT with SIGHASH_ALL

Setup in production overhaul

Right now, in production mode, NodeGuard will generate its internal wallet automatically and print the wallet seedphrase in the console, but there is a security/privacy issue. We will implement a prompt on start to fix this.

When NodeGuard is opened for the first time (i.e. No superadmin users), we allow to set a new superadmin / password, then if not internal wallets are in the db, the same UI will generate one and display it on the screen for the user to store it safely.

Notification service crashing UI

{"Timestamp":"2023-04-13T09:44:46.6734848+00:00","Level":"Warning","MessageTemplate":"Unhandled exception rendering component: {Message}","Exception":"System.NullReferenceException: Object reference not set to an instance of an object.\n at FundsManager.Services.NotificationService.SendNotification(String message, List`1 recipientList, String returnUrl) in /src/src/Services/NotificationService.cs:line 75\n at FundsManager.Services.NotificationService.NotifyRequestSigners(Int32 walletId, String sourcePage) in /src/src/Services/NotificationService.cs:line 61\n at FundsManager.Services.NotificationService.NotifyRequestSigners(Int32 walletId, String sourcePage) in /src/src/Services/NotificationService.cs:line 61\n at FundsManager.Data.Repositories.ChannelOperationRequestRepository.AddAsync(ChannelOperationRequest type) in /src/src/Data/Repositories/ChannelOperationRequestRepository.cs:line 119\n at FundsManager.Data.Repositories.ChannelOperationRequestRepository.AddAsync(ChannelOperationRequest type) in /src/src/Data/Repositories/ChannelOperationRequestRepository.cs:line 121\n at FundsManager.Data.Repositories.ChannelRepository.SafeRemove(Channel type, Boolean forceClose) in /src/src/Data/Repositories/ChannelRepository.cs:line 144\n at FundsManager.Data.Repositories.ChannelRepository.SafeRemove(Channel type, Boolean forceClose) in /src/src/Data/Repositories/ChannelRepository.cs:line 176\n at FundsManager.Pages.Channels.ShowConfirmedClose(Channel channel, Boolean forceClose) in /src/src/Pages/Channels.razor:line 363\n at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)\n at Blazorise.DropdownItem.ClickHandler()\n at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)\n at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)","Properties":{"Message":"Object reference not set to an instance of an object.","EventId":{"Id":100,"Name":"ExceptionRenderingComponent"},"SourceContext":"Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer","TransportConnectionId":"FLH2JUgBFdeo-KX-1CrSQg","RequestId":"0HMPR8QCK6JK7:00000002","RequestPath":"/_blazor","ConnectionId":"0HMPR8QCK6JK7","dd.trace_id":"14129391728701447723","dd.span_id":"6131940780546872198"}}

CI/CD Tweak

CI/CD need to be tweak for building the staging and prod versions of the remote signer and the nodeguard project.

Add a prefix to remote signer environment variable

We used to add the master fingerprint of a wallet to know which seedphrase needs to be used by the remote signer lambda function, but if the fingerprint starts with a number, AWS wont allow it, so we need to retrieve the env-var in the code like MF_{Master Fingerprint}

Fix role based accesses

Right now the access control is broken and nodemanagers are not able to create channels, finance managers have access to create and close channels. We should fix that so every role has access to their own domain:

  • Admins: Users and nodes
  • Finance Managers: Money
  • NodeManagers: Channels

Acceptance Criteria:

  • Admin can add/remove nodes
  • Admin can and/remove users
  • Admin can’t create/close channels
  • Admin can’t create/approve withdrawal requests
  • Admin can’t create/finalize wallets

  • Node Manager can create channel requests/close channels
  • Node Manager can’t approve channels
  • Node Manager can’t create wallets
  • Node Manager can’t create/approve withdrawals
  • Node Manager can’t create users
  • Node Manager can’t create nodes

  • Finance Manager can create/approve withdrawals
  • Finance Manager can create/finalize wallets
  • Finance Manager can approve channels
  • Finance Manager can’t open/close channels
  • Finance Manager can’t create users
  • Finance Manager can’t create nodes

Entity model changes

Entity model changes for features such as:

  • Single-sig & hot wallets
  • Liquidity rule engine
  • Automated withdrawals
  • Metadata for wallets such as OwnerId

Allow disabling autosweep on nodes

Problem statement

Whenever we want to test sweeps on nodes, and we put money on them, the autosweep feature will take the money back to the wallets.

Proposed work

It would be useful to have a way to optionally disable autosweep on nodes.

Success criteria

  • A checkbox in the nodes view to disable autosweep
  • Autosweep is on by default

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.