mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-04 06:44:24 +01:00
protocol: move commitment key to open_channel message.
And rename final to final_key to be clearer. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -54,8 +54,8 @@ int main(int argc, char *argv[])
|
||||
errx(1, "Private key '%s' not on testnet!", argv[4]);
|
||||
|
||||
/* Pubkey well-formed? */
|
||||
if (!proto_to_pubkey(o2->anchor->pubkey, &pubkey2))
|
||||
errx(1, "Invalid anchor-2 key");
|
||||
if (!proto_to_pubkey(o2->commit_key, &pubkey2))
|
||||
errx(1, "Invalid o2 commit_key");
|
||||
|
||||
/* Get the transaction ID of the anchor. */
|
||||
anchor = anchor_tx_create(ctx, o1, o2, &inmap, &outmap);
|
||||
|
||||
@@ -68,13 +68,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Get pubkeys */
|
||||
if (!proto_to_pubkey(o1->anchor->pubkey, &pubkey2))
|
||||
if (!proto_to_pubkey(o1->commit_key, &pubkey2))
|
||||
errx(1, "Invalid o1 commit pubkey");
|
||||
if (pubkey_len(&pubkey1) != pubkey_len(&pubkey2)
|
||||
|| memcmp(pubkey1.key, pubkey2.key, pubkey_len(&pubkey2)) != 0)
|
||||
errx(1, "o1 pubkey != this privkey");
|
||||
if (!proto_to_pubkey(o2->anchor->pubkey, &pubkey2))
|
||||
errx(1, "Invalid o2 final pubkey");
|
||||
if (!proto_to_pubkey(o2->commit_key, &pubkey2))
|
||||
errx(1, "Invalid o2 commit pubkey");
|
||||
|
||||
/* This is what the anchor pays to; figure out whick output. */
|
||||
redeemscript = bitcoin_redeem_2of2(ctx, &pubkey1, &pubkey2);
|
||||
|
||||
@@ -53,10 +53,10 @@ int main(int argc, char *argv[])
|
||||
bitcoin_txid(anchor, &anchor_txid);
|
||||
|
||||
/* Pubkeys well-formed? */
|
||||
if (!proto_to_pubkey(o1->anchor->pubkey, &pubkey1))
|
||||
errx(1, "Invalid anchor-1 key");
|
||||
if (!proto_to_pubkey(o2->anchor->pubkey, &pubkey2))
|
||||
errx(1, "Invalid anchor-2 key");
|
||||
if (!proto_to_pubkey(o1->commit_key, &pubkey1))
|
||||
errx(1, "Invalid o1 commit_key");
|
||||
if (!proto_to_pubkey(o2->commit_key, &pubkey2))
|
||||
errx(1, "Invalid o2 commit_key");
|
||||
|
||||
/* Get delta by accumulting all the updates. */
|
||||
delta = 0;
|
||||
|
||||
@@ -70,12 +70,12 @@ int main(int argc, char *argv[])
|
||||
errx(1, "Invalid bitcoin pubkey '%s'", argv[5]);
|
||||
|
||||
/* Get pubkeys */
|
||||
if (!proto_to_pubkey(o1->final, &pubkey2))
|
||||
if (!proto_to_pubkey(o1->final_key, &pubkey2))
|
||||
errx(1, "Invalid o1 final pubkey");
|
||||
if (pubkey_len(&pubkey1) != pubkey_len(&pubkey2)
|
||||
|| memcmp(pubkey1.key, pubkey2.key, pubkey_len(&pubkey2)) != 0)
|
||||
errx(1, "o1 pubkey != this privkey");
|
||||
if (!proto_to_pubkey(o2->final, &pubkey2))
|
||||
if (!proto_to_pubkey(o2->final_key, &pubkey2))
|
||||
errx(1, "Invalid o2 final pubkey");
|
||||
|
||||
/* o1 gives us the revocation hash */
|
||||
|
||||
@@ -58,13 +58,13 @@ int main(int argc, char *argv[])
|
||||
errx(1, "Private key '%s' not on testnet!", argv[4]);
|
||||
|
||||
/* Get pubkeys */
|
||||
if (!proto_to_pubkey(o1->anchor->pubkey, &pubkey2))
|
||||
errx(1, "Invalid o1 anchor pubkey");
|
||||
if (!proto_to_pubkey(o1->commit_key, &pubkey2))
|
||||
errx(1, "Invalid o1 commit pubkey");
|
||||
if (pubkey_len(&pubkey1) != pubkey_len(&pubkey2)
|
||||
|| memcmp(pubkey1.key, pubkey2.key, pubkey_len(&pubkey2)) != 0)
|
||||
errx(1, "o1 pubkey != this privkey");
|
||||
if (!proto_to_pubkey(o2->anchor->pubkey, &pubkey2))
|
||||
errx(1, "Invalid o2 anchor pubkey");
|
||||
if (!proto_to_pubkey(o2->commit_key, &pubkey2))
|
||||
errx(1, "Invalid o2 commit pubkey");
|
||||
|
||||
/* Their signature comes from open-commit or from update-accept. */
|
||||
sig2.stype = SIGHASH_ALL;
|
||||
|
||||
@@ -74,12 +74,12 @@ int main(int argc, char *argv[])
|
||||
errx(1, "Invalid bitcoin pubkey '%s'", argv[6]);
|
||||
|
||||
/* Get pubkeys */
|
||||
if (!proto_to_pubkey(o1->final, &pubkey2))
|
||||
if (!proto_to_pubkey(o1->final_key, &pubkey2))
|
||||
errx(1, "Invalid o1 final pubkey");
|
||||
if (pubkey_len(&pubkey1) != pubkey_len(&pubkey2)
|
||||
|| memcmp(pubkey1.key, pubkey2.key, pubkey_len(&pubkey2)) != 0)
|
||||
errx(1, "o1 pubkey != this privkey");
|
||||
if (!proto_to_pubkey(o2->final, &pubkey2))
|
||||
if (!proto_to_pubkey(o2->final_key, &pubkey2))
|
||||
errx(1, "Invalid o2 final pubkey");
|
||||
|
||||
/* Now, which commit output? Match redeem script. */
|
||||
|
||||
@@ -132,7 +132,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
anchor.n_inputs = (argc - 6);
|
||||
anchor.inputs = tal_arr(ctx, BitcoinInput *, anchor.n_inputs);
|
||||
anchor.pubkey = pubkey_to_proto(ctx, &commitkey);
|
||||
|
||||
total_in = 0;
|
||||
for (i = 0; i < anchor.n_inputs; i++) {
|
||||
@@ -160,7 +159,7 @@ int main(int argc, char *argv[])
|
||||
sha256(&revocation_hash,
|
||||
revocation_hash.u.u8, sizeof(revocation_hash.u.u8));
|
||||
|
||||
pkt = openchannel_pkt(ctx, &revocation_hash, &outkey,
|
||||
pkt = openchannel_pkt(ctx, &revocation_hash, &commitkey, &outkey,
|
||||
commit_tx_fee, locktime_seconds, &anchor);
|
||||
|
||||
if (!write_all(STDOUT_FILENO, pkt, pkt_totlen(pkt)))
|
||||
|
||||
@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
|
||||
(long long)o2->commitment_fee);
|
||||
|
||||
/* Their pubkey must be valid */
|
||||
if (!proto_to_pubkey(o2->anchor->pubkey, &pubkey2))
|
||||
if (!proto_to_pubkey(o2->commit_key, &pubkey2))
|
||||
errx(1, "Invalid public open-channel-file2");
|
||||
|
||||
/* Sign it for them. */
|
||||
|
||||
@@ -76,13 +76,13 @@ int main(int argc, char *argv[])
|
||||
revocation_hash.u.u8, sizeof(revocation_hash.u.u8));
|
||||
|
||||
/* Get pubkeys */
|
||||
if (!proto_to_pubkey(o1->anchor->pubkey, &pubkey2))
|
||||
if (!proto_to_pubkey(o1->commit_key, &pubkey2))
|
||||
errx(1, "Invalid o1 commit pubkey");
|
||||
if (pubkey_len(&pubkey1) != pubkey_len(&pubkey2)
|
||||
|| memcmp(pubkey1.key, pubkey2.key, pubkey_len(&pubkey2)) != 0)
|
||||
errx(1, "o1 pubkey != this privkey");
|
||||
if (!proto_to_pubkey(o2->anchor->pubkey, &pubkey2))
|
||||
errx(1, "Invalid o2 final pubkey");
|
||||
if (!proto_to_pubkey(o2->commit_key, &pubkey2))
|
||||
errx(1, "Invalid o2 commit pubkey");
|
||||
|
||||
/* This is what the anchor pays to; figure out whick output. */
|
||||
redeemscript = bitcoin_redeem_2of2(ctx, &pubkey1, &pubkey2);
|
||||
|
||||
@@ -89,10 +89,10 @@ int main(int argc, char *argv[])
|
||||
errx(1, "Their preimage was incorrect");
|
||||
|
||||
/* Get pubkeys */
|
||||
if (!proto_to_pubkey(o1->anchor->pubkey, &pubkey1))
|
||||
if (!proto_to_pubkey(o1->commit_key, &pubkey1))
|
||||
errx(1, "Invalid o1 commit pubkey");
|
||||
if (!proto_to_pubkey(o2->anchor->pubkey, &pubkey2))
|
||||
errx(1, "Invalid o2 final pubkey");
|
||||
if (!proto_to_pubkey(o2->commit_key, &pubkey2))
|
||||
errx(1, "Invalid o2 commit pubkey");
|
||||
|
||||
/* This is what the anchor pays to; figure out whick output. */
|
||||
redeemscript = bitcoin_redeem_2of2(ctx, &pubkey1, &pubkey2);
|
||||
|
||||
@@ -80,13 +80,13 @@ int main(int argc, char *argv[])
|
||||
shachain_from_seed(&seed, argc - 7 - 1, &preimage);
|
||||
|
||||
/* Get pubkeys */
|
||||
if (!proto_to_pubkey(o1->anchor->pubkey, &pubkey2))
|
||||
if (!proto_to_pubkey(o1->commit_key, &pubkey2))
|
||||
errx(1, "Invalid o1 commit pubkey");
|
||||
if (pubkey_len(&pubkey1) != pubkey_len(&pubkey2)
|
||||
|| memcmp(pubkey1.key, pubkey2.key, pubkey_len(&pubkey2)) != 0)
|
||||
errx(1, "o1 pubkey != this privkey");
|
||||
if (!proto_to_pubkey(o2->anchor->pubkey, &pubkey2))
|
||||
errx(1, "Invalid o2 final pubkey");
|
||||
if (!proto_to_pubkey(o2->commit_key, &pubkey2))
|
||||
errx(1, "Invalid o2 commit pubkey");
|
||||
|
||||
/* This is what the anchor pays to; figure out whick output. */
|
||||
redeemscript = bitcoin_redeem_2of2(ctx, &pubkey1, &pubkey2);
|
||||
@@ -115,7 +115,7 @@ int main(int argc, char *argv[])
|
||||
errx(1, "Delta too large");
|
||||
|
||||
/* Their pubkey must be valid */
|
||||
if (!proto_to_pubkey(o2->anchor->pubkey, &pubkey2))
|
||||
if (!proto_to_pubkey(o2->commit_key, &pubkey2))
|
||||
errx(1, "Invalid public open-channel-file2");
|
||||
|
||||
/* Sign it for them. */
|
||||
|
||||
Reference in New Issue
Block a user