github.com/mit-dci/lit@v0.0.0-20221102210550-8c3d3b49f2ce/WALKTHROUGH.md (about)

     1  2017-01-09 Lit sortof works on testnet.  There are known bugs / omissions / errors, and also unknown ones!  Reporting bugs / crashes is helpful, and fixing them is even more helpful.
     2  
     3  2018-06-12 Updated to use new addresses and command formats.  Lit also works much better than it did in the above note.
     4  
     5  ## Lit 0.0 Walkthrough
     6  
     7  This walkthrough is to set people up who want to send payments over channels on a test network. If you haven't already, make sure to go to the [README](./README.md) for setup instructions.
     8  
     9  ### Step 1: Files in place
    10  
    11  Make sure you have built both the `lit` and `lit-af` (in `cmd/lit-af`) packages with `go build`
    12  
    13  If you have a full node, like bitcoind or btcd, start running that as well, either on testnet3 or regtest mode.
    14  
    15  For this walkthrough, you will run 2 lit nodes and have them make channels.  It's more fun for the nodes to be on different computers controlled by different people, but you can run them on the same machine for testing.  You can also have the full node running on that machine as well.
    16  
    17  In this example, there are 2 computers.  Most things should work the same with 1 computer; just make sure to have 2 different folders for the lit nodes.
    18  
    19  Set up two folders (i.e. anode and bnode) and copy both the `lit` and `lit-af` executables you built into both folders.
    20  
    21  Here is a sample for Linux users who have not already built the packages
    22  
    23  #### Alice's setup
    24  
    25  ```
    26  alice@pi2:~$ mkdir anode
    27  alice@pi2:~$ cd gofolder/src/github.com/mit-dci/lit
    28  alice@pi2:~/gofolder/src/github.com/mit-dci/lit$ go build
    29  alice@pi2:~/gofolder/src/github.com/mit-dci/lit$ cp lit ~/anode/
    30  alice@pi2:~/gofolder/src/github.com/mit-dci/lit$ cd cmd/lit-af
    31  alice@pi2:~/gofolder/src/github.com/mit-dci/lit/cmd/lit-af$ go build
    32  alice@pi2:~/gofolder/src/github.com/mit-dci/lit/cmd/lit-af$ cp lit-af ~/anode/
    33  alice@pi2:~/gofolder/src/github.com/mit-dci/lit/cmd/lit-af$ cd ~/anode/
    34  alice@pi2:~/anode$
    35  ```
    36  
    37  ### Step 2: Run lit and sync up
    38  
    39  Alice starts running lit (with `./lit --tn3 fullnode.net`) and syncs up to the blockchain.  The lit node will print lots of stuff on the screen, but can't be controlled from here.
    40  
    41  Alice connects to her full node, fullnode.net.  By default this is on testnet3, using port 18333.
    42  
    43  ```
    44  alice@pi2:~/anode$ ./lit --tn3=fullnode.net -v
    45  lit node v0.1
    46  -h for list of options.
    47  No file testkey.hex, generating.
    48  passphrase:
    49  repeat passphrase:
    50  
    51  WARNING!! Key file not encrypted!!
    52  ```
    53  
    54  Here Alice can type a passphrase to secure the wallet the newborn lit node is generating.  But she just pressed enter twice, because this is testnet.  Even though it's testnet, lit will show warnings about not using a passphrase.
    55  
    56  Now in another window, alice connects to the lit node over RPC using `./lit-af`
    57  
    58  ```
    59  alice@pi2:~/anode$ ./lit-af
    60  lit-af# ls -a
    61  entered command: ls -a
    62          Peers:
    63  1 127.0.0.1:49958 (ln1wj3csaf6p6kgvj6zre6zqta7lnjms9zndkwc8d)
    64          Listening Ports:
    65  Listening for connections on port(s) [[::]:2448] with key ln1akupazfterdadrywclht0s8kgvt3r3jga0lyez
    66          Addresses:
    67  1 tb1qf77l4ja2kq6na0ffmekph6qv22puufqr5aatg0 (mnnbGE9dxHpNFuzBrTWUk5PZ9272JF2bkK)
    68          Balances:
    69  Type: 1 Sync Height: 1481792    FeeRate: 80     Utxo: 0 WitConf: 0 Channel: 0
    70  
    71  ```
    72  
    73  Buy default the lit-af utility use ~/.lit directory for litHomeDir and 2448 for autoListenPort.
    74  You can change this running:
    75  
    76  ```
    77  alice@pi2:~/gofolder/src/github.com/mit-dci/lit/cmd/lit-af/lit-af --litHomeDir=/path/to_alice/lit1 --autoListenPort=2448
    78  ```
    79  
    80  
    81  ls -a shows how much money Alice has, which is none.  She can get some from a faucet. One such faucet you can find [here](https://testnet.manu.backend.hamburg/faucet).
    82  
    83  Bob can start a wallet in the same way; if Bob's node is running on the same computer, he'll have to run lit placing a lit.conf in to the ~/bnode folder:
    84  
    85  ```
    86  tn3=1
    87  rpchost=0.0.0.0
    88  rpcport=8002
    89  tracker=http://hubris.media.mit.edu:46580
    90  autoListenPort=2449
    91  autoReconnect=true
    92  autoReconnectInterval=5
    93  ```
    94  
    95  Then run lit as:
    96  
    97  ```
    98  alice@pi2:~/gofolder/src/github.com/mit-dci/lit/lit --dir=~/bnode
    99  ```
   100  
   101  Once Alice and Bob are both set up, they can connect to each other.
   102  
   103  If Bob is on the same computer he should run lit-af with the parameters:
   104  
   105  ```
   106  ./lit-af --litHomeDir=~/bnode --autoListenPort=2449
   107  ```
   108  
   109  
   110  ### Step 3: Connect
   111  
   112  Bob can connect to Alice using her node-ID:
   113  
   114  ```
   115  lit-af# con ln1akupazfterdadrywclht0s8kgvt3r3jga0lyez@:2448@pi2
   116  entered command: con ln1akupazfterdadrywclht0s8kgvt3r3jga0lyez@:2448@pi2
   117  connected to peer 1
   118  lit-af# say 1 Hi Alice!
   119  entered command: say 1 Hi Alice!
   120  ```
   121  
   122  Bob puts the pubkey@hostname for Alice and connects.  Then he says hi to Alice.
   123  
   124  ### Step 4: Sweep Funds
   125  
   126  Before Bob can make a channel, he needs to sweep his coins to make sure they are in his segwit address.
   127  
   128  ```
   129  lit-af# sweep tb1qf77l4ja2kq6na0ffmekph6qv22puufqr5aatg0 50000000
   130  entered command: sweep tb1qf77l4ja2kq6na0ffmekph6qv22puufqr5aatg0 50000000
   131  Swept
   132  0 d297da04c43919e683ffc03539ee38e185425e8fa14d1ccae6577fbb35be575a
   133  ```
   134  
   135  ### Step 5: Open a channel
   136  
   137  Bob is connected to Alice and wants to open a payment channel. If he has enough (segwit) money and is connected to Alice, he can open a channel.
   138  
   139  ```
   140  lit-af# fund 1 1 50000000 0
   141  ```
   142  
   143  This opens a channel with peer 1 (Alice) with a channel capacity of 50,000,000 satoshis (half a coin), and sends 0 satoshis over in the creation process.  Bob starts out with all 50,000,000 satoshis in the channel, so only he can send to Alice.  The second "1" is to specify the cointype, which is 1 for Bitcoin Testnet3.
   144  
   145  ### Step 6: Send micro-payments
   146  
   147  (Do they count as micro-payments if testnet coins have zero value?)
   148  
   149  use ls again to see that the channel is there, it will be labeled channel 1.
   150  
   151  ```
   152  lit-af# push 1 200000
   153  ```
   154  
   155  This pushes 200,000 satoshis to the other side of the channel.  You can do this 200 trillion times before the channel needs to be closed.  (Actually, since I don't think you can send that many payments, the software will probably crash if you do manage to exceed 2^48)
   156  
   157  ### Step 7: Close/Break the channel
   158  
   159  You can close the channel cooperatively using:
   160  
   161  ```
   162  lit-af# close 1
   163  ```
   164  or non-cooperatively with:
   165  
   166  ```
   167  lit-af# break 1
   168  ```
   169  
   170  to close the channel at the current state. Uncooperative is maybe more fun because the node who breaks the channel has to wait 5 blocks before they can use their money.  The other node can spend immediately.  After a cooperative close, they can both spend immediately.  The `break` command does not need a connection to the other node.