lnwallet: add more godoc to InputScript rename ScriptSig field to SigScript
This commit is contained in:
parent
73c9c2ee15
commit
bd9ebbd5af
@ -180,9 +180,10 @@ func (b *BtcWallet) SignOutputRaw(tx *wire.MsgTx,
|
||||
// TODO(roasbeef): generate sighash midstate if not present?
|
||||
|
||||
amt := signDesc.Output.Value
|
||||
sig, err := txscript.RawTxInWitnessSignature(tx, signDesc.SigHashes,
|
||||
signDesc.InputIndex, amt, witnessScript, signDesc.HashType,
|
||||
privKey)
|
||||
sig, err := txscript.RawTxInWitnessSignature(
|
||||
tx, signDesc.SigHashes, signDesc.InputIndex, amt,
|
||||
witnessScript, signDesc.HashType, privKey,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -227,8 +228,9 @@ func (b *BtcWallet) ComputeInputScript(tx *wire.MsgTx,
|
||||
// spend the p2sh output. The sigScript will contain only a
|
||||
// single push of the p2wkh witness program corresponding to
|
||||
// the matching public key of this address.
|
||||
p2wkhAddr, err := btcutil.NewAddressWitnessPubKeyHash(pubKeyHash,
|
||||
b.netParams)
|
||||
p2wkhAddr, err := btcutil.NewAddressWitnessPubKeyHash(
|
||||
pubKeyHash, b.netParams,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -244,7 +246,7 @@ func (b *BtcWallet) ComputeInputScript(tx *wire.MsgTx,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
inputScript.ScriptSig = sigScript
|
||||
inputScript.SigScript = sigScript
|
||||
|
||||
// Otherwise, this is a regular p2wkh output, so we include the
|
||||
// witness program itself as the subscript to generate the proper
|
||||
@ -267,7 +269,8 @@ func (b *BtcWallet) ComputeInputScript(tx *wire.MsgTx,
|
||||
// TODO(roasbeef): adhere to passed HashType
|
||||
witnessScript, err := txscript.WitnessSignature(tx, signDesc.SigHashes,
|
||||
signDesc.InputIndex, signDesc.Output.Value, witnessProgram,
|
||||
signDesc.HashType, privKey, true)
|
||||
signDesc.HashType, privKey, true,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -50,11 +50,15 @@ func (c *ChannelContribution) toChanConfig() channeldb.ChannelConfig {
|
||||
}
|
||||
|
||||
// InputScript represents any script inputs required to redeem a previous
|
||||
// output. This struct is used rather than just a witness, or scripSig in
|
||||
// order to accommodate nested p2sh which utilizes both types of input scripts.
|
||||
// output. This struct is used rather than just a witness, or scripSig in order
|
||||
// to accommodate nested p2sh which utilizes both types of input scripts.
|
||||
type InputScript struct {
|
||||
Witness [][]byte
|
||||
ScriptSig []byte
|
||||
// Witness is the full witness stack required to unlock this output.
|
||||
Witness wire.TxWitness
|
||||
|
||||
// SigScript will only be populated if this is an input script sweeping
|
||||
// a nested p2sh output.
|
||||
SigScript []byte
|
||||
}
|
||||
|
||||
// ChannelReservation represents an intent to open a lightning payment channel
|
||||
|
@ -438,13 +438,15 @@ func (m *mockSigner) ComputeInputScript(tx *wire.MsgTx, signDesc *SignDescriptor
|
||||
"address %v", addresses[0])
|
||||
}
|
||||
|
||||
scriptSig, err := txscript.SignatureScript(tx, signDesc.InputIndex,
|
||||
signDesc.Output.PkScript, txscript.SigHashAll, privKey, true)
|
||||
sigScript, err := txscript.SignatureScript(
|
||||
tx, signDesc.InputIndex, signDesc.Output.PkScript,
|
||||
txscript.SigHashAll, privKey, true,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &InputScript{ScriptSig: scriptSig}, nil
|
||||
return &InputScript{SigScript: sigScript}, nil
|
||||
|
||||
case txscript.WitnessV0PubKeyHashTy:
|
||||
privKey := m.findKey(addresses[0].ScriptAddress(), signDesc.SingleTweak,
|
||||
|
@ -747,14 +747,15 @@ func (l *LightningWallet) handleContributionMsg(req *addContributionMsg) {
|
||||
signDesc.Output = info
|
||||
signDesc.InputIndex = i
|
||||
|
||||
inputScript, err := l.Cfg.Signer.ComputeInputScript(fundingTx,
|
||||
&signDesc)
|
||||
inputScript, err := l.Cfg.Signer.ComputeInputScript(
|
||||
fundingTx, &signDesc,
|
||||
)
|
||||
if err != nil {
|
||||
req.err <- err
|
||||
return
|
||||
}
|
||||
|
||||
txIn.SignatureScript = inputScript.ScriptSig
|
||||
txIn.SignatureScript = inputScript.SigScript
|
||||
txIn.Witness = inputScript.Witness
|
||||
pendingReservation.ourFundingInputScripts = append(
|
||||
pendingReservation.ourFundingInputScripts,
|
||||
@ -958,7 +959,7 @@ func (l *LightningWallet) handleFundingCounterPartySigs(msg *addCounterPartySigs
|
||||
if len(inputScripts) != 0 && len(txin.Witness) == 0 {
|
||||
// Attach the input scripts so we can verify it below.
|
||||
txin.Witness = inputScripts[sigIndex].Witness
|
||||
txin.SignatureScript = inputScripts[sigIndex].ScriptSig
|
||||
txin.SignatureScript = inputScripts[sigIndex].SigScript
|
||||
|
||||
// Fetch the alleged previous output along with the
|
||||
// pkscript referenced by this input.
|
||||
@ -1256,7 +1257,6 @@ func (l *LightningWallet) handleSingleFunderSigs(req *addSingleFunderSigsMsg) {
|
||||
// selection is successful/possible, then the selected coins are available
|
||||
// within the passed contribution's inputs. If necessary, a change address will
|
||||
// also be generated.
|
||||
// TODO(roasbeef): remove hardcoded fees.
|
||||
func (l *LightningWallet) selectCoinsAndChange(feeRate SatPerKWeight,
|
||||
amt btcutil.Amount, minConfs int32,
|
||||
contribution *ChannelContribution) error {
|
||||
|
Loading…
Reference in New Issue
Block a user