Hi,
In case someone reaches this post with the same question, here I post the solution on how to replicate a Contract Breach Attack for C-lighting (Core lightning) node implementation.
Do this in a simulation environment as you could lose your funds.
Simulator used: Polar:
https://lightningpolar.com/ 1. Create polar enviorment with minimum 2 lightning nodes and one bitcoin core node, one has to be c-lightning (the malicious one).
2. Open a channel between two nodes.
3. Do a first transaction
4. The malicious node wants to keep this status after some payments, sign the last transaction following these steps (two methods available):
4.1 SQL METHOD:
4.1.1 Login into node as root:
· "docker exec -it polar-n2-bob bash" (polar-n2-bob is the container name, may be different)
4.1.2 Go to the node directory:
· "cd /home/clightning/.lightning/regtest"
4.1.3 Install the needed dependencies in order to make sql queries to the database:
· apt-get update -y; apt install sqlite3 -y
4.1.4 Open the database:
· "sqlite3 lightningd.sqlite3"
4.1.5 Take peer id with:
· "SELECT HEX(node_id) FROM peers;"
4.1.6 Sign the last tx with:
· "lightning-cli dev-sign-last-tx {peer-id}"
4.2 CLI METHOD:
4.2.1 Take the peer id:
· "lightning-cli listchannels"
4.2.2 Sign the last tx with:
· "lightning-cli dev-sign-last-tx {peer-id}"
5. Do some more payments to have a different last valid status.
6. Login into the bitcoin core node and broadcast the sign transaction with: "bitcoin-cli sendrawtransaction {output 4.1.6 or 4.2.2}"
7. Refresh the graph and you should see the channel closed and all the money on the victim node you may need to mine some blocks to add the tx into the blockchain.
References:
https://bitcoin.stackexchange.com/questions/96881/cheat-lightning-network-c-lightningHope this helps,
SS