mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
lnwallet: move lockTimeToSequence to script_utils.go
This commit is contained in:
parent
fa05ee9a22
commit
81a4887d11
@ -597,22 +597,3 @@ func createCommitTx(fundingOutput *wire.TxIn, selfKey, theirKey *btcec.PublicKey
|
||||
|
||||
return commitTx, nil
|
||||
}
|
||||
|
||||
// lockTimeToSequence converts the passed relative locktime to a sequence
|
||||
// number in accordance to BIP-68.
|
||||
// See: https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki
|
||||
// * (Compatibility)
|
||||
func lockTimeToSequence(isSeconds bool, locktime uint32) uint32 {
|
||||
if !isSeconds {
|
||||
// The locktime is to be expressed in confirmations. Apply the
|
||||
// mask to restrict the number of confirmations to 65,535 or
|
||||
// 1.25 years.
|
||||
return SequenceLockTimeMask & locktime
|
||||
}
|
||||
|
||||
// Set the 22nd bit which indicates the lock time is in seconds, then
|
||||
// shift the locktime over by 9 since the time granularity is in
|
||||
// 512-second intervals (2^9). This results in a max lock-time of
|
||||
// 33,554,431 seconds, or 1.06 years.
|
||||
return SequenceLockTimeSeconds | (locktime >> 9)
|
||||
}
|
||||
|
@ -212,6 +212,25 @@ func receiverHTLCScript(absoluteTimeout, relativeTimeout uint32, senderKey,
|
||||
return builder.Script()
|
||||
}
|
||||
|
||||
// lockTimeToSequence converts the passed relative locktime to a sequence
|
||||
// number in accordance to BIP-68.
|
||||
// See: https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki
|
||||
// * (Compatibility)
|
||||
func lockTimeToSequence(isSeconds bool, locktime uint32) uint32 {
|
||||
if !isSeconds {
|
||||
// The locktime is to be expressed in confirmations. Apply the
|
||||
// mask to restrict the number of confirmations to 65,535 or
|
||||
// 1.25 years.
|
||||
return SequenceLockTimeMask & locktime
|
||||
}
|
||||
|
||||
// Set the 22nd bit which indicates the lock time is in seconds, then
|
||||
// shift the locktime over by 9 since the time granularity is in
|
||||
// 512-second intervals (2^9). This results in a max lock-time of
|
||||
// 33,554,431 seconds, or 1.06 years.
|
||||
return SequenceLockTimeSeconds | (locktime >> 9)
|
||||
}
|
||||
|
||||
// commitScriptToSelf constructs the public key script for the output on the
|
||||
// commitment transaction paying to the "owner" of said commitment transaction.
|
||||
// If the other party learns of the pre-image to the revocation hash, then they
|
||||
|
Loading…
Reference in New Issue
Block a user