mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-27 21:27:44 +02:00
multi: replace DefaultDustLimit with script-specific DustLimitForSize
This commit updates call-sites to use the proper dust limits for various script types. This also updates the default dust limit used in the funding flow to be 354 satoshis instead of 573 satoshis.
This commit is contained in:
@@ -45,6 +45,55 @@ func WitnessScriptHash(witnessScript []byte) ([]byte, error) {
|
||||
return bldr.Script()
|
||||
}
|
||||
|
||||
// WitnessPubKeyHash generates a pay-to-witness-pubkey-hash public key script
|
||||
// paying to a version 0 witness program containing the passed serialized
|
||||
// public key.
|
||||
func WitnessPubKeyHash(pubkey []byte) ([]byte, error) {
|
||||
bldr := txscript.NewScriptBuilder()
|
||||
|
||||
bldr.AddOp(txscript.OP_0)
|
||||
pkhash := btcutil.Hash160(pubkey)
|
||||
bldr.AddData(pkhash)
|
||||
return bldr.Script()
|
||||
}
|
||||
|
||||
// GenerateP2SH generates a pay-to-script-hash public key script paying to the
|
||||
// passed redeem script.
|
||||
func GenerateP2SH(script []byte) ([]byte, error) {
|
||||
bldr := txscript.NewScriptBuilder()
|
||||
|
||||
bldr.AddOp(txscript.OP_HASH160)
|
||||
scripthash := btcutil.Hash160(script)
|
||||
bldr.AddData(scripthash)
|
||||
bldr.AddOp(txscript.OP_EQUAL)
|
||||
return bldr.Script()
|
||||
}
|
||||
|
||||
// GenerateP2PKH generates a pay-to-public-key-hash public key script paying to
|
||||
// the passed serialized public key.
|
||||
func GenerateP2PKH(pubkey []byte) ([]byte, error) {
|
||||
bldr := txscript.NewScriptBuilder()
|
||||
|
||||
bldr.AddOp(txscript.OP_DUP)
|
||||
bldr.AddOp(txscript.OP_HASH160)
|
||||
pkhash := btcutil.Hash160(pubkey)
|
||||
bldr.AddData(pkhash)
|
||||
bldr.AddOp(txscript.OP_EQUALVERIFY)
|
||||
bldr.AddOp(txscript.OP_CHECKSIG)
|
||||
return bldr.Script()
|
||||
}
|
||||
|
||||
// GenerateUnknownWitness generates the maximum-sized witness public key script
|
||||
// consisting of a version push and a 40-byte data push.
|
||||
func GenerateUnknownWitness() ([]byte, error) {
|
||||
bldr := txscript.NewScriptBuilder()
|
||||
|
||||
bldr.AddOp(txscript.OP_0)
|
||||
witnessScript := make([]byte, 40)
|
||||
bldr.AddData(witnessScript)
|
||||
return bldr.Script()
|
||||
}
|
||||
|
||||
// GenMultiSigScript generates the non-p2sh'd multisig script for 2 of 2
|
||||
// pubkeys.
|
||||
func GenMultiSigScript(aPub, bPub []byte) ([]byte, error) {
|
||||
|
@@ -41,11 +41,20 @@ const (
|
||||
// - P2WSHWitnessProgram: 34 bytes
|
||||
NestedP2WSHSize = 1 + P2WSHSize
|
||||
|
||||
// UnknownWitnessSize 42 bytes
|
||||
// - OP_x: 1 byte
|
||||
// - OP_DATA: 1 byte (max-size length)
|
||||
// - max-size: 40 bytes
|
||||
UnknownWitnessSize = 1 + 1 + 40
|
||||
|
||||
// P2PKHSize 25 bytes
|
||||
P2PKHSize = 25
|
||||
|
||||
// P2PKHOutputSize 34 bytes
|
||||
// - value: 8 bytes
|
||||
// - var_int: 1 byte (pkscript_length)
|
||||
// - pkscript (p2pkh): 25 bytes
|
||||
P2PKHOutputSize = 8 + 1 + 25
|
||||
P2PKHOutputSize = 8 + 1 + P2PKHSize
|
||||
|
||||
// P2WKHOutputSize 31 bytes
|
||||
// - value: 8 bytes
|
||||
@@ -59,11 +68,14 @@ const (
|
||||
// - pkscript (p2wsh): 34 bytes
|
||||
P2WSHOutputSize = 8 + 1 + P2WSHSize
|
||||
|
||||
// P2SHSize 23 bytes
|
||||
P2SHSize = 23
|
||||
|
||||
// P2SHOutputSize 32 bytes
|
||||
// - value: 8 bytes
|
||||
// - var_int: 1 byte (pkscript_length)
|
||||
// - pkscript (p2sh): 23 bytes
|
||||
P2SHOutputSize = 8 + 1 + 23
|
||||
P2SHOutputSize = 8 + 1 + P2SHSize
|
||||
|
||||
// P2PKHScriptSigSize 108 bytes
|
||||
// - OP_DATA: 1 byte (signature length)
|
||||
|
Reference in New Issue
Block a user