Merge pull request #1617 from cfromknecht/to-local-script-size
lnwallet/size: correct commit to-local and 2nd stage script/witness sizes
This commit is contained in:
commit
8cd6eebadc
@ -8,17 +8,17 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
|
"github.com/btcsuite/btcd/blockchain"
|
||||||
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
|
"github.com/btcsuite/btcd/txscript"
|
||||||
|
"github.com/btcsuite/btcd/wire"
|
||||||
|
"github.com/btcsuite/btcutil"
|
||||||
"github.com/coreos/bbolt"
|
"github.com/coreos/bbolt"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
"github.com/btcsuite/btcd/blockchain"
|
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
|
||||||
"github.com/btcsuite/btcd/txscript"
|
|
||||||
"github.com/btcsuite/btcd/wire"
|
|
||||||
"github.com/btcsuite/btcutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -993,7 +993,7 @@ func (b *breachArbiter) createJusticeTx(
|
|||||||
witnessWeight = lnwallet.AcceptedHtlcPenaltyWitnessSize
|
witnessWeight = lnwallet.AcceptedHtlcPenaltyWitnessSize
|
||||||
|
|
||||||
case lnwallet.HtlcSecondLevelRevoke:
|
case lnwallet.HtlcSecondLevelRevoke:
|
||||||
witnessWeight = lnwallet.SecondLevelHtlcPenaltyWitnessSize
|
witnessWeight = lnwallet.ToLocalPenaltyWitnessSize
|
||||||
|
|
||||||
default:
|
default:
|
||||||
brarLog.Warnf("breached output in retribution info "+
|
brarLog.Warnf("breached output in retribution info "+
|
||||||
|
@ -186,22 +186,22 @@ const (
|
|||||||
// weight limits.
|
// weight limits.
|
||||||
MaxHTLCNumber = 966
|
MaxHTLCNumber = 966
|
||||||
|
|
||||||
// ToLocalScriptSize 83 bytes
|
// ToLocalScriptSize 79 bytes
|
||||||
// - OP_IF: 1 byte
|
// - OP_IF: 1 byte
|
||||||
// - OP_DATA: 1 byte (revocationkey length)
|
// - OP_DATA: 1 byte
|
||||||
// - revocationkey: 33 bytes
|
// - revoke_key: 33 bytes
|
||||||
// - OP_CHECKSIG: 1 byte
|
|
||||||
// - OP_ELSE: 1 byte
|
// - OP_ELSE: 1 byte
|
||||||
// - OP_DATA: 1 byte (localkey length)
|
// - OP_DATA: 1 byte
|
||||||
// - local_delay_key: 33 bytes
|
// - csv_delay: 4 bytes
|
||||||
// - OP_CHECKSIG_VERIFY: 1 byte
|
|
||||||
// - OP_DATA: 1 byte (delay length)
|
|
||||||
// - delay: 8 bytes
|
|
||||||
// - OP_CHECKSEQUENCEVERIFY: 1 byte
|
// - OP_CHECKSEQUENCEVERIFY: 1 byte
|
||||||
|
// - OP_DROP: 1 byte
|
||||||
|
// - OP_DATA: 1 byte
|
||||||
|
// - delay_key: 33 bytes
|
||||||
// - OP_ENDIF: 1 byte
|
// - OP_ENDIF: 1 byte
|
||||||
ToLocalScriptSize = 1 + 1 + 33 + 1 + 1 + 1 + 33 + 1 + 1 + 8 + 1 + 1
|
// - OP_CHECKSIG: 1 byte
|
||||||
|
ToLocalScriptSize = 1 + 1 + 33 + 1 + 1 + 4 + 1 + 1 + 1 + 33 + 1 + 1
|
||||||
|
|
||||||
// ToLocalTimeoutWitnessSize x bytes
|
// ToLocalTimeoutWitnessSize 156 bytes
|
||||||
// - number_of_witness_elements: 1 byte
|
// - number_of_witness_elements: 1 byte
|
||||||
// - local_delay_sig_length: 1 byte
|
// - local_delay_sig_length: 1 byte
|
||||||
// - local_delay_sig: 73 bytes
|
// - local_delay_sig: 73 bytes
|
||||||
@ -210,44 +210,15 @@ const (
|
|||||||
// - witness_script (to_local_script)
|
// - witness_script (to_local_script)
|
||||||
ToLocalTimeoutWitnessSize = 1 + 1 + 73 + 1 + 1 + ToLocalScriptSize
|
ToLocalTimeoutWitnessSize = 1 + 1 + 73 + 1 + 1 + ToLocalScriptSize
|
||||||
|
|
||||||
// ToLocalPenaltyWitnessSize 160 bytes
|
// ToLocalPenaltyWitnessSize 156 bytes
|
||||||
// - number_of_witness_elements: 1 byte
|
// - number_of_witness_elements: 1 byte
|
||||||
// - revocation_sig_length: 1 byte
|
// - revocation_sig_length: 1 byte
|
||||||
// - revocation_sig: 73 bytes
|
// - revocation_sig: 73 bytes
|
||||||
// - one_length: 1 byte
|
// - OP_TRUE: 1 byte
|
||||||
// - witness_script_length: 1 byte
|
// - witness_script_length: 1 byte
|
||||||
// - witness_script (to_local_script)
|
// - witness_script (to_local_script)
|
||||||
ToLocalPenaltyWitnessSize = 1 + 1 + 73 + 1 + 1 + ToLocalScriptSize
|
ToLocalPenaltyWitnessSize = 1 + 1 + 73 + 1 + 1 + ToLocalScriptSize
|
||||||
|
|
||||||
// SecondLevelHtlcScriptSize 73 bytes
|
|
||||||
// - OP_IF: 1 byte
|
|
||||||
// - OP_DATA: 1 byte
|
|
||||||
// - revoke_key: 33 bytes
|
|
||||||
// - OP_ELSE: 1 byte
|
|
||||||
// - csv_delay: 1 byte
|
|
||||||
// - OP_CHECKSEQUENCEVERIFY: 1 byte
|
|
||||||
// - OP_DROP: 1 byte
|
|
||||||
// - delay_key: 33 bytes
|
|
||||||
// - OP_ENDIF: 1 byte
|
|
||||||
// - OP_CHECKSIG: 1 byte
|
|
||||||
SecondLevelHtlcScriptSize = 73
|
|
||||||
|
|
||||||
// SecondLevelHtlcPenaltyWitnessSize 149 bytes
|
|
||||||
// - number_of_witness_elements: 1 byte
|
|
||||||
// - revoke_sig_length: 1 byte
|
|
||||||
// - revoke_sig: 73 bytes
|
|
||||||
// - OP_TRUE: 1 byte
|
|
||||||
// - witness_script (second_level_script_size)
|
|
||||||
SecondLevelHtlcPenaltyWitnessSize = 1 + 1 + 73 + 1 + SecondLevelHtlcScriptSize
|
|
||||||
|
|
||||||
// SecondLevelHtlcSuccessWitnessSize 149 bytes
|
|
||||||
// - number_of_witness_elements: 1 byte
|
|
||||||
// - success_sig_length: 1 byte
|
|
||||||
// - success_sig: 73 bytes
|
|
||||||
// - nil_length: 1 byte
|
|
||||||
// - witness_script (second_level_script_size)
|
|
||||||
SecondLevelHtlcSuccessWitnessSize = 1 + 1 + 73 + 1 + SecondLevelHtlcScriptSize
|
|
||||||
|
|
||||||
// AcceptedHtlcScriptSize 139 bytes
|
// AcceptedHtlcScriptSize 139 bytes
|
||||||
// - OP_DUP: 1 byte
|
// - OP_DUP: 1 byte
|
||||||
// - OP_HASH160: 1 byte
|
// - OP_HASH160: 1 byte
|
||||||
@ -286,14 +257,16 @@ const (
|
|||||||
AcceptedHtlcScriptSize = 3*1 + 20 + 5*1 + 33 + 7*1 + 20 + 4*1 +
|
AcceptedHtlcScriptSize = 3*1 + 20 + 5*1 + 33 + 7*1 + 20 + 4*1 +
|
||||||
33 + 5*1 + 4 + 5*1
|
33 + 5*1 + 4 + 5*1
|
||||||
|
|
||||||
// AcceptedHtlcTimeoutWitnessSize 214
|
// AcceptedHtlcTimeoutWitnessSize 216
|
||||||
// - number_of_witness_elements: 1 byte
|
// - number_of_witness_elements: 1 byte
|
||||||
|
// - sender_sig_length: 1 byte
|
||||||
// - sender_sig: 73 bytes
|
// - sender_sig: 73 bytes
|
||||||
// - nil_length: 1 byte
|
// - nil_length: 1 byte
|
||||||
|
// - witness_script_length: 1 byte
|
||||||
// - witness_script: (accepted_htlc_script)
|
// - witness_script: (accepted_htlc_script)
|
||||||
AcceptedHtlcTimeoutWitnessSize = 1 + 73 + 1 + AcceptedHtlcScriptSize
|
AcceptedHtlcTimeoutWitnessSize = 1 + 1 + 73 + 1 + 1 + AcceptedHtlcScriptSize
|
||||||
|
|
||||||
// AcceptedHtlcSuccessWitnessSize 325 bytes
|
// AcceptedHtlcSuccessWitnessSize 322 bytes
|
||||||
// - number_of_witness_elements: 1 byte
|
// - number_of_witness_elements: 1 byte
|
||||||
// - nil_length: 1 byte
|
// - nil_length: 1 byte
|
||||||
// - sig_alice_length: 1 byte
|
// - sig_alice_length: 1 byte
|
||||||
@ -362,15 +335,18 @@ const (
|
|||||||
// - witness_script (offered_htlc_script)
|
// - witness_script (offered_htlc_script)
|
||||||
OfferedHtlcTimeoutWitnessSize = 1 + 1 + 1 + 73 + 1 + 73 + 1 + 1 + OfferedHtlcScriptSize
|
OfferedHtlcTimeoutWitnessSize = 1 + 1 + 1 + 73 + 1 + 73 + 1 + 1 + OfferedHtlcScriptSize
|
||||||
|
|
||||||
// OfferedHtlcSuccessWitnessSize 283 bytes
|
// OfferedHtlcSuccessWitnessSize 317 bytes
|
||||||
// - number_of_witness_elements: 1 byte
|
// - number_of_witness_elements: 1 byte
|
||||||
// - nil_length: 1 byte
|
// - nil_length: 1 byte
|
||||||
|
// - receiver_sig_length: 1 byte
|
||||||
// - receiver_sig: 73 bytes
|
// - receiver_sig: 73 bytes
|
||||||
// - sender_sigs: 73 bytes
|
// - sender_sig_length: 1 byte
|
||||||
|
// - sender_sig: 73 bytes
|
||||||
|
// - payment_preimage_length: 1 byte
|
||||||
// - payment_preimage: 32 bytes
|
// - payment_preimage: 32 bytes
|
||||||
// - witness_script_length: 1 byte
|
// - witness_script_length: 1 byte
|
||||||
// - witness_script (offered_htlc_script)
|
// - witness_script (offered_htlc_script)
|
||||||
OfferedHtlcSuccessWitnessSize = 1 + 1 + 73 + 73 + 73 + 32 + 1 + OfferedHtlcScriptSize
|
OfferedHtlcSuccessWitnessSize = 1 + 1 + 1 + 73 + 1 + 73 + 1 + 32 + 1 + OfferedHtlcScriptSize
|
||||||
|
|
||||||
// OfferedHtlcPenaltyWitnessSize 243 bytes
|
// OfferedHtlcPenaltyWitnessSize 243 bytes
|
||||||
// - number_of_witness_elements: 1 byte
|
// - number_of_witness_elements: 1 byte
|
||||||
@ -380,7 +356,7 @@ const (
|
|||||||
// - revocation_key: 33 bytes
|
// - revocation_key: 33 bytes
|
||||||
// - witness_script_length: 1 byte
|
// - witness_script_length: 1 byte
|
||||||
// - witness_script (offered_htlc_script)
|
// - witness_script (offered_htlc_script)
|
||||||
OfferedHtlcPenaltyWitnessSize = 1 + 1 + 73 + 1 + 1 + OfferedHtlcScriptSize
|
OfferedHtlcPenaltyWitnessSize = 1 + 1 + 73 + 1 + 33 + 1 + OfferedHtlcScriptSize
|
||||||
)
|
)
|
||||||
|
|
||||||
// estimateCommitTxWeight estimate commitment transaction weight depending on
|
// estimateCommitTxWeight estimate commitment transaction weight depending on
|
||||||
|
@ -8,14 +8,14 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
|
||||||
"github.com/btcsuite/btcd/blockchain"
|
"github.com/btcsuite/btcd/blockchain"
|
||||||
"github.com/btcsuite/btcd/txscript"
|
"github.com/btcsuite/btcd/txscript"
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/btcsuite/btcutil"
|
"github.com/btcsuite/btcutil"
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SUMMARY OF OUTPUT STATES
|
// SUMMARY OF OUTPUT STATES
|
||||||
@ -962,7 +962,7 @@ func (u *utxoNursery) createSweepTx(kgtnOutputs []kidOutput,
|
|||||||
// sweep.
|
// sweep.
|
||||||
case lnwallet.HtlcOfferedTimeoutSecondLevel:
|
case lnwallet.HtlcOfferedTimeoutSecondLevel:
|
||||||
weightEstimate.AddWitnessInput(
|
weightEstimate.AddWitnessInput(
|
||||||
lnwallet.SecondLevelHtlcSuccessWitnessSize,
|
lnwallet.ToLocalTimeoutWitnessSize,
|
||||||
)
|
)
|
||||||
csvOutputs = append(csvOutputs, input)
|
csvOutputs = append(csvOutputs, input)
|
||||||
|
|
||||||
@ -971,7 +971,7 @@ func (u *utxoNursery) createSweepTx(kgtnOutputs []kidOutput,
|
|||||||
// sweep.
|
// sweep.
|
||||||
case lnwallet.HtlcAcceptedSuccessSecondLevel:
|
case lnwallet.HtlcAcceptedSuccessSecondLevel:
|
||||||
weightEstimate.AddWitnessInput(
|
weightEstimate.AddWitnessInput(
|
||||||
lnwallet.SecondLevelHtlcSuccessWitnessSize,
|
lnwallet.ToLocalTimeoutWitnessSize,
|
||||||
)
|
)
|
||||||
csvOutputs = append(csvOutputs, input)
|
csvOutputs = append(csvOutputs, input)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user