Difference between revisions of "Backup"

From lightningwiki.net
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{ALERT|Reliable backups are being worked on at the moment}}
Recent Lightning implementations have made backups easier. It is important to understand the difference between wallet and channel funds.


Making backups is not easy. You can backup your [[Keys|key]], but to recover a disk failure (for example), you still need the channel state.
You can easily get your wallet balance back by recovering your seed. Getting your channel funds back is harder. If you would have an old version of your channel, you broadcast an old state, the counterparty (peer) detects [[Fraud]] and takes your funds.


The problem is that if you announce an old channel state (after you recovered a backup), this is detected as [[Fraud]] and you might lose your funds.
That is why you need to backup your channel state too.


= Poor mans solution=
= Backup wallet funds =
Probably just take your wallet-file... See [https://github.com/lightningnetwork/lnd/issues/732 github for more info].
Use the wallet seed. You get this at installation. It can not be recovered ([[Lnd]]).
 
= Hardware =
If you’re putting a lot of money on your Lightning routing node, please use a reliable hard drives (with mirroring).
 
= Data Loss Protection =
[[Data loss protection]]


= Channel information =
= Channel information =
The second important thing to backup is channel states.
== LND ==
== LND ==
{{NOTE|On 2019-04-02 Static Channel Backup was merged into LND Master}}
{{NOTE|Static Channel backups are suported since [[Lnd]] version 6}}
Once you start a channel, take a [https://github.com/lightningnetwork/lnd/pull/2313 static channel backup]. This has to be done only once.
 
Once you start a channel, take a [https://github.com/lightningnetwork/lnd/pull/2313 static channel backup]. This has to be done only once. Or take a backup of the channels.backup file in the same location that we store all the other files. Users will at any time be able to safely copy and backup this file


After that, if your node dies, you can recover using the seed + the static-channel-backup and retrieve both your onchain and channel balance!
After that, if your node dies, you can recover using the seed + the static-channel-backup and retrieve both your onchain and channel balance!
See [https://github.com/lightningnetwork/lnd/blob/master/docs/recovery.md recovery] docs by lnd.
=== Backup channelbackup using inotify (watch changes) ===
[https://gist.github.com/alexbosworth/2c5e185aedbdac45a03655b709e255a3 Post by Alex Bosworth]


=== Example Static channel backup commands ===
=== Example Static channel backup commands ===
Line 128: Line 129:
= Commitment revocation private key =
= Commitment revocation private key =
Every commitment transaction has a unique commitment revocation private-key value that allows the other peer to spend all outputs immediately: revealing this key is how old commitment transactions are revoked. To support revocation, each output of the commitment transaction refers to the commitment revocation public key.
Every commitment transaction has a unique commitment revocation private-key value that allows the other peer to spend all outputs immediately: revealing this key is how old commitment transactions are revoked. To support revocation, each output of the commitment transaction refers to the commitment revocation public key.
= Hardware =
If you’re putting a lot of money on your Lightning routing node, please use a reliable hard drives (with mirroring).
= Data Loss Protection =
[[Data loss protection]]

Latest revision as of 07:14, 18 April 2019

Recent Lightning implementations have made backups easier. It is important to understand the difference between wallet and channel funds.

You can easily get your wallet balance back by recovering your seed. Getting your channel funds back is harder. If you would have an old version of your channel, you broadcast an old state, the counterparty (peer) detects Fraud and takes your funds.

That is why you need to backup your channel state too.

Backup wallet funds

Use the wallet seed. You get this at installation. It can not be recovered (Lnd).

Channel information

The second important thing to backup is channel states.

LND

Error creating thumbnail: File missing
Side note:
Static Channel backups are suported since Lnd version 6

Once you start a channel, take a static channel backup. This has to be done only once. Or take a backup of the channels.backup file in the same location that we store all the other files. Users will at any time be able to safely copy and backup this file

After that, if your node dies, you can recover using the seed + the static-channel-backup and retrieve both your onchain and channel balance!

See recovery docs by lnd.

Backup channelbackup using inotify (watch changes)

Post by Alex Bosworth

Example Static channel backup commands

>tlncli exportchanbackup --all

{
        "chan_points": [
                "a173ca220bb644b4be03e44285b1541382c85fc3de1f9f1e0f317892c55cfd29:0",
                "30ad897d900d837728e09bdb2f4859354207599522fab72d20582f5a713f983d:0",
                "2f86e0049c4488b2cad1a6cffffc56ffd56ba5e639b79994baed64e87e6849f2:0"
        ],
        "multi_chan_backup": "0f955a78d0df14db44769c946a537a9c81174a097e3***6ecf7f4ab1afaa0e06"
}

>tlncli verifychanbackup --multi_backup 0f955a78d0df14db44769c946a537a9c81174a097e3***6ecf7f4ab1afaa0e06

{
    "singles_valid": true,
    "multi_valid": true
}

>tlncli restorechanbackup --multi_backup 0f955a78d0df14db44769c946a537a9c81174a097e3***6ecf7f4ab1afaa0e06

>tlncli pendingchannels

{
    "total_limbo_balance": "0",
    "pending_open_channels": [
    ],
    "pending_closing_channels": [
    ],
    "pending_force_closing_channels": [
    ],
    "waiting_close_channels": [
        {
            "channel": {
                "remote_node_pub": "031673e26fa50f5e1598caff98b8be466998486bd876751b7824ad8def3aa7e76d",
                "channel_point": "30ad897d900d837728e09bdb2f4859354207599522fab72d20582f5a713f983d:0",
                "capacity": "500000",
                "local_balance": "0",
                "remote_balance": "0"
            },
            "limbo_balance": "0"
        },
        {
            "channel": {
                "remote_node_pub": "03b8e1dfc4bf42adec135350dd51784e5b55055f5647d031771bdf439f5de87b88",
                "channel_point": "2f86e0049c4488b2cad1a6cffffc56ffd56ba5e639b79994baed64e87e6849f2:0",
                "capacity": "700000",
                "local_balance": "0",
                "remote_balance": "0"
            },
            "limbo_balance": "0"
        },
        {
            "channel": {
                "remote_node_pub": "03ecd95e86e780ae82139c3217b527073622d28c4d8a53b76142a7b7b1d1e36975",
                "channel_point": "a173ca220bb644b4be03e44285b1541382c85fc3de1f9f1e0f317892c55cfd29:0",
                "capacity": "600000",
                "local_balance": "0",
                "remote_balance": "0"
            },
            "limbo_balance": "0"
        }
    ]
}
>tlncli walletbalance

{
    "total_balance": "108199538",
    "confirmed_balance": "108199538",
    "unconfirmed_balance": "0"
}
>tlncli pendingchannels

{
    "total_limbo_balance": "0",
    "pending_open_channels": [
    ],
    "pending_closing_channels": [
    ],
    "pending_force_closing_channels": [
    ],
    "waiting_close_channels": [
    ]
}
>tlncli walletbalance

{
    "total_balance": "109818740",
    "confirmed_balance": "109818740",
    "unconfirmed_balance": "0"
}
>tlncli listunspent --min_confs 0

{
        "utxos": [
                {
                        "address_type": 0,
                        "address": "tb1qxx25r275r08z3ygagg4cawxp60gj8ptynkvnwc",
                        "amount_sat": 1619202,
                        "pk_script": "0014319541abd41bce28911d422b8eb8c1d3d1238564",
                        "outpoint": "d7f037b2757e27ab16018c03c811f0f494fdad2dc029fc0810b108e103725da5:0",
                        "confirmations": 13
                },

Commitment revocation private key

Every commitment transaction has a unique commitment revocation private-key value that allows the other peer to spend all outputs immediately: revealing this key is how old commitment transactions are revoked. To support revocation, each output of the commitment transaction refers to the commitment revocation public key.

Hardware

If you’re putting a lot of money on your Lightning routing node, please use a reliable hard drives (with mirroring).

Data Loss Protection

Data loss protection