mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
protocol: add field so we can specify the escape fee.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
98d994f930
commit
06fe371b3f
@ -1033,7 +1033,7 @@ const ProtobufCMessageDescriptor bitcoin_pubkey__descriptor =
|
||||
(ProtobufCMessageInit) bitcoin_pubkey__init,
|
||||
NULL,NULL,NULL /* reserved[123] */
|
||||
};
|
||||
static const ProtobufCFieldDescriptor open_channel__field_descriptors[9] =
|
||||
static const ProtobufCFieldDescriptor open_channel__field_descriptors[10] =
|
||||
{
|
||||
{
|
||||
"locktime_seconds",
|
||||
@ -1132,9 +1132,21 @@ static const ProtobufCFieldDescriptor open_channel__field_descriptors[9] =
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"min_confirms",
|
||||
"escape_fee",
|
||||
10,
|
||||
PROTOBUF_C_LABEL_REQUIRED,
|
||||
PROTOBUF_C_TYPE_UINT64,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(OpenChannel, escape_fee),
|
||||
NULL,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"min_confirms",
|
||||
11,
|
||||
PROTOBUF_C_LABEL_REQUIRED,
|
||||
PROTOBUF_C_TYPE_UINT32,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(OpenChannel, min_confirms),
|
||||
@ -1147,18 +1159,19 @@ static const ProtobufCFieldDescriptor open_channel__field_descriptors[9] =
|
||||
static const unsigned open_channel__field_indices_by_name[] = {
|
||||
5, /* field[5] = commitkey */
|
||||
4, /* field[4] = commitment_fee */
|
||||
8, /* field[8] = escape_fee */
|
||||
7, /* field[7] = escape_hash */
|
||||
3, /* field[3] = final */
|
||||
1, /* field[1] = locktime_blocks */
|
||||
0, /* field[0] = locktime_seconds */
|
||||
8, /* field[8] = min_confirms */
|
||||
9, /* field[9] = min_confirms */
|
||||
2, /* field[2] = revocation_hash */
|
||||
6, /* field[6] = total_input */
|
||||
};
|
||||
static const ProtobufCIntRange open_channel__number_ranges[1 + 1] =
|
||||
{
|
||||
{ 2, 0 },
|
||||
{ 0, 9 }
|
||||
{ 0, 10 }
|
||||
};
|
||||
const ProtobufCMessageDescriptor open_channel__descriptor =
|
||||
{
|
||||
@ -1168,7 +1181,7 @@ const ProtobufCMessageDescriptor open_channel__descriptor =
|
||||
"OpenChannel",
|
||||
"",
|
||||
sizeof(OpenChannel),
|
||||
9,
|
||||
10,
|
||||
open_channel__field_descriptors,
|
||||
open_channel__field_indices_by_name,
|
||||
1, open_channel__number_ranges,
|
||||
|
@ -145,6 +145,10 @@ struct _OpenChannel
|
||||
* Secret hash for escape transactions.
|
||||
*/
|
||||
Sha256Hash *escape_hash;
|
||||
/*
|
||||
* How much fee we will pay for escape txs.
|
||||
*/
|
||||
uint64_t escape_fee;
|
||||
/*
|
||||
* How many confirmations on anchor before we'll use channel.
|
||||
*/
|
||||
@ -157,7 +161,7 @@ struct _OpenChannel
|
||||
};
|
||||
#define OPEN_CHANNEL__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&open_channel__descriptor) \
|
||||
, NULL, NULL, 0, NULL, 0, NULL, 0, OPEN_CHANNEL__LOCKTIME__NOT_SET, {} }
|
||||
, NULL, NULL, 0, NULL, 0, NULL, 0, 0, OPEN_CHANNEL__LOCKTIME__NOT_SET, {} }
|
||||
|
||||
|
||||
/*
|
||||
|
@ -62,8 +62,10 @@ message open_channel {
|
||||
required uint64 total_input = 8;
|
||||
// Secret hash for escape transactions.
|
||||
required sha256_hash escape_hash = 9;
|
||||
// How much fee we will pay for escape txs.
|
||||
required uint64 escape_fee = 10;
|
||||
// How many confirmations on anchor before we'll use channel.
|
||||
required uint32 min_confirms = 10;
|
||||
required uint32 min_confirms = 11;
|
||||
}
|
||||
|
||||
// Give them the txid of our anchor transaction.
|
||||
|
2
pkt.c
2
pkt.c
@ -39,6 +39,7 @@ struct pkt *openchannel_pkt(const tal_t *ctx,
|
||||
u32 rel_locktime_seconds,
|
||||
u64 anchor_amount,
|
||||
const struct sha256 *escape_hash,
|
||||
u64 escape_fee,
|
||||
u32 min_confirms)
|
||||
{
|
||||
OpenChannel o = OPEN_CHANNEL__INIT;
|
||||
@ -51,6 +52,7 @@ struct pkt *openchannel_pkt(const tal_t *ctx,
|
||||
o.locktime_seconds = rel_locktime_seconds;
|
||||
o.total_input = anchor_amount;
|
||||
o.escape_hash = sha256_to_proto(ctx, escape_hash);
|
||||
o.escape_fee = escape_fee;
|
||||
o.min_confirms = min_confirms;
|
||||
|
||||
{
|
||||
|
2
pkt.h
2
pkt.h
@ -40,6 +40,7 @@ struct pubkey;
|
||||
* @anchor_txid: the anchor transaction ID.
|
||||
* @anchor_amount: the anchor amount.
|
||||
* @escape_hash: the hash whose preimage will revoke our escape txs.
|
||||
* @escape_fee: the fee for escape txs.
|
||||
* @min_confirms: how many confirms we want on anchor.
|
||||
*/
|
||||
struct pkt *openchannel_pkt(const tal_t *ctx,
|
||||
@ -50,6 +51,7 @@ struct pkt *openchannel_pkt(const tal_t *ctx,
|
||||
u32 rel_locktime_seconds,
|
||||
u64 anchor_amount,
|
||||
const struct sha256 *escape_hash,
|
||||
u64 escape_fee,
|
||||
u32 min_confirms);
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@ int main(int argc, char *argv[])
|
||||
struct sha256 seed, revocation_hash, escape_secret, escape_hash;
|
||||
struct pkt *pkt;
|
||||
const tal_t *ctx = tal_arr(NULL, char, 0);
|
||||
u64 commit_tx_fee, total_in;
|
||||
u64 commit_tx_fee, escape_fee, total_in;
|
||||
unsigned int locktime_seconds, min_confirms;
|
||||
bool testnet;
|
||||
struct pubkey commitkey, outkey;
|
||||
@ -40,6 +40,8 @@ int main(int argc, char *argv[])
|
||||
min_confirms = 3;
|
||||
/* We only need this for involuntary close, so make it larger. */
|
||||
commit_tx_fee = 100000;
|
||||
/* Don't let them waste too much of our money if they abort. */
|
||||
escape_fee = 10000;
|
||||
/* This means we have ~1 day before they can steal our money. */
|
||||
locktime_seconds = LOCKTIME_MIN + 24 * 60 * 60;
|
||||
|
||||
@ -53,6 +55,9 @@ int main(int argc, char *argv[])
|
||||
opt_register_arg("--commitment-fee=<bits>",
|
||||
opt_set_bits, opt_show_bits, &commit_tx_fee,
|
||||
"100's of satoshi to pay for commitment");
|
||||
opt_register_arg("--escape-fee=<bits>",
|
||||
opt_set_bits, opt_show_bits, &escape_fee,
|
||||
"100's of satoshi to pay for escape transactions");
|
||||
opt_register_arg("--locktime=<seconds>",
|
||||
opt_set_uintval, opt_show_uintval, &locktime_seconds,
|
||||
"Seconds to lock out our transaction redemption");
|
||||
@ -97,7 +102,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
pkt = openchannel_pkt(ctx, &revocation_hash, &commitkey, &outkey,
|
||||
commit_tx_fee, locktime_seconds, total_in,
|
||||
&escape_hash, min_confirms);
|
||||
&escape_hash, escape_fee, min_confirms);
|
||||
|
||||
if (!write_all(STDOUT_FILENO, pkt, pkt_totlen(pkt)))
|
||||
err(1, "Writing out packet");
|
||||
|
Loading…
Reference in New Issue
Block a user