input/size: split constants into confirmed/non-confirmed
This to more easily track mismatches if constants and get more accurate fee estimates for the two channel types. The non-anchor weight estimates will now be smaller, this is okay since these constants are only being used for fee estimation (and will now be more accurate).
This commit is contained in:
parent
56b61078c5
commit
fe71c905e5
@ -286,7 +286,7 @@ const (
|
||||
// - witness_script (to_remote_delayed_script)
|
||||
ToRemoteConfirmedWitnessSize = 1 + 1 + 73 + 1 + ToRemoteConfirmedScriptSize
|
||||
|
||||
// AcceptedHtlcScriptSize 143 bytes
|
||||
// AcceptedHtlcScriptSize 140 bytes
|
||||
// - OP_DUP: 1 byte
|
||||
// - OP_HASH160: 1 byte
|
||||
// - OP_DATA: 1 byte (RIPEMD160(SHA256(revocationkey)) length)
|
||||
@ -321,20 +321,18 @@ const (
|
||||
// - OP_DROP: 1 byte
|
||||
// - OP_CHECKSIG: 1 byte
|
||||
// - OP_ENDIF: 1 byte
|
||||
// - OP_1: 1 byte // These 3 extra bytes are used for both confirmed and regular
|
||||
// - OP_CSV: 1 byte // HTLC script types. The size won't be correct in all cases,
|
||||
// - OP_DROP: 1 byte // but it is just an upper bound used for fee estimation in any case.
|
||||
// - OP_1: 1 byte // These 3 extra bytes are only
|
||||
// - OP_CSV: 1 byte // present for the confirmed
|
||||
// - OP_DROP: 1 byte // HTLC script types.
|
||||
// - OP_ENDIF: 1 byte
|
||||
AcceptedHtlcScriptSize = 3*1 + 20 + 5*1 + 33 + 8*1 + 20 + 4*1 +
|
||||
33 + 5*1 + 4 + 8*1
|
||||
33 + 5*1 + 4 + 5*1
|
||||
|
||||
// AcceptedHtlcScriptSizeConfirmed 143 bytes
|
||||
//
|
||||
// TODO(halseth): the non-confirmed version currently includes the
|
||||
// overhead.
|
||||
AcceptedHtlcScriptSizeConfirmed = AcceptedHtlcScriptSize // + HtlcConfirmedScriptOverhead
|
||||
AcceptedHtlcScriptSizeConfirmed = AcceptedHtlcScriptSize +
|
||||
HtlcConfirmedScriptOverhead
|
||||
|
||||
// AcceptedHtlcTimeoutWitnessSize 219
|
||||
// AcceptedHtlcTimeoutWitnessSize 216
|
||||
// - number_of_witness_elements: 1 byte
|
||||
// - sender_sig_length: 1 byte
|
||||
// - sender_sig: 73 bytes
|
||||
@ -343,7 +341,11 @@ const (
|
||||
// - witness_script: (accepted_htlc_script)
|
||||
AcceptedHtlcTimeoutWitnessSize = 1 + 1 + 73 + 1 + 1 + AcceptedHtlcScriptSize
|
||||
|
||||
// AcceptedHtlcPenaltyWitnessSize 252 bytes
|
||||
// AcceptedHtlcTimeoutWitnessSizeConfirmed 219 bytes
|
||||
AcceptedHtlcTimeoutWitnessSizeConfirmed = 1 + 1 + 73 + 1 + 1 +
|
||||
AcceptedHtlcScriptSizeConfirmed
|
||||
|
||||
// AcceptedHtlcPenaltyWitnessSize 249 bytes
|
||||
// - number_of_witness_elements: 1 byte
|
||||
// - revocation_sig_length: 1 byte
|
||||
// - revocation_sig: 73 bytes
|
||||
@ -353,7 +355,11 @@ const (
|
||||
// - witness_script (accepted_htlc_script)
|
||||
AcceptedHtlcPenaltyWitnessSize = 1 + 1 + 73 + 1 + 33 + 1 + AcceptedHtlcScriptSize
|
||||
|
||||
// AcceptedHtlcSuccessWitnessSize 322 bytes
|
||||
// AcceptedHtlcPenaltyWitnessSizeConfirmed 252 bytes
|
||||
AcceptedHtlcPenaltyWitnessSizeConfirmed = 1 + 1 + 73 + 1 + 33 + 1 +
|
||||
AcceptedHtlcScriptSizeConfirmed
|
||||
|
||||
// AcceptedHtlcSuccessWitnessSize 319 bytes
|
||||
// - number_of_witness_elements: 1 byte
|
||||
// - nil_length: 1 byte
|
||||
// - sig_alice_length: 1 byte
|
||||
@ -364,16 +370,18 @@ const (
|
||||
// - preimage: 32 bytes
|
||||
// - witness_script_length: 1 byte
|
||||
// - witness_script (accepted_htlc_script)
|
||||
//
|
||||
// Input to second level success tx, spending non-delayed HTLC output.
|
||||
AcceptedHtlcSuccessWitnessSize = 1 + 1 + 1 + 73 + 1 + 73 + 1 + 32 + 1 +
|
||||
AcceptedHtlcScriptSize
|
||||
|
||||
// AcceptedHtlcSuccessWitnessSizeConfirmed 327 bytes
|
||||
// AcceptedHtlcSuccessWitnessSizeConfirmed 322 bytes
|
||||
//
|
||||
// Input to second level success tx, spending 1 CSV delayed HTLC output.
|
||||
AcceptedHtlcSuccessWitnessSizeConfirmed = 1 + 1 + 1 + 73 + 1 + 73 + 1 + 32 + 1 +
|
||||
AcceptedHtlcScriptSizeConfirmed
|
||||
|
||||
// OfferedHtlcScriptSize 136 bytes
|
||||
// OfferedHtlcScriptSize 133 bytes
|
||||
// - OP_DUP: 1 byte
|
||||
// - OP_HASH160: 1 byte
|
||||
// - OP_DATA: 1 byte (RIPEMD160(SHA256(revocationkey)) length)
|
||||
@ -404,19 +412,17 @@ const (
|
||||
// - OP_EQUALVERIFY: 1 byte
|
||||
// - OP_CHECKSIG: 1 byte
|
||||
// - OP_ENDIF: 1 byte
|
||||
// - OP_1: 1 byte
|
||||
// - OP_CSV: 1 byte
|
||||
// - OP_DROP: 1 byte
|
||||
// - OP_1: 1 byte // These 3 extra bytes are only
|
||||
// - OP_CSV: 1 byte // present for the confirmed
|
||||
// - OP_DROP: 1 byte // HTLC script types.
|
||||
// - OP_ENDIF: 1 byte
|
||||
OfferedHtlcScriptSize = 3*1 + 20 + 5*1 + 33 + 10*1 + 33 + 5*1 + 20 + 7*1
|
||||
OfferedHtlcScriptSize = 3*1 + 20 + 5*1 + 33 + 10*1 + 33 + 5*1 + 20 + 4*1
|
||||
|
||||
// OfferedHtlcScriptSizeConfirmed 136 bytes
|
||||
//
|
||||
// TODO(halseth): the non-confirmed version currently includes the
|
||||
// overhead.
|
||||
OfferedHtlcScriptSizeConfirmed = OfferedHtlcScriptSize // + HtlcConfirmedScriptOverhead
|
||||
OfferedHtlcScriptSizeConfirmed = OfferedHtlcScriptSize +
|
||||
HtlcConfirmedScriptOverhead
|
||||
|
||||
// OfferedHtlcSuccessWitnessSize 245 bytes
|
||||
// OfferedHtlcSuccessWitnessSize 242 bytes
|
||||
// - number_of_witness_elements: 1 byte
|
||||
// - receiver_sig_length: 1 byte
|
||||
// - receiver_sig: 73 bytes
|
||||
@ -426,7 +432,11 @@ const (
|
||||
// - witness_script (offered_htlc_script)
|
||||
OfferedHtlcSuccessWitnessSize = 1 + 1 + 73 + 1 + 32 + 1 + OfferedHtlcScriptSize
|
||||
|
||||
// OfferedHtlcTimeoutWitnessSize 285 bytes
|
||||
// OfferedHtlcSuccessWitnessSizeConfirmed 245 bytes
|
||||
OfferedHtlcSuccessWitnessSizeConfirmed = 1 + 1 + 73 + 1 + 32 + 1 +
|
||||
OfferedHtlcScriptSizeConfirmed
|
||||
|
||||
// OfferedHtlcTimeoutWitnessSize 282 bytes
|
||||
// - number_of_witness_elements: 1 byte
|
||||
// - nil_length: 1 byte
|
||||
// - sig_alice_length: 1 byte
|
||||
@ -436,15 +446,18 @@ const (
|
||||
// - nil_length: 1 byte
|
||||
// - witness_script_length: 1 byte
|
||||
// - witness_script (offered_htlc_script)
|
||||
OfferedHtlcTimeoutWitnessSize = 1 + 1 + 1 + 73 + 1 + 73 + 1 + 1 + OfferedHtlcScriptSize
|
||||
//
|
||||
// Input to second level timeout tx, spending non-delayed HTLC output.
|
||||
OfferedHtlcTimeoutWitnessSize = 1 + 1 + 1 + 73 + 1 + 73 + 1 + 1 +
|
||||
OfferedHtlcScriptSize
|
||||
|
||||
// OfferedHtlcTimeoutWitnessSizeConfirmed 288 bytes
|
||||
// OfferedHtlcTimeoutWitnessSizeConfirmed 285 bytes
|
||||
//
|
||||
// Input to second level timeout tx, spending 1 CSV delayed HTLC output.
|
||||
OfferedHtlcTimeoutWitnessSizeConfirmed = 1 + 1 + 1 + 73 + 1 + 73 + 1 + 1 +
|
||||
OfferedHtlcScriptSizeConfirmed
|
||||
|
||||
// OfferedHtlcPenaltyWitnessSize 246 bytes
|
||||
// OfferedHtlcPenaltyWitnessSize 243 bytes
|
||||
// - number_of_witness_elements: 1 byte
|
||||
// - revocation_sig_length: 1 byte
|
||||
// - revocation_sig: 73 bytes
|
||||
@ -454,6 +467,10 @@ const (
|
||||
// - witness_script (offered_htlc_script)
|
||||
OfferedHtlcPenaltyWitnessSize = 1 + 1 + 73 + 1 + 33 + 1 + OfferedHtlcScriptSize
|
||||
|
||||
// OfferedHtlcPenaltyWitnessSizeConfirmed 246 bytes
|
||||
OfferedHtlcPenaltyWitnessSizeConfirmed = 1 + 1 + 73 + 1 + 33 + 1 +
|
||||
OfferedHtlcScriptSizeConfirmed
|
||||
|
||||
// AnchorScriptSize 40 bytes
|
||||
// - pubkey_length: 1 byte
|
||||
// - pubkey: 33 bytes
|
||||
|
@ -485,7 +485,7 @@ var witnessSizeTests = []witnessSizeTest{
|
||||
},
|
||||
{
|
||||
name: "offered htlc revoke",
|
||||
expSize: input.OfferedHtlcPenaltyWitnessSize - 3,
|
||||
expSize: input.OfferedHtlcPenaltyWitnessSize,
|
||||
genWitness: func(t *testing.T) wire.TxWitness {
|
||||
witScript, err := input.SenderHTLCScript(
|
||||
testPubkey, testPubkey, testPubkey,
|
||||
@ -515,7 +515,7 @@ var witnessSizeTests = []witnessSizeTest{
|
||||
},
|
||||
{
|
||||
name: "offered htlc revoke confirmed",
|
||||
expSize: input.OfferedHtlcPenaltyWitnessSize,
|
||||
expSize: input.OfferedHtlcPenaltyWitnessSizeConfirmed,
|
||||
genWitness: func(t *testing.T) wire.TxWitness {
|
||||
hash := make([]byte, 20)
|
||||
|
||||
@ -547,7 +547,7 @@ var witnessSizeTests = []witnessSizeTest{
|
||||
},
|
||||
{
|
||||
name: "offered htlc timeout",
|
||||
expSize: input.OfferedHtlcTimeoutWitnessSize - 3,
|
||||
expSize: input.OfferedHtlcTimeoutWitnessSize,
|
||||
genWitness: func(t *testing.T) wire.TxWitness {
|
||||
witScript, err := input.SenderHTLCScript(
|
||||
testPubkey, testPubkey, testPubkey,
|
||||
@ -574,7 +574,7 @@ var witnessSizeTests = []witnessSizeTest{
|
||||
},
|
||||
{
|
||||
name: "offered htlc timeout confirmed",
|
||||
expSize: input.OfferedHtlcTimeoutWitnessSize,
|
||||
expSize: input.OfferedHtlcTimeoutWitnessSizeConfirmed,
|
||||
genWitness: func(t *testing.T) wire.TxWitness {
|
||||
witScript, err := input.SenderHTLCScript(
|
||||
testPubkey, testPubkey, testPubkey,
|
||||
@ -601,7 +601,7 @@ var witnessSizeTests = []witnessSizeTest{
|
||||
},
|
||||
{
|
||||
name: "offered htlc success",
|
||||
expSize: input.OfferedHtlcSuccessWitnessSize - 3,
|
||||
expSize: input.OfferedHtlcSuccessWitnessSize,
|
||||
genWitness: func(t *testing.T) wire.TxWitness {
|
||||
witScript, err := input.SenderHTLCScript(
|
||||
testPubkey, testPubkey, testPubkey,
|
||||
@ -627,7 +627,7 @@ var witnessSizeTests = []witnessSizeTest{
|
||||
},
|
||||
{
|
||||
name: "offered htlc success confirmed",
|
||||
expSize: input.OfferedHtlcSuccessWitnessSize,
|
||||
expSize: input.OfferedHtlcSuccessWitnessSizeConfirmed,
|
||||
genWitness: func(t *testing.T) wire.TxWitness {
|
||||
witScript, err := input.SenderHTLCScript(
|
||||
testPubkey, testPubkey, testPubkey,
|
||||
@ -653,7 +653,7 @@ var witnessSizeTests = []witnessSizeTest{
|
||||
},
|
||||
{
|
||||
name: "accepted htlc revoke",
|
||||
expSize: input.AcceptedHtlcPenaltyWitnessSize - 3,
|
||||
expSize: input.AcceptedHtlcPenaltyWitnessSize,
|
||||
genWitness: func(t *testing.T) wire.TxWitness {
|
||||
witScript, err := input.ReceiverHTLCScript(
|
||||
testCLTVExpiry, testPubkey, testPubkey,
|
||||
@ -683,7 +683,7 @@ var witnessSizeTests = []witnessSizeTest{
|
||||
},
|
||||
{
|
||||
name: "accepted htlc revoke confirmed",
|
||||
expSize: input.AcceptedHtlcPenaltyWitnessSize,
|
||||
expSize: input.AcceptedHtlcPenaltyWitnessSizeConfirmed,
|
||||
genWitness: func(t *testing.T) wire.TxWitness {
|
||||
witScript, err := input.ReceiverHTLCScript(
|
||||
testCLTVExpiry, testPubkey, testPubkey,
|
||||
@ -713,7 +713,7 @@ var witnessSizeTests = []witnessSizeTest{
|
||||
},
|
||||
{
|
||||
name: "accepted htlc timeout",
|
||||
expSize: input.AcceptedHtlcTimeoutWitnessSize - 3,
|
||||
expSize: input.AcceptedHtlcTimeoutWitnessSize,
|
||||
genWitness: func(t *testing.T) wire.TxWitness {
|
||||
|
||||
witScript, err := input.ReceiverHTLCScript(
|
||||
@ -741,7 +741,7 @@ var witnessSizeTests = []witnessSizeTest{
|
||||
},
|
||||
{
|
||||
name: "accepted htlc timeout confirmed",
|
||||
expSize: input.AcceptedHtlcTimeoutWitnessSize,
|
||||
expSize: input.AcceptedHtlcTimeoutWitnessSizeConfirmed,
|
||||
genWitness: func(t *testing.T) wire.TxWitness {
|
||||
witScript, err := input.ReceiverHTLCScript(
|
||||
testCLTVExpiry, testPubkey, testPubkey,
|
||||
@ -768,7 +768,7 @@ var witnessSizeTests = []witnessSizeTest{
|
||||
},
|
||||
{
|
||||
name: "accepted htlc success",
|
||||
expSize: input.AcceptedHtlcSuccessWitnessSize - 3,
|
||||
expSize: input.AcceptedHtlcSuccessWitnessSize,
|
||||
genWitness: func(t *testing.T) wire.TxWitness {
|
||||
witScript, err := input.ReceiverHTLCScript(
|
||||
testCLTVExpiry, testPubkey, testPubkey,
|
||||
@ -798,7 +798,7 @@ var witnessSizeTests = []witnessSizeTest{
|
||||
},
|
||||
{
|
||||
name: "accepted htlc success confirmed",
|
||||
expSize: input.AcceptedHtlcSuccessWitnessSize,
|
||||
expSize: input.AcceptedHtlcSuccessWitnessSizeConfirmed,
|
||||
genWitness: func(t *testing.T) wire.TxWitness {
|
||||
witScript, err := input.ReceiverHTLCScript(
|
||||
testCLTVExpiry, testPubkey, testPubkey,
|
||||
|
@ -15,7 +15,7 @@ var (
|
||||
input.HtlcOfferedRemoteTimeout,
|
||||
input.WitnessKeyHash,
|
||||
}
|
||||
expectedWeight = int64(1463)
|
||||
expectedWeight = int64(1460)
|
||||
expectedSummary = "0000000000000000000000000000000000000000000000000000000000000000:10 (CommitmentTimeLock), " +
|
||||
"0000000000000000000000000000000000000000000000000000000000000001:11 (HtlcAcceptedSuccessSecondLevel), " +
|
||||
"0000000000000000000000000000000000000000000000000000000000000002:12 (HtlcOfferedRemoteTimeout), " +
|
||||
|
Loading…
Reference in New Issue
Block a user