mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-10 07:32:38 +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) {
|
||||
|
Reference in New Issue
Block a user