MCPcopy Create free account
hub / github.com/btcsuite/btcd / TestComputePkScript

Function TestComputePkScript

txscript/pkscript_test.go:191–441  ·  view source on GitHub ↗

TestComputePkScript ensures that we can correctly re-derive an output's pkScript by looking at the input's signature script/witness attempting to spend it.

(t *testing.T)

Source from the content-addressed store, hash-verified

189// pkScript by looking at the input's signature script/witness attempting to
190// spend it.
191func TestComputePkScript(t *testing.T) {
192 t.Parallel()
193
194 tests := []struct {
195 name string
196 sigScript []byte
197 witness wire.TxWitness
198 class ScriptClass
199 pkScript []byte
200 }{
201 {
202 name: "empty sigScript and witness",
203 sigScript: nil,
204 witness: nil,
205 class: NonStandardTy,
206 pkScript: nil,
207 },
208 {
209 name: "P2PKH sigScript",
210 sigScript: []byte{
211 // OP_DATA_73,
212 0x49,
213 // <73-byte sig>
214 0x30, 0x44, 0x02, 0x20, 0x65, 0x92, 0xd8, 0x8e,
215 0x1d, 0x0a, 0x4a, 0x3c, 0xc5, 0x9f, 0x92, 0xae,
216 0xfe, 0x62, 0x54, 0x74, 0xa9, 0x4d, 0x13, 0xa5,
217 0x9f, 0x84, 0x97, 0x78, 0xfc, 0xe7, 0xdf, 0x4b,
218 0xe0, 0xc2, 0x28, 0xd8, 0x02, 0x20, 0x2d, 0xea,
219 0x36, 0x96, 0x19, 0x1f, 0xb7, 0x00, 0xc5, 0xa7,
220 0x7e, 0x22, 0xd9, 0xfb, 0x6b, 0x42, 0x67, 0x42,
221 0xa4, 0x2c, 0xac, 0xdb, 0x74, 0xa2, 0x7c, 0x43,
222 0xcd, 0x89, 0xa0, 0xf9, 0x44, 0x54, 0x12, 0x74,
223 0x01,
224 // OP_DATA_33
225 0x21,
226 // <33-byte compressed pubkey>
227 0x02, 0x7d, 0x56, 0x12, 0x09, 0x75, 0x31, 0xc2,
228 0x17, 0xfd, 0xd4, 0xd2, 0xe1, 0x7a, 0x35, 0x4b,
229 0x17, 0xf2, 0x7a, 0xef, 0x30, 0x9f, 0xb2, 0x7f,
230 0x1f, 0x1f, 0x7b, 0x73, 0x7d, 0x9a, 0x24, 0x49,
231 0x90,
232 },
233 witness: nil,
234 class: PubKeyHashTy,
235 pkScript: []byte{
236 // OP_DUP
237 0x76,
238 // OP_HASH160
239 0xa9,
240 // OP_DATA_20
241 0x14,
242 // <20-byte pubkey hash>
243 0xf0, 0x7a, 0xb8, 0xce, 0x72, 0xda, 0x4e, 0x76,
244 0x0b, 0x74, 0x7d, 0x48, 0xd6, 0x65, 0xec, 0x96,
245 0xad, 0xf0, 0x24, 0xf5,
246 // OP_EQUALVERIFY
247 0x88,
248 // OP_CHECKSIG

Callers

nothing calls this directly

Calls 3

ComputePkScriptFunction · 0.85
ClassMethod · 0.80
ScriptMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…