2015-08-19 12:41:18 +02:00
|
|
|
syntax = "proto2";
|
|
|
|
|
2015-05-26 06:38:12 +02:00
|
|
|
// The outer layer handles encryption, authentication and message
|
|
|
|
// boundaries.
|
|
|
|
|
|
|
|
//
|
|
|
|
// Helper Types
|
|
|
|
//
|
|
|
|
|
2015-06-01 04:26:09 +02:00
|
|
|
// Protobufs don't have fixed-length fields, so these are a hack.
|
2015-05-26 06:38:12 +02:00
|
|
|
message sha256_hash {
|
|
|
|
required fixed64 a = 1;
|
|
|
|
required fixed64 b = 2;
|
|
|
|
required fixed64 c = 3;
|
|
|
|
required fixed64 d = 4;
|
|
|
|
}
|
|
|
|
|
2016-06-28 23:19:20 +02:00
|
|
|
message rval {
|
|
|
|
required fixed64 a = 1;
|
|
|
|
required fixed64 b = 2;
|
|
|
|
required fixed64 c = 3;
|
|
|
|
required fixed64 d = 4;
|
|
|
|
}
|
|
|
|
|
2015-06-01 04:26:09 +02:00
|
|
|
message signature {
|
|
|
|
required fixed64 r1 = 1;
|
|
|
|
required fixed64 r2 = 2;
|
|
|
|
required fixed64 r3 = 3;
|
|
|
|
required fixed64 r4 = 4;
|
|
|
|
required fixed64 s1 = 5;
|
|
|
|
required fixed64 s2 = 6;
|
|
|
|
required fixed64 s3 = 7;
|
|
|
|
required fixed64 s4 = 8;
|
|
|
|
}
|
|
|
|
|
2015-08-07 05:15:30 +02:00
|
|
|
message locktime {
|
|
|
|
oneof locktime {
|
|
|
|
uint32 seconds = 1;
|
|
|
|
uint32 blocks = 2;
|
|
|
|
}
|
2015-09-24 07:32:46 +02:00
|
|
|
}
|
2015-08-07 05:15:30 +02:00
|
|
|
|
2015-05-28 23:38:27 +02:00
|
|
|
// Pubkey for commitment transaction input.
|
|
|
|
message bitcoin_pubkey {
|
2016-03-30 08:24:16 +02:00
|
|
|
// Must be 33 bytes.
|
2015-05-28 23:38:27 +02:00
|
|
|
required bytes key = 1;
|
2015-08-07 05:15:30 +02:00
|
|
|
}
|
2015-05-28 23:38:27 +02:00
|
|
|
|
2015-09-24 07:32:46 +02:00
|
|
|
// How much a node charges (or pays!) for sending.
|
|
|
|
message funding {
|
|
|
|
// Base amount (in satoshi).
|
|
|
|
optional int64 fixed = 1 [ default = 0 ];
|
|
|
|
// This is charge per millionth of a satoshi.
|
|
|
|
optional int32 per_micro_satoshi = 2 [ default = 0 ];
|
|
|
|
}
|
|
|
|
|
2015-05-26 06:38:12 +02:00
|
|
|
//
|
|
|
|
// Packet Types
|
|
|
|
//
|
|
|
|
|
2016-01-21 21:11:48 +01:00
|
|
|
// Set channel params.
|
|
|
|
message authenticate {
|
|
|
|
// Which node this is.
|
|
|
|
required bitcoin_pubkey node_id = 1;
|
|
|
|
// Signature of your session key. */
|
|
|
|
required signature session_sig = 2;
|
2016-08-09 05:41:11 +02:00
|
|
|
// How many update_commit and update_revocation messages already received
|
|
|
|
optional uint64 ack = 3 [ default = 0 ];
|
2016-01-21 21:11:48 +01:00
|
|
|
};
|
|
|
|
|
2015-05-26 06:38:12 +02:00
|
|
|
// Set channel params.
|
|
|
|
message open_channel {
|
|
|
|
// Relative locktime for outputs going to us.
|
2015-09-24 07:32:54 +02:00
|
|
|
required locktime delay = 1;
|
2015-07-29 08:44:28 +02:00
|
|
|
// Hash for revoking first commitment transaction.
|
2015-09-24 07:32:54 +02:00
|
|
|
required sha256_hash revocation_hash = 2;
|
2016-03-15 07:38:35 +01:00
|
|
|
// Hash for revoking second commitment transaction.
|
|
|
|
required sha256_hash next_revocation_hash = 8;
|
2015-07-29 04:30:50 +02:00
|
|
|
// Pubkey for anchor to pay into commitment tx.
|
2015-09-24 07:32:54 +02:00
|
|
|
required bitcoin_pubkey commit_key = 3;
|
2015-05-28 23:38:27 +02:00
|
|
|
// How to pay money to us from commit_tx.
|
2015-09-24 07:32:54 +02:00
|
|
|
required bitcoin_pubkey final_key = 4;
|
2015-07-29 08:44:28 +02:00
|
|
|
|
|
|
|
enum anchor_offer {
|
|
|
|
// I will create the anchor
|
|
|
|
WILL_CREATE_ANCHOR = 1;
|
|
|
|
// I won't create the anchor
|
|
|
|
WONT_CREATE_ANCHOR = 2;
|
|
|
|
}
|
2015-09-24 07:32:54 +02:00
|
|
|
required anchor_offer anch = 5;
|
2015-07-29 08:44:28 +02:00
|
|
|
|
|
|
|
// How far must anchor be buried before we consider channel live?
|
2015-09-24 07:32:54 +02:00
|
|
|
optional uint32 min_depth = 6 [ default = 0 ];
|
2015-07-29 08:46:24 +02:00
|
|
|
|
|
|
|
// How much fee would I like on commitment tx?
|
2016-03-24 02:42:43 +01:00
|
|
|
required uint64 initial_fee_rate = 7;
|
2015-05-26 06:38:12 +02:00
|
|
|
}
|
|
|
|
|
2015-07-29 08:44:28 +02:00
|
|
|
// Whoever is supplying anchor sends this.
|
|
|
|
message open_anchor {
|
|
|
|
// Transaction ID of anchor.
|
|
|
|
required sha256_hash txid = 1;
|
|
|
|
// Which output is going to the 2 of 2.
|
|
|
|
required uint32 output_index = 2;
|
|
|
|
// Amount of anchor output.
|
|
|
|
required uint64 amount = 3;
|
2015-05-26 06:38:12 +02:00
|
|
|
}
|
|
|
|
|
2015-07-29 08:44:28 +02:00
|
|
|
// Reply: signature for your initial commitment tx
|
|
|
|
message open_commit_sig {
|
|
|
|
required signature sig = 1;
|
2015-05-28 23:38:27 +02:00
|
|
|
}
|
|
|
|
|
2015-07-29 08:44:28 +02:00
|
|
|
// Indicates we've seen anchor reach min-depth.
|
2015-05-26 06:38:12 +02:00
|
|
|
message open_complete {
|
|
|
|
// Block it went into.
|
|
|
|
optional sha256_hash blockid = 1;
|
|
|
|
// FIXME: add a merkle proof plus block headers here?
|
|
|
|
}
|
|
|
|
|
2016-06-28 23:19:21 +02:00
|
|
|
message route_step {
|
|
|
|
// Where to next?
|
|
|
|
oneof next {
|
|
|
|
// Actually, this is the last one
|
|
|
|
bool end = 1;
|
|
|
|
// Next lightning node.
|
|
|
|
bitcoin_pubkey bitcoin = 2;
|
|
|
|
// Other realms go here...
|
|
|
|
}
|
|
|
|
|
|
|
|
// How much to forward (difference is fee)
|
|
|
|
required uint32 amount = 4;
|
|
|
|
};
|
|
|
|
|
|
|
|
message route {
|
|
|
|
repeated route_step steps = 1;
|
|
|
|
};
|
|
|
|
|
2016-03-31 08:43:20 +02:00
|
|
|
message routing {
|
|
|
|
required bytes info = 1;
|
|
|
|
}
|
|
|
|
|
2015-08-07 05:15:30 +02:00
|
|
|
// Start a new commitment tx to add an HTLC me -> you.
|
|
|
|
message update_add_htlc {
|
2016-03-31 08:43:20 +02:00
|
|
|
// Unique identifier for this HTLC.
|
|
|
|
required uint64 id = 1;
|
2015-09-24 07:30:47 +02:00
|
|
|
// Amount for htlc (millisatoshi)
|
|
|
|
required uint32 amount_msat = 2;
|
2015-08-07 05:15:30 +02:00
|
|
|
// Hash for HTLC R value.
|
|
|
|
required sha256_hash r_hash = 3;
|
|
|
|
// Time at which HTLC expires (absolute)
|
2015-08-07 05:15:30 +02:00
|
|
|
required locktime expiry = 4;
|
2016-03-31 08:43:20 +02:00
|
|
|
// Onion-wrapped routing information.
|
|
|
|
required routing route = 5;
|
2015-09-24 07:32:46 +02:00
|
|
|
}
|
|
|
|
|
2015-09-24 07:32:49 +02:00
|
|
|
// Complete your HTLC: I have the R value, pay me!
|
2015-09-25 04:21:18 +02:00
|
|
|
message update_fulfill_htlc {
|
2016-03-31 08:43:20 +02:00
|
|
|
// Which HTLC
|
|
|
|
required uint64 id = 1;
|
2015-08-07 05:15:30 +02:00
|
|
|
// HTLC R value.
|
2016-06-28 23:19:20 +02:00
|
|
|
required rval r = 2;
|
2015-08-07 05:15:30 +02:00
|
|
|
}
|
|
|
|
|
2016-03-31 08:43:20 +02:00
|
|
|
// FIXME: Failure information.
|
|
|
|
message fail_reason {
|
|
|
|
required bytes info = 1;
|
2015-08-07 05:15:30 +02:00
|
|
|
}
|
|
|
|
|
2016-03-31 08:43:20 +02:00
|
|
|
message update_fail_htlc {
|
|
|
|
// Which HTLC
|
|
|
|
required uint64 id = 1;
|
|
|
|
// Reason for failure (for relay to initial node)
|
|
|
|
required fail_reason reason = 2;
|
2015-06-10 13:02:43 +02:00
|
|
|
}
|
|
|
|
|
2016-05-26 07:55:24 +02:00
|
|
|
// Commit all the staged changes.
|
2016-03-31 08:43:20 +02:00
|
|
|
message update_commit {
|
2015-06-10 13:02:43 +02:00
|
|
|
// Signature for your new commitment tx.
|
|
|
|
required signature sig = 1;
|
2015-05-26 06:38:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Complete the update.
|
2016-03-31 08:43:20 +02:00
|
|
|
message update_revocation {
|
2015-05-26 06:38:12 +02:00
|
|
|
// Hash preimage which revokes old commitment tx.
|
|
|
|
required sha256_hash revocation_preimage = 1;
|
2016-03-31 08:43:20 +02:00
|
|
|
// Revocation hash for my next commit transaction
|
|
|
|
required sha256_hash next_revocation_hash = 2;
|
2015-05-26 06:38:12 +02:00
|
|
|
}
|
|
|
|
|
2016-03-24 02:39:41 +01:00
|
|
|
// Start clearing out the channel HTLCs so we can close it
|
|
|
|
message close_clearing {
|
2016-04-24 12:31:52 +02:00
|
|
|
// Output script for mutual close tx.
|
|
|
|
required bytes scriptPubkey = 1;
|
2015-05-26 06:38:12 +02:00
|
|
|
}
|
|
|
|
|
2016-03-24 02:39:41 +01:00
|
|
|
message close_signature {
|
|
|
|
// Fee in satoshis.
|
|
|
|
required uint64 close_fee = 1;
|
|
|
|
// Signature on the close transaction.
|
|
|
|
required signature sig = 2;
|
2015-09-24 07:32:52 +02:00
|
|
|
}
|
|
|
|
|
2015-05-26 06:38:12 +02:00
|
|
|
// This means we're going to hang up; it's to help diagnose only!
|
|
|
|
message error {
|
|
|
|
optional string problem = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is the union which defines all of them
|
|
|
|
message pkt {
|
|
|
|
oneof pkt {
|
2016-01-21 21:11:48 +01:00
|
|
|
// Start of connection
|
|
|
|
authenticate auth = 50;
|
2015-05-26 06:38:12 +02:00
|
|
|
// Opening
|
2015-09-24 07:32:54 +02:00
|
|
|
open_channel open = 20;
|
|
|
|
open_anchor open_anchor = 21;
|
|
|
|
open_commit_sig open_commit_sig = 22;
|
|
|
|
open_complete open_complete = 23;
|
2015-05-26 06:38:12 +02:00
|
|
|
// Updating (most common)
|
2015-08-07 05:15:30 +02:00
|
|
|
update_add_htlc update_add_htlc = 2;
|
2016-03-31 08:43:20 +02:00
|
|
|
update_fulfill_htlc update_fulfill_htlc = 3;
|
|
|
|
update_fail_htlc update_fail_htlc = 4;
|
|
|
|
update_commit update_commit = 5;
|
|
|
|
update_revocation update_revocation = 6;
|
|
|
|
|
2015-05-26 06:38:12 +02:00
|
|
|
// Closing
|
2016-03-24 02:39:41 +01:00
|
|
|
close_clearing close_clearing = 30;
|
|
|
|
close_signature close_signature = 31;
|
2015-05-26 06:38:12 +02:00
|
|
|
|
|
|
|
// Unexpected issue.
|
2015-09-24 07:32:54 +02:00
|
|
|
error error = 40;
|
2015-05-26 06:38:12 +02:00
|
|
|
}
|
|
|
|
}
|