mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
[NOD-1532] OpTrueScript should also return the redeem script
This commit is contained in:
parent
34be898491
commit
dc80a39c54
@ -38,9 +38,11 @@ func (tc *testConsensus) AddBlock(parentHashes []*externalapi.DomainHash, coinba
|
||||
tc.lock.Lock()
|
||||
defer tc.lock.Unlock()
|
||||
|
||||
scriptPublicKey, _ := testutils.OpTrueScript()
|
||||
|
||||
if coinbaseData == nil {
|
||||
coinbaseData = &externalapi.DomainCoinbaseData{
|
||||
ScriptPublicKey: testutils.OpTrueScript(),
|
||||
ScriptPublicKey: scriptPublicKey,
|
||||
ExtraData: []byte{},
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,9 @@ import (
|
||||
// Assumes that the output being spent has opTrueScript as it's scriptPublicKey
|
||||
// Creates the value of the spent output minus 1 sompi
|
||||
func CreateTransaction(txToSpend *externalapi.DomainTransaction) (*externalapi.DomainTransaction, error) {
|
||||
opTrueScript := OpTrueScript()
|
||||
scriptPublicKey, redeemScript := OpTrueScript()
|
||||
|
||||
scriptPublicKey := opTrueScript
|
||||
signatureScript, err := txscript.PayToScriptHashSignatureScript(opTrueScript, nil)
|
||||
signatureScript, err := txscript.PayToScriptHashSignatureScript(redeemScript, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -5,11 +5,14 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// OpTrueScript returns a P2SH script paying to an anyone-can-spend address
|
||||
func OpTrueScript() []byte {
|
||||
opTrueScript, err := txscript.PayToScriptHashScript([]byte{txscript.OpTrue})
|
||||
// OpTrueScript returns a P2SH script paying to an anyone-can-spend address,
|
||||
// The second return value is a redeemScript to be used with txscript.PayToScriptHashSignatureScript
|
||||
func OpTrueScript() (scriptPublicKey, redeemScript []byte) {
|
||||
var err error
|
||||
redeemScript = []byte{txscript.OpTrue}
|
||||
scriptPublicKey, err = txscript.PayToScriptHashScript(redeemScript)
|
||||
if err != nil {
|
||||
panic(errors.Wrapf(err, "Couldn't parse opTrueScript. This should never happen"))
|
||||
}
|
||||
return opTrueScript
|
||||
return scriptPublicKey, redeemScript
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user