MCPcopy Index your code
hub / github.com/btcsuite/btcd / Script

Method Script

txscript/pkscript.go:122–156  ·  view source on GitHub ↗

Script returns the script as a byte slice without any padding.

()

Source from the content-addressed store, hash-verified

120
121// Script returns the script as a byte slice without any padding.
122func (s PkScript) Script() []byte {
123 var script []byte
124
125 switch s.class {
126 case PubKeyHashTy:
127 script = make([]byte, pubKeyHashLen)
128 copy(script, s.script[:pubKeyHashLen])
129
130 case WitnessV0PubKeyHashTy:
131 script = make([]byte, witnessV0PubKeyHashLen)
132 copy(script, s.script[:witnessV0PubKeyHashLen])
133
134 case ScriptHashTy:
135 script = make([]byte, scriptHashLen)
136 copy(script, s.script[:scriptHashLen])
137
138 case WitnessV0ScriptHashTy:
139 script = make([]byte, witnessV0ScriptHashLen)
140 copy(script, s.script[:witnessV0ScriptHashLen])
141
142 case WitnessV1TaprootTy:
143 script = make([]byte, witnessV1TaprootLen)
144 copy(script, s.script[:witnessV1TaprootLen])
145
146 case PayToAnchorTy:
147 script = make([]byte, payToAnchorLen)
148 copy(script, s.script[:payToAnchorLen])
149
150 default:
151 // Unsupported script type.
152 return nil
153 }
154
155 return script
156}
157
158// Address encodes the script into an address for the given chain.
159func (s PkScript) Address(chainParams *chaincfg.Params) (address.Address, error) {

Callers 15

AddressMethod · 0.95
StringMethod · 0.95
builderScriptFunction · 0.45
CreateCoinbaseTxMethod · 0.45
createCSVOutputFunction · 0.45
spendCSVOutputFunction · 0.45
standardCoinbaseScriptFunction · 0.45
standardCoinbaseScriptFunction · 0.45
createCoinbaseTxFunction · 0.45
addPartialSignatureMethod · 0.45
compareScriptFunction · 0.45

Calls

no outgoing calls

Tested by 15

CreateCoinbaseTxMethod · 0.36
createCSVOutputFunction · 0.36
spendCSVOutputFunction · 0.36
TestUseBlockHashFunction · 0.36
createTestCoinbaseFunction · 0.36
TestScriptBuilderAddOpFunction · 0.36
TestExceedMaxScriptSizeFunction · 0.36
TestErroredScriptFunction · 0.36
TestParsePkScriptFunction · 0.36
TestComputePkScriptFunction · 0.36