-
Notifications
You must be signed in to change notification settings - Fork 911
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
Update emergency.recover after every 'commitment_revocation' so that user can sweep funds by penalty transaction. #7772
Open
adi2011
wants to merge
8
commits into
ElementsProject:master
Choose a base branch
from
adi2011:enablepenaltytxn
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3379840
tools/gen: Enable Subtypes to have TLVStreams
adi2011 c9b3bfa
common/scb_wire: Add their_shachain, basepoints, opener to enable eme…
adi2011 53b16a0
lightningd: Add shachain, their_basepoint, and opener fields to stub_…
adi2011 afa2aa8
wallet: Add 'wallet_stub_shachain_init' to persist new shachain data …
adi2011 6bac311
lightningd/peer_control: Add the latest shachain when we update the e…
adi2011 ee38322
plugins/chanbackup: Add hook 'commitment_revocation' so that we can u…
adi2011 5a77b19
tests/test_misc.py: Add test_emergencyrecoverpenaltytxn
adi2011 e20a2c3
wallet/test: Update mocks for run-wallet.c
adi2011 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1452,7 +1452,11 @@ static struct channel *stub_chan(struct command *cmd, | |
struct bitcoin_outpoint funding, | ||
struct wireaddr addr, | ||
struct amount_sat funding_sats, | ||
struct channel_type *type) | ||
struct channel_type *type, | ||
struct shachain shachain, | ||
struct basepoints their_basepoint, | ||
enum side opener, | ||
u16 remote_to_self_delay) | ||
{ | ||
struct basepoints basepoints; | ||
struct bitcoin_signature *sig; | ||
|
@@ -1465,9 +1469,13 @@ static struct channel *stub_chan(struct command *cmd, | |
struct pubkey localFundingPubkey; | ||
struct pubkey pk; | ||
struct short_channel_id *scid; | ||
u32 blockht; | ||
u32 blockht = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why set this here? it doesn't look like it got used again in this commit |
||
u32 feerate; | ||
struct channel_stats zero_channel_stats; | ||
struct wallet_shachain *their_shachain = tal(cmd, struct wallet_shachain); | ||
their_shachain->chain = shachain; | ||
their_shachain->id = 0; | ||
|
||
u8 *dummy_sig = tal_hexdata(cmd, | ||
"30450221009b2e0eef267b94c3899fb0dc73750" | ||
"12e2cee4c10348a068fe78d1b82b4b1403602207" | ||
|
@@ -1528,8 +1536,11 @@ static struct channel *stub_chan(struct command *cmd, | |
/* FIXME: Makeake these a pointer, so they could be NULL */ | ||
memset(our_config, 0, sizeof(struct channel_config)); | ||
memset(their_config, 0, sizeof(struct channel_config)); | ||
memset(channel_info, 0, sizeof(struct channel_info)); | ||
|
||
our_config->to_self_delay = remote_to_self_delay; | ||
channel_info->their_config = *their_config; | ||
channel_info->theirbase = basepoints; | ||
channel_info->theirbase = their_basepoint; | ||
channel_info->remote_fundingkey = pk; | ||
channel_info->remote_per_commit = pk; | ||
channel_info->old_remote_per_commit = pk; | ||
|
@@ -1545,9 +1556,9 @@ static struct channel *stub_chan(struct command *cmd, | |
|
||
/* Channel Shell with Dummy data(mostly) */ | ||
channel = new_channel(peer, id, | ||
NULL, /* No shachain yet */ | ||
their_shachain, | ||
CHANNELD_NORMAL, | ||
LOCAL, | ||
opener, | ||
NULL, | ||
"restored from static channel backup", | ||
0, false, false, | ||
|
@@ -1574,15 +1585,15 @@ static struct channel *stub_chan(struct command *cmd, | |
sig, | ||
NULL, /* No HTLC sigs */ | ||
channel_info, | ||
new_fee_states(cmd, LOCAL, &feerate), | ||
new_fee_states(cmd, opener, &feerate), | ||
NULL, /* No shutdown_scriptpubkey[REMOTE] */ | ||
NULL, | ||
1, false, | ||
NULL, /* No commit sent */ | ||
/* If we're fundee, could be a little before this | ||
* in theory, but it's only used for timing out. */ | ||
get_network_blockheight(ld->topology), | ||
FEERATE_FLOOR, | ||
feerate, | ||
funding_sats.satoshis / MINIMUM_TX_WEIGHT * 1000 /* Raw: convert to feerate */, | ||
&basepoints, | ||
&localFundingPubkey, | ||
|
@@ -1596,7 +1607,7 @@ static struct channel *stub_chan(struct command *cmd, | |
0, /* no close_attempt_height */ | ||
REASON_REMOTE, | ||
NULL, | ||
take(new_height_states(ld->wallet, LOCAL, | ||
take(new_height_states(ld->wallet, opener, | ||
&blockht)), | ||
0, NULL, 0, 0, /* No leases on v1s */ | ||
ld->config.htlc_minimum_msat, | ||
|
@@ -1636,6 +1647,8 @@ static struct command_result *json_recoverchannel(struct command *cmd, | |
char *token = json_strdup(tmpctx, buffer, t); | ||
const u8 *scb_arr = tal_hexdata(cmd, token, strlen(token)); | ||
size_t scblen = tal_count(scb_arr); | ||
struct shachain chain; | ||
struct basepoints basepoints; | ||
|
||
scb_chan = fromwire_scb_chan(cmd ,&scb_arr, &scblen); | ||
|
||
|
@@ -1644,6 +1657,25 @@ static struct command_result *json_recoverchannel(struct command *cmd, | |
continue; | ||
} | ||
|
||
if (scb_chan->tlvs->shachain == NULL) { | ||
shachain_init(&chain); | ||
} else { | ||
log_debug(cmd->ld->log, "shachain is not null yayyy"); | ||
chain = *scb_chan->tlvs->shachain; | ||
} | ||
|
||
if (scb_chan->tlvs->basepoints == NULL) { | ||
struct pubkey _localfundingpubkey; | ||
get_channel_basepoints(cmd->ld, | ||
&scb_chan->node_id, | ||
scb_chan->id, | ||
&basepoints, | ||
&_localfundingpubkey); | ||
} else { | ||
log_debug(cmd->ld->log, "basepoints is not null yayyy"); | ||
basepoints = *scb_chan->tlvs->basepoints; | ||
} | ||
|
||
struct lightningd *ld = cmd->ld; | ||
struct channel *channel= stub_chan(cmd, | ||
scb_chan->id, | ||
|
@@ -1652,7 +1684,11 @@ static struct command_result *json_recoverchannel(struct command *cmd, | |
scb_chan->funding, | ||
scb_chan->addr, | ||
scb_chan->funding_sats, | ||
scb_chan->type); | ||
scb_chan->type, | ||
chain, | ||
basepoints, | ||
scb_chan->tlvs->opener == NULL ? LOCAL : *scb_chan->tlvs->opener, | ||
scb_chan->tlvs->remote_to_self_delay == NULL ? 0 : *scb_chan->tlvs->remote_to_self_delay); | ||
|
||
/* Returns NULL only when channel already exists, so we skip over it. */ | ||
if (channel == NULL) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
for commit 53b16a0, it looks like a keyword got omitted from the commit message