New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Create trade after finished dlc protocol #2084
Conversation
8a58950
to
e80b8cc
Compare
coordinator/migrations/2024-02-12-113100_add_contract_transaction/down.sql
Outdated
Show resolved
Hide resolved
Note, rollovers will change the contract but are currently not get captured in a contract transaction. I will work on that once I got an approval on this change. |
8f2c78a
to
c344472
Compare
Note, this change will add the reference id to the dlc messages, thus affecting the hash of the dlc message. Any last dlc messages will those get processed again. In my testing this didn't lead to any issues, however, we might want to consider reverting adding the reference id to the dlc message for now, since it is not really needed at the moment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it! With some new names and a ProtocolId
type I would be very happy.
coordinator/migrations/2024-02-12-113100_add_contract_transaction/up.sql
Outdated
Show resolved
Hide resolved
coordinator/migrations/2024-02-12-113100_add_contract_transaction/up.sql
Outdated
Show resolved
Hide resolved
coordinator/migrations/2024-02-12-113100_add_contract_transaction/up.sql
Outdated
Show resolved
Hide resolved
coordinator/migrations/2024-02-12-113100_add_contract_transaction/up.sql
Outdated
Show resolved
Hide resolved
coordinator/migrations/2024-02-12-113100_add_contract_transaction/up.sql
Outdated
Show resolved
Hide resolved
Let's keep the change, as discussed 🙏 |
354d436
to
905a599
Compare
905a599
to
37c7d83
Compare
@luckysori please have another look, I've addressed your remarks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks for taking the time to address my comments
This patch introduces the contract transaction, which reflects the state of the dlc protocol. A contract transaction starts with one of the following dlc protocols - offer channel - offer collaborative settle - renew offer - offer collaborative close - force closure The contract txid is used as a reference id for the offer channel, offer collaborative settle and renew offer protocols. Once the final message of the protocol is received, the contract transaction gets updated with the latest dlc ids and creates the corresponding trade. ``` orderbook=# select id, previous_txid, contract_txid, channel_id, contract_id, transaction_state from contract_transactions; id | previous_txid | contract_txid | channel_id | contract_id | transaction_state ----+--------------------------------------+--------------------------------------+------------------------------------------------------------------+------------------------------------------------------------------+------------------- 1 | | 996ef088-f30c-4b9a-b386-9dd502416777 | bfd333e680af603b52340c4e84335c6b9b2fb950363db8a4c77589d494bc8d1e | eba735ded90d3db6516d8260a1361d69f32da484b1b3b0a8e7612ae42f8768fe | Success 2 | 996ef088-f30c-4b9a-b386-9dd502416777 | caf1335c-be7f-478e-aadb-e996055a8668 | bfd333e680af603b52340c4e84335c6b9b2fb950363db8a4c77589d494bc8d1e | eba735ded90d3db6516d8260a1361d69f32da484b1b3b0a8e7612ae42f8768fe | Success 3 | caf1335c-be7f-478e-aadb-e996055a8668 | 06d443f1-17e7-4536-8640-e4ff7ac79b91 | bfd333e680af603b52340c4e84335c6b9b2fb950363db8a4c77589d494bc8d1e | 402ac89527d6aa15c26fc550c21390b5d603e645b37358c3dd8e1c22230de826 | Success 4 | 06d443f1-17e7-4536-8640-e4ff7ac79b91 | 322f3e46-4817-4c57-b8a6-3f641f800988 | bfd333e680af603b52340c4e84335c6b9b2fb950363db8a4c77589d494bc8d1e | 402ac89527d6aa15c26fc550c21390b5d603e645b37358c3dd8e1c22230de826 | Success 5 | 322f3e46-4817-4c57-b8a6-3f641f800988 | 535303e3-d00f-4a13-9cab-6998b629be42 | bfd333e680af603b52340c4e84335c6b9b2fb950363db8a4c77589d494bc8d1e | eceef4e5a6a3b7c81500f70379a807c66d61468496850b1b06a74884f5be7395 | Success ``` Note, the trade params are temporarily stored to the `trade_params` table so that the trade can be created correctly.
37c7d83
to
3c58a99
Compare
This patch introduces the contract transaction, which reflects the state of the dlc protocol.
A contract transaction starts with one of the following dlc protocols
The contract txid is used as a reference id for the offer channel, offer collaborative settle and renew offer protocols. Once the final message of the protocol is received, the contract transaction gets updated with the latest dlc ids and creates the corresponding trade.
Note, the trade params are temporarily stored to the
trade_params
table so that the trade can be created correctly.Depends on the following
rust-dlc
changes