Skip to content

Commit

Permalink
Merge pull request #116 from p2pderivatives/fix/channel-renew-ln-dlc-…
Browse files Browse the repository at this point in the history
…establish

Fix protocol of channel renew and sub channel establish
  • Loading branch information
Tibo-lg committed Jul 10, 2023
2 parents 34f7334 + 7560cad commit 572afbb
Show file tree
Hide file tree
Showing 32 changed files with 787 additions and 306 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ jobs:
- name: Wait for electrs to be ready
run: ./scripts/wait_for_electrs.sh
- name: Run test
run: RUST_BACKTRACE=1 ${{ matrix.tests }} --ignored --exact
run: RUST_MIN_STACK=104857600 RUST_BACKTRACE=1 ${{ matrix.tests }} --ignored --exact
- name: Stop bitcoin node
run: ./scripts/stop_node.sh
5 changes: 3 additions & 2 deletions dlc-manager/src/channel/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ impl_dlc_writeable_enum!(
(4, SettledConfirmed, {(settle_tx, writeable), (counter_settle_adaptor_signature, {cb_writeable, write_ecdsa_adaptor_signature, read_ecdsa_adaptor_signature}), (own_settle_adaptor_signature, {cb_writeable, write_ecdsa_adaptor_signature, read_ecdsa_adaptor_signature}), (counter_next_per_update_point, writeable), (own_next_per_update_point, writeable), (timeout, writeable), (own_payout, writeable), (counter_payout, writeable) }),
(5, Settled, {(settle_tx, writeable), (counter_settle_adaptor_signature, {cb_writeable, write_ecdsa_adaptor_signature, read_ecdsa_adaptor_signature}), (own_settle_adaptor_signature, {cb_writeable, write_ecdsa_adaptor_signature, read_ecdsa_adaptor_signature}), (own_payout, writeable), (counter_payout, writeable)}),
(6, RenewOffered, {(offered_contract_id, writeable), (counter_payout, writeable), (is_offer, writeable), (offer_next_per_update_point, writeable), (timeout, writeable)}),
(7, RenewAccepted, {(contract_id, writeable), (offer_per_update_point, writeable), (accept_per_update_point, writeable), (buffer_transaction, writeable), (buffer_script_pubkey, writeable), (accept_buffer_adaptor_signature, {cb_writeable, write_ecdsa_adaptor_signature, read_ecdsa_adaptor_signature}), (timeout, writeable), (own_payout, writeable)}),
(8, RenewConfirmed, {(contract_id, writeable), (offer_per_update_point, writeable), (accept_per_update_point, writeable), (buffer_transaction, writeable), (buffer_script_pubkey, writeable), (offer_buffer_adaptor_signature, {cb_writeable, write_ecdsa_adaptor_signature, read_ecdsa_adaptor_signature}), (accept_buffer_adaptor_signature, {cb_writeable, write_ecdsa_adaptor_signature, read_ecdsa_adaptor_signature}), (timeout, writeable), (own_payout, writeable), (total_collateral, writeable)}),
(7, RenewAccepted, {(contract_id, writeable), (offer_per_update_point, writeable), (accept_per_update_point, writeable), (buffer_transaction, writeable), (buffer_script_pubkey, writeable), (timeout, writeable), (own_payout, writeable)}),
(8, RenewConfirmed, {(contract_id, writeable), (offer_per_update_point, writeable), (accept_per_update_point, writeable), (buffer_transaction, writeable), (buffer_script_pubkey, writeable), (offer_buffer_adaptor_signature, {cb_writeable, write_ecdsa_adaptor_signature, read_ecdsa_adaptor_signature}), (timeout, writeable), (own_payout, writeable), (total_collateral, writeable)}),
(15, RenewFinalized, {(contract_id, writeable), (offer_per_update_point, writeable), (accept_per_update_point, writeable), (buffer_transaction, writeable), (buffer_script_pubkey, writeable), (offer_buffer_adaptor_signature, {cb_writeable, write_ecdsa_adaptor_signature, read_ecdsa_adaptor_signature}), (accept_buffer_adaptor_signature, {cb_writeable, write_ecdsa_adaptor_signature, read_ecdsa_adaptor_signature}), (timeout, writeable), (own_payout, writeable), (total_collateral, writeable)}),
(9, Closing, {(buffer_transaction, writeable), (contract_id, writeable), (is_initiator, writeable)}),
(10, ClosedPunished, { (punishment_txid, writeable) }),
(11, CollaborativeCloseOffered, { (counter_payout, writeable), (offer_signature, writeable), (close_tx, writeable), (timeout, writeable) })
Expand Down
29 changes: 26 additions & 3 deletions dlc-manager/src/channel/signed_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,6 @@ typed_enum!(
buffer_transaction: Transaction,
/// The buffer transaction script pubkey.
buffer_script_pubkey: Script,
/// The adaptor signature for the buffer transaction generated by
/// the accept party.
accept_buffer_adaptor_signature: EcdsaAdaptorSignature,
/// The UNIX epoch at which the counter party will be considered
/// unresponsive and the channel will be forced closed.
timeout: u64,
Expand All @@ -240,6 +237,31 @@ typed_enum!(
/// A [`SignedChannel`] is in `RenewConfirmed` state when the local party
/// has sent a [`dlc_messages::channel::RenewConfirm`] message.
RenewConfirmed {
/// The [`crate::ContractId`] of the offered contract.
contract_id: ContractId,
/// The per update point to be used by the offer party for the setup
/// of the next channel state.
offer_per_update_point: PublicKey,
/// The per update point to be used by the accept party for the setup
/// of the next channel state.
accept_per_update_point: PublicKey,
/// The buffer transaction.
buffer_transaction: Transaction,
/// The buffer transaction script pubkey.
buffer_script_pubkey: Script,
/// The adaptor signature for the buffer transaction generated by
/// the offer party.
offer_buffer_adaptor_signature: EcdsaAdaptorSignature,
/// The UNIX epoch at which the counter party will be considered
/// unresponsive and the channel will be forced closed.
timeout: u64,
/// The payout to the local party attributed for closing the previous state.
own_payout: u64,
/// The total amount of collateral in the channel.
total_collateral: u64,
},
/// Finalize the renewal of the contract within a DLC channel.
RenewFinalized {
/// The [`crate::ContractId`] of the offered contract.
contract_id: ContractId,
/// The per update point to be used by the offer party for the setup
Expand Down Expand Up @@ -334,6 +356,7 @@ impl SignedChannelState {
} => Some(*offered_contract_id),
SignedChannelState::RenewAccepted { contract_id, .. } => Some(*contract_id),
SignedChannelState::RenewConfirmed { contract_id, .. } => Some(*contract_id),
SignedChannelState::RenewFinalized { contract_id, .. } => Some(*contract_id),
SignedChannelState::Closing { contract_id, .. } => Some(*contract_id),
_ => None,
}
Expand Down
Loading

0 comments on commit 572afbb

Please sign in to comment.