This commit is contained in:
David Hill 2014-02-04 16:18:37 -05:00
parent 13ba8607f7
commit 971fbf8b28
4 changed files with 594 additions and 594 deletions

File diff suppressed because it is too large Load diff

View file

@ -483,7 +483,7 @@ func testScript(t *testing.T, script []byte, canonical bool) (err error) {
tx := &btcwire.MsgTx{ tx := &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash{}, Hash: btcwire.ShaHash{},
Index: 0xffffffff, Index: 0xffffffff,
@ -493,7 +493,7 @@ func testScript(t *testing.T, script []byte, canonical bool) (err error) {
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 0x12a05f200, Value: 0x12a05f200,
PkScript: []byte{}, PkScript: []byte{},
}, },
@ -4265,7 +4265,7 @@ func testOpcode(t *testing.T, test *detailedTest) {
tx := &btcwire.MsgTx{ tx := &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash{}, Hash: btcwire.ShaHash{},
Index: 0xffffffff, Index: 0xffffffff,
@ -4275,7 +4275,7 @@ func testOpcode(t *testing.T, test *detailedTest) {
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 0x12a05f200, Value: 0x12a05f200,
PkScript: []byte{}, PkScript: []byte{},
}, },

View file

@ -963,20 +963,20 @@ func getSigOpCount(pops []parsedOpcode, precise bool) int {
// output to a 20-byte pubkey hash. // output to a 20-byte pubkey hash.
func PayToPubKeyHashScript(pubKeyHash []byte) (pkScript []byte, err error) { func PayToPubKeyHashScript(pubKeyHash []byte) (pkScript []byte, err error) {
pops := []parsedOpcode{ pops := []parsedOpcode{
parsedOpcode{ {
opcode: opcodemap[OP_DUP], opcode: opcodemap[OP_DUP],
}, },
parsedOpcode{ {
opcode: opcodemap[OP_HASH160], opcode: opcodemap[OP_HASH160],
}, },
parsedOpcode{ {
opcode: opcodemap[OP_DATA_20], opcode: opcodemap[OP_DATA_20],
data: pubKeyHash, data: pubKeyHash,
}, },
parsedOpcode{ {
opcode: opcodemap[OP_EQUALVERIFY], opcode: opcodemap[OP_EQUALVERIFY],
}, },
parsedOpcode{ {
opcode: opcodemap[OP_CHECKSIG], opcode: opcodemap[OP_CHECKSIG],
}, },
} }
@ -987,14 +987,14 @@ func PayToPubKeyHashScript(pubKeyHash []byte) (pkScript []byte, err error) {
// script hash. // script hash.
func PayToScriptHashScript(scriptHash []byte) (pkScript []byte, err error) { func PayToScriptHashScript(scriptHash []byte) (pkScript []byte, err error) {
pops := []parsedOpcode{ pops := []parsedOpcode{
parsedOpcode{ {
opcode: opcodemap[OP_HASH160], opcode: opcodemap[OP_HASH160],
}, },
parsedOpcode{ {
opcode: opcodemap[OP_DATA_20], opcode: opcodemap[OP_DATA_20],
data: scriptHash, data: scriptHash,
}, },
parsedOpcode{ {
opcode: opcodemap[OP_EQUAL], opcode: opcodemap[OP_EQUAL],
}, },
} }
@ -1069,7 +1069,7 @@ func signatureScriptCustomReader(reader io.Reader, tx *btcwire.MsgTx, idx int,
} }
} }
pops := []parsedOpcode{ pops := []parsedOpcode{
parsedOpcode{ {
opcode: opcodemap[byte(len(sig))], opcode: opcodemap[byte(len(sig))],
data: sig, data: sig,
}, },

View file

@ -33,12 +33,12 @@ type txTest struct {
var txTests = []txTest{ var txTests = []txTest{
// tx 0437cd7f8525ceed2324359c2d0ba26006d92d85. the first tx in the // tx 0437cd7f8525ceed2324359c2d0ba26006d92d85. the first tx in the
// blockchain that verifies signatures. // blockchain that verifies signatures.
txTest{ {
name: "CheckSig", name: "CheckSig",
tx: &btcwire.MsgTx{ tx: &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0xc9, 0x97, 0xa5, 0xe5, 0xc9, 0x97, 0xa5, 0xe5,
@ -75,7 +75,7 @@ var txTests = []txTest{
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 1000000000, Value: 1000000000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DATA_65, btcscript.OP_DATA_65,
@ -95,7 +95,7 @@ var txTests = []txTest{
btcscript.OP_CHECKSIG, btcscript.OP_CHECKSIG,
}, },
}, },
&btcwire.TxOut{ {
Value: 4000000000, Value: 4000000000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DATA_65, btcscript.OP_DATA_65,
@ -139,12 +139,12 @@ var txTests = []txTest{
}, },
}, },
// Previous test with the value of one output changed. // Previous test with the value of one output changed.
txTest{ {
name: "CheckSig Failure", name: "CheckSig Failure",
tx: &btcwire.MsgTx{ tx: &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0xc9, 0x97, 0xa5, 0xe5, 0xc9, 0x97, 0xa5, 0xe5,
@ -181,7 +181,7 @@ var txTests = []txTest{
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 1000000000, Value: 1000000000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DATA_65, btcscript.OP_DATA_65,
@ -201,7 +201,7 @@ var txTests = []txTest{
btcscript.OP_CHECKSIG, btcscript.OP_CHECKSIG,
}, },
}, },
&btcwire.TxOut{ {
Value: 5000000000, Value: 5000000000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DATA_65, btcscript.OP_DATA_65,
@ -245,12 +245,12 @@ var txTests = []txTest{
SigOps: 1, SigOps: 1,
}, },
}, },
txTest{ {
name: "CheckSig invalid signature", name: "CheckSig invalid signature",
tx: &btcwire.MsgTx{ tx: &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0xc9, 0x97, 0xa5, 0xe5, 0xc9, 0x97, 0xa5, 0xe5,
@ -289,7 +289,7 @@ var txTests = []txTest{
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 1000000000, Value: 1000000000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DATA_65, btcscript.OP_DATA_65,
@ -309,7 +309,7 @@ var txTests = []txTest{
btcscript.OP_CHECKSIG, btcscript.OP_CHECKSIG,
}, },
}, },
&btcwire.TxOut{ {
Value: 4000000000, Value: 4000000000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DATA_65, btcscript.OP_DATA_65,
@ -353,12 +353,12 @@ var txTests = []txTest{
SigOps: 1, SigOps: 1,
}, },
}, },
txTest{ {
name: "CheckSig invalid pubkey", name: "CheckSig invalid pubkey",
tx: &btcwire.MsgTx{ tx: &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0xc9, 0x97, 0xa5, 0xe5, 0xc9, 0x97, 0xa5, 0xe5,
@ -395,7 +395,7 @@ var txTests = []txTest{
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 1000000000, Value: 1000000000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DATA_65, btcscript.OP_DATA_65,
@ -415,7 +415,7 @@ var txTests = []txTest{
btcscript.OP_CHECKSIG, btcscript.OP_CHECKSIG,
}, },
}, },
&btcwire.TxOut{ {
Value: 4000000000, Value: 4000000000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DATA_65, btcscript.OP_DATA_65,
@ -462,12 +462,12 @@ var txTests = []txTest{
}, },
// tx 599e47a8114fe098103663029548811d2651991b62397e057f0c863c2bc9f9ea // tx 599e47a8114fe098103663029548811d2651991b62397e057f0c863c2bc9f9ea
// uses checksig with SigHashNone. // uses checksig with SigHashNone.
txTest{ {
name: "CheckSigHashNone", name: "CheckSigHashNone",
tx: &btcwire.MsgTx{ tx: &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0x5f, 0x38, 0x6c, 0x8a, 0x5f, 0x38, 0x6c, 0x8a,
@ -517,7 +517,7 @@ var txTests = []txTest{
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 1000000, Value: 1000000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DUP, btcscript.OP_DUP,
@ -531,7 +531,7 @@ var txTests = []txTest{
btcscript.OP_CHECKSIG, btcscript.OP_CHECKSIG,
}, },
}, },
&btcwire.TxOut{ {
Value: 29913632, Value: 29913632,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DUP, btcscript.OP_DUP,
@ -568,12 +568,12 @@ var txTests = []txTest{
SigOps: 1, SigOps: 1,
}, },
}, },
txTest{ {
name: "Non-canonical signature: R value negative", name: "Non-canonical signature: R value negative",
tx: &btcwire.MsgTx{ tx: &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0xfe, 0x15, 0x62, 0xc4, 0xfe, 0x15, 0x62, 0xc4,
@ -621,7 +621,7 @@ var txTests = []txTest{
}, },
Sequence: 4294967295, Sequence: 4294967295,
}, },
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0x2a, 0xc7, 0xee, 0xf8, 0x2a, 0xc7, 0xee, 0xf8,
@ -671,7 +671,7 @@ var txTests = []txTest{
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 630320000, Value: 630320000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DUP, btcscript.OP_DUP,
@ -685,7 +685,7 @@ var txTests = []txTest{
btcscript.OP_CHECKSIG, btcscript.OP_CHECKSIG,
}, },
}, },
&btcwire.TxOut{ {
Value: 100000181, Value: 100000181,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DUP, btcscript.OP_DUP,
@ -699,7 +699,7 @@ var txTests = []txTest{
btcscript.OP_CHECKSIG, btcscript.OP_CHECKSIG,
}, },
}, },
&btcwire.TxOut{ {
Value: 596516343, Value: 596516343,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DUP, btcscript.OP_DUP,
@ -742,12 +742,12 @@ var txTests = []txTest{
// tx 51bf528ecf3c161e7c021224197dbe84f9a8564212f6207baa014c01a1668e1e // tx 51bf528ecf3c161e7c021224197dbe84f9a8564212f6207baa014c01a1668e1e
// first instance of an AnyoneCanPay signature in the blockchain // first instance of an AnyoneCanPay signature in the blockchain
txTest{ {
name: "CheckSigHashAnyoneCanPay", name: "CheckSigHashAnyoneCanPay",
tx: &btcwire.MsgTx{ tx: &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0xf6, 0x04, 0x4c, 0x0a, 0xf6, 0x04, 0x4c, 0x0a,
@ -789,7 +789,7 @@ var txTests = []txTest{
}, },
Sequence: 4294967295, Sequence: 4294967295,
}, },
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0x9c, 0x6a, 0xf0, 0xdf, 0x9c, 0x6a, 0xf0, 0xdf,
@ -833,7 +833,7 @@ var txTests = []txTest{
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 300000, Value: 300000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DUP, btcscript.OP_DUP,
@ -872,12 +872,12 @@ var txTests = []txTest{
}, },
// tx 6d36bc17e947ce00bb6f12f8e7a56a1585c5a36188ffa2b05e10b4743273a74b // tx 6d36bc17e947ce00bb6f12f8e7a56a1585c5a36188ffa2b05e10b4743273a74b
// Uses OP_CODESEPARATOR and OP_CHECKMULTISIG // Uses OP_CODESEPARATOR and OP_CHECKMULTISIG
txTest{ {
name: "CheckMultiSig", name: "CheckMultiSig",
tx: &btcwire.MsgTx{ tx: &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0x37, 0xb1, 0x7d, 0x76, 0x37, 0xb1, 0x7d, 0x76,
@ -915,7 +915,7 @@ var txTests = []txTest{
}, },
Sequence: 4294967295, Sequence: 4294967295,
}, },
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0x37, 0xb1, 0x7d, 0x76, 0x37, 0xb1, 0x7d, 0x76,
@ -964,7 +964,7 @@ var txTests = []txTest{
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 4800000, Value: 4800000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DUP, btcscript.OP_DUP,
@ -995,12 +995,12 @@ var txTests = []txTest{
scriptInfoErr: btcscript.StackErrNonPushOnly, scriptInfoErr: btcscript.StackErrNonPushOnly,
}, },
// same as previous but with one byte changed to make signature fail // same as previous but with one byte changed to make signature fail
txTest{ {
name: "CheckMultiSig fail", name: "CheckMultiSig fail",
tx: &btcwire.MsgTx{ tx: &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0x37, 0xb1, 0x7d, 0x76, 0x37, 0xb1, 0x7d, 0x76,
@ -1038,7 +1038,7 @@ var txTests = []txTest{
}, },
Sequence: 4294967295, Sequence: 4294967295,
}, },
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0x37, 0xb1, 0x7d, 0x76, 0x37, 0xb1, 0x7d, 0x76,
@ -1087,7 +1087,7 @@ var txTests = []txTest{
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 5800000, Value: 5800000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DUP, btcscript.OP_DUP,
@ -1120,12 +1120,12 @@ var txTests = []txTest{
}, },
// tx e5779b9e78f9650debc2893fd9636d827b26b4ddfa6a8172fe8708c924f5c39d // tx e5779b9e78f9650debc2893fd9636d827b26b4ddfa6a8172fe8708c924f5c39d
// First P2SH transaction in the blockchain // First P2SH transaction in the blockchain
txTest{ {
name: "P2SH", name: "P2SH",
tx: &btcwire.MsgTx{ tx: &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0x6d, 0x58, 0xf8, 0xa3, 0x6d, 0x58, 0xf8, 0xa3,
@ -1148,7 +1148,7 @@ var txTests = []txTest{
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 1000000, Value: 1000000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DUP, btcscript.OP_DUP,
@ -1185,13 +1185,13 @@ var txTests = []txTest{
}, },
// next few tests are modified versions of previous to hit p2sh error // next few tests are modified versions of previous to hit p2sh error
// cases. // cases.
txTest{ {
// sigscript changed so that pkscript hash will not match. // sigscript changed so that pkscript hash will not match.
name: "P2SH - bad hash", name: "P2SH - bad hash",
tx: &btcwire.MsgTx{ tx: &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0x6d, 0x58, 0xf8, 0xa3, 0x6d, 0x58, 0xf8, 0xa3,
@ -1214,7 +1214,7 @@ var txTests = []txTest{
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 1000000, Value: 1000000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DUP, btcscript.OP_DUP,
@ -1250,13 +1250,13 @@ var txTests = []txTest{
SigOps: 0, SigOps: 0,
}, },
}, },
txTest{ {
// sigscript changed so that pkscript hash will not match. // sigscript changed so that pkscript hash will not match.
name: "P2SH - doesn't parse", name: "P2SH - doesn't parse",
tx: &btcwire.MsgTx{ tx: &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0x6d, 0x58, 0xf8, 0xa3, 0x6d, 0x58, 0xf8, 0xa3,
@ -1279,7 +1279,7 @@ var txTests = []txTest{
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 1000000, Value: 1000000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DUP, btcscript.OP_DUP,
@ -1309,13 +1309,13 @@ var txTests = []txTest{
bip16: true, bip16: true,
scriptInfoErr: btcscript.StackErrShortScript, scriptInfoErr: btcscript.StackErrShortScript,
}, },
txTest{ {
// sigscript changed so to be non pushonly. // sigscript changed so to be non pushonly.
name: "P2SH - non pushonly", name: "P2SH - non pushonly",
tx: &btcwire.MsgTx{ tx: &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0x6d, 0x58, 0xf8, 0xa3, 0x6d, 0x58, 0xf8, 0xa3,
@ -1342,7 +1342,7 @@ var txTests = []txTest{
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 1000000, Value: 1000000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DUP, btcscript.OP_DUP,
@ -1373,13 +1373,13 @@ var txTests = []txTest{
nSigOps: 0, // no signature ops in the pushed script. nSigOps: 0, // no signature ops in the pushed script.
scriptInfoErr: btcscript.StackErrNonPushOnly, scriptInfoErr: btcscript.StackErrNonPushOnly,
}, },
txTest{ {
// sigscript changed so to be non pushonly. // sigscript changed so to be non pushonly.
name: "empty pkScript", name: "empty pkScript",
tx: &btcwire.MsgTx{ tx: &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0x6d, 0x58, 0xf8, 0xa3, 0x6d, 0x58, 0xf8, 0xa3,
@ -1402,7 +1402,7 @@ var txTests = []txTest{
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 1000000, Value: 1000000,
PkScript: []byte{ PkScript: []byte{
btcscript.OP_DUP, btcscript.OP_DUP,
@ -1509,29 +1509,29 @@ func TestGetPreciseSignOps(t *testing.T) {
err error err error
} }
psocTests := []psocTest{ psocTests := []psocTest{
psocTest{ {
name: "scriptSig doesn't parse", name: "scriptSig doesn't parse",
scriptSig: []byte{btcscript.OP_PUSHDATA1, 2}, scriptSig: []byte{btcscript.OP_PUSHDATA1, 2},
err: btcscript.StackErrShortScript, err: btcscript.StackErrShortScript,
}, },
psocTest{ {
name: "scriptSig isn't push only", name: "scriptSig isn't push only",
scriptSig: []byte{btcscript.OP_1, btcscript.OP_DUP}, scriptSig: []byte{btcscript.OP_1, btcscript.OP_DUP},
nSigOps: 0, nSigOps: 0,
}, },
psocTest{ {
name: "scriptSig length 0", name: "scriptSig length 0",
scriptSig: []byte{}, scriptSig: []byte{},
nSigOps: 0, nSigOps: 0,
}, },
psocTest{ {
name: "No script at the end", name: "No script at the end",
// No script at end but still push only. // No script at end but still push only.
scriptSig: []byte{btcscript.OP_1, btcscript.OP_1}, scriptSig: []byte{btcscript.OP_1, btcscript.OP_1},
nSigOps: 0, nSigOps: 0,
}, },
// pushed script doesn't parse. // pushed script doesn't parse.
psocTest{ {
name: "pushed script doesn't parse", name: "pushed script doesn't parse",
scriptSig: []byte{btcscript.OP_DATA_2, scriptSig: []byte{btcscript.OP_DATA_2,
btcscript.OP_PUSHDATA1, 2}, btcscript.OP_PUSHDATA1, 2},
@ -1759,14 +1759,14 @@ type removeOpcodeTest struct {
var removeOpcodeTests = []removeOpcodeTest{ var removeOpcodeTests = []removeOpcodeTest{
// Nothing to remove. // Nothing to remove.
removeOpcodeTest{ {
name: "nothing to remove", name: "nothing to remove",
before: []byte{btcscript.OP_NOP}, before: []byte{btcscript.OP_NOP},
remove: btcscript.OP_CODESEPARATOR, remove: btcscript.OP_CODESEPARATOR,
after: []byte{btcscript.OP_NOP}, after: []byte{btcscript.OP_NOP},
}, },
// Test basic opcode removal // Test basic opcode removal
removeOpcodeTest{ {
name: "codeseparator 1", name: "codeseparator 1",
before: []byte{btcscript.OP_NOP, btcscript.OP_CODESEPARATOR, before: []byte{btcscript.OP_NOP, btcscript.OP_CODESEPARATOR,
btcscript.OP_TRUE}, btcscript.OP_TRUE},
@ -1775,7 +1775,7 @@ var removeOpcodeTests = []removeOpcodeTest{
}, },
// The opcode in question is actually part of the data in a previous // The opcode in question is actually part of the data in a previous
// opcode // opcode
removeOpcodeTest{ {
name: "codeseparator by coincidence", name: "codeseparator by coincidence",
before: []byte{btcscript.OP_NOP, btcscript.OP_DATA_1, btcscript.OP_CODESEPARATOR, before: []byte{btcscript.OP_NOP, btcscript.OP_DATA_1, btcscript.OP_CODESEPARATOR,
btcscript.OP_TRUE}, btcscript.OP_TRUE},
@ -1783,19 +1783,19 @@ var removeOpcodeTests = []removeOpcodeTest{
after: []byte{btcscript.OP_NOP, btcscript.OP_DATA_1, btcscript.OP_CODESEPARATOR, after: []byte{btcscript.OP_NOP, btcscript.OP_DATA_1, btcscript.OP_CODESEPARATOR,
btcscript.OP_TRUE}, btcscript.OP_TRUE},
}, },
removeOpcodeTest{ {
name: "invalid opcode", name: "invalid opcode",
before: []byte{btcscript.OP_UNKNOWN186}, before: []byte{btcscript.OP_UNKNOWN186},
remove: btcscript.OP_CODESEPARATOR, remove: btcscript.OP_CODESEPARATOR,
after: []byte{btcscript.OP_UNKNOWN186}, after: []byte{btcscript.OP_UNKNOWN186},
}, },
removeOpcodeTest{ {
name: "invalid length (insruction)", name: "invalid length (insruction)",
before: []byte{btcscript.OP_PUSHDATA1}, before: []byte{btcscript.OP_PUSHDATA1},
remove: btcscript.OP_CODESEPARATOR, remove: btcscript.OP_CODESEPARATOR,
err: btcscript.StackErrShortScript, err: btcscript.StackErrShortScript,
}, },
removeOpcodeTest{ {
name: "invalid length (data)", name: "invalid length (data)",
before: []byte{btcscript.OP_PUSHDATA1, 255, 254}, before: []byte{btcscript.OP_PUSHDATA1, 255, 254},
remove: btcscript.OP_CODESEPARATOR, remove: btcscript.OP_CODESEPARATOR,
@ -1837,73 +1837,73 @@ type removeOpcodeByDataTest struct {
} }
var removeOpcodeByDataTests = []removeOpcodeByDataTest{ var removeOpcodeByDataTests = []removeOpcodeByDataTest{
removeOpcodeByDataTest{ {
name: "nothing to do", name: "nothing to do",
before: []byte{btcscript.OP_NOP}, before: []byte{btcscript.OP_NOP},
remove: []byte{1, 2, 3, 4}, remove: []byte{1, 2, 3, 4},
after: []byte{btcscript.OP_NOP}, after: []byte{btcscript.OP_NOP},
}, },
removeOpcodeByDataTest{ {
name: "simple case", name: "simple case",
before: []byte{btcscript.OP_DATA_4, 1, 2, 3, 4}, before: []byte{btcscript.OP_DATA_4, 1, 2, 3, 4},
remove: []byte{1, 2, 3, 4}, remove: []byte{1, 2, 3, 4},
after: []byte{}, after: []byte{},
}, },
removeOpcodeByDataTest{ {
name: "simple case (miss)", name: "simple case (miss)",
before: []byte{btcscript.OP_DATA_4, 1, 2, 3, 4}, before: []byte{btcscript.OP_DATA_4, 1, 2, 3, 4},
remove: []byte{1, 2, 3, 5}, remove: []byte{1, 2, 3, 5},
after: []byte{btcscript.OP_DATA_4, 1, 2, 3, 4}, after: []byte{btcscript.OP_DATA_4, 1, 2, 3, 4},
}, },
removeOpcodeByDataTest{ {
name: "simple case (pushdata1)", name: "simple case (pushdata1)",
before: []byte{btcscript.OP_PUSHDATA1, 4, 1, 2, 3, 4}, before: []byte{btcscript.OP_PUSHDATA1, 4, 1, 2, 3, 4},
remove: []byte{1, 2, 3, 4}, remove: []byte{1, 2, 3, 4},
after: []byte{}, after: []byte{},
}, },
removeOpcodeByDataTest{ {
name: "simple case (pushdata1 miss)", name: "simple case (pushdata1 miss)",
before: []byte{btcscript.OP_PUSHDATA1, 4, 1, 2, 3, 4}, before: []byte{btcscript.OP_PUSHDATA1, 4, 1, 2, 3, 4},
remove: []byte{1, 2, 3, 5}, remove: []byte{1, 2, 3, 5},
after: []byte{btcscript.OP_PUSHDATA1, 4, 1, 2, 3, 4}, after: []byte{btcscript.OP_PUSHDATA1, 4, 1, 2, 3, 4},
}, },
removeOpcodeByDataTest{ {
name: "simple case (pushdata2)", name: "simple case (pushdata2)",
before: []byte{btcscript.OP_PUSHDATA2, 4, 0, 1, 2, 3, 4}, before: []byte{btcscript.OP_PUSHDATA2, 4, 0, 1, 2, 3, 4},
remove: []byte{1, 2, 3, 4}, remove: []byte{1, 2, 3, 4},
after: []byte{}, after: []byte{},
}, },
removeOpcodeByDataTest{ {
name: "simple case (pushdata2 miss)", name: "simple case (pushdata2 miss)",
before: []byte{btcscript.OP_PUSHDATA2, 4, 0, 1, 2, 3, 4}, before: []byte{btcscript.OP_PUSHDATA2, 4, 0, 1, 2, 3, 4},
remove: []byte{1, 2, 3, 5}, remove: []byte{1, 2, 3, 5},
after: []byte{btcscript.OP_PUSHDATA2, 4, 0, 1, 2, 3, 4}, after: []byte{btcscript.OP_PUSHDATA2, 4, 0, 1, 2, 3, 4},
}, },
removeOpcodeByDataTest{ {
name: "simple case (pushdata4)", name: "simple case (pushdata4)",
before: []byte{btcscript.OP_PUSHDATA4, 4, 0, 0, 0, 1, 2, 3, 4}, before: []byte{btcscript.OP_PUSHDATA4, 4, 0, 0, 0, 1, 2, 3, 4},
remove: []byte{1, 2, 3, 4}, remove: []byte{1, 2, 3, 4},
after: []byte{}, after: []byte{},
}, },
removeOpcodeByDataTest{ {
name: "simple case (pushdata4 miss)", name: "simple case (pushdata4 miss)",
before: []byte{btcscript.OP_PUSHDATA4, 4, 0, 0, 0, 1, 2, 3, 4}, before: []byte{btcscript.OP_PUSHDATA4, 4, 0, 0, 0, 1, 2, 3, 4},
remove: []byte{1, 2, 3, 4, 5}, remove: []byte{1, 2, 3, 4, 5},
after: []byte{btcscript.OP_PUSHDATA4, 4, 0, 0, 0, 1, 2, 3, 4}, after: []byte{btcscript.OP_PUSHDATA4, 4, 0, 0, 0, 1, 2, 3, 4},
}, },
removeOpcodeByDataTest{ {
name: "invalid opcode ", name: "invalid opcode ",
before: []byte{btcscript.OP_UNKNOWN187}, before: []byte{btcscript.OP_UNKNOWN187},
remove: []byte{1, 2, 3, 4}, remove: []byte{1, 2, 3, 4},
after: []byte{btcscript.OP_UNKNOWN187}, after: []byte{btcscript.OP_UNKNOWN187},
}, },
removeOpcodeByDataTest{ {
name: "invalid length (instruction)", name: "invalid length (instruction)",
before: []byte{btcscript.OP_PUSHDATA1}, before: []byte{btcscript.OP_PUSHDATA1},
remove: []byte{1, 2, 3, 4}, remove: []byte{1, 2, 3, 4},
err: btcscript.StackErrShortScript, err: btcscript.StackErrShortScript,
}, },
removeOpcodeByDataTest{ {
name: "invalid length (data)", name: "invalid length (data)",
before: []byte{btcscript.OP_PUSHDATA1, 255, 254}, before: []byte{btcscript.OP_PUSHDATA1, 255, 254},
remove: []byte{1, 2, 3, 4}, remove: []byte{1, 2, 3, 4},
@ -1946,7 +1946,7 @@ type scriptTypeTest struct {
var scriptTypeTests = []scriptTypeTest{ var scriptTypeTests = []scriptTypeTest{
// tx 0437cd7f8525ceed2324359c2d0ba26006d92d85. // tx 0437cd7f8525ceed2324359c2d0ba26006d92d85.
scriptTypeTest{ {
name: "Pay Pubkey", name: "Pay Pubkey",
script: []byte{ script: []byte{
btcscript.OP_DATA_65, btcscript.OP_DATA_65,
@ -1963,7 +1963,7 @@ var scriptTypeTests = []scriptTypeTest{
scripttype: btcscript.PubKeyTy, scripttype: btcscript.PubKeyTy,
}, },
// tx 599e47a8114fe098103663029548811d2651991b62397e057f0c863c2bc9f9ea // tx 599e47a8114fe098103663029548811d2651991b62397e057f0c863c2bc9f9ea
scriptTypeTest{ {
name: "Pay PubkeyHash", name: "Pay PubkeyHash",
script: []byte{ script: []byte{
btcscript.OP_DUP, btcscript.OP_DUP,
@ -1980,7 +1980,7 @@ var scriptTypeTests = []scriptTypeTest{
// part of tx 6d36bc17e947ce00bb6f12f8e7a56a1585c5a36188ffa2b05e10b4743273a74b // part of tx 6d36bc17e947ce00bb6f12f8e7a56a1585c5a36188ffa2b05e10b4743273a74b
// codeseparator parts have been elided. (bitcoind's checks for multisig // codeseparator parts have been elided. (bitcoind's checks for multisig
// type doesn't have codesep etc either. // type doesn't have codesep etc either.
scriptTypeTest{ {
name: "multisig", name: "multisig",
script: []byte{ script: []byte{
btcscript.OP_TRUE, btcscript.OP_TRUE,
@ -1996,7 +1996,7 @@ var scriptTypeTests = []scriptTypeTest{
}, },
// tx e5779b9e78f9650debc2893fd9636d827b26b4ddfa6a8172fe8708c924f5c39d // tx e5779b9e78f9650debc2893fd9636d827b26b4ddfa6a8172fe8708c924f5c39d
// P2SH // P2SH
scriptTypeTest{ {
name: "P2SH", name: "P2SH",
script: []byte{ script: []byte{
btcscript.OP_HASH160, btcscript.OP_HASH160,
@ -2009,7 +2009,7 @@ var scriptTypeTests = []scriptTypeTest{
scripttype: btcscript.ScriptHashTy, scripttype: btcscript.ScriptHashTy,
}, },
// Nulldata with no data at all. // Nulldata with no data at all.
scriptTypeTest{ {
name: "nulldata", name: "nulldata",
script: []byte{ script: []byte{
btcscript.OP_RETURN, btcscript.OP_RETURN,
@ -2017,7 +2017,7 @@ var scriptTypeTests = []scriptTypeTest{
scripttype: btcscript.NullDataTy, scripttype: btcscript.NullDataTy,
}, },
// Nulldata with small data. // Nulldata with small data.
scriptTypeTest{ {
name: "nulldata2", name: "nulldata2",
script: []byte{ script: []byte{
btcscript.OP_RETURN, btcscript.OP_RETURN,
@ -2027,7 +2027,7 @@ var scriptTypeTests = []scriptTypeTest{
scripttype: btcscript.NullDataTy, scripttype: btcscript.NullDataTy,
}, },
// Nulldata with max allowed data. // Nulldata with max allowed data.
scriptTypeTest{ {
name: "nulldata3", name: "nulldata3",
script: []byte{ script: []byte{
btcscript.OP_RETURN, btcscript.OP_RETURN,
@ -2047,7 +2047,7 @@ var scriptTypeTests = []scriptTypeTest{
scripttype: btcscript.NullDataTy, scripttype: btcscript.NullDataTy,
}, },
// Nulldata with more than max allowed data (so therefore nonstandard) // Nulldata with more than max allowed data (so therefore nonstandard)
scriptTypeTest{ {
name: "nulldata4", name: "nulldata4",
script: []byte{ script: []byte{
btcscript.OP_RETURN, btcscript.OP_RETURN,
@ -2069,7 +2069,7 @@ var scriptTypeTests = []scriptTypeTest{
}, },
// Almost nulldata, but add an additional opcode after the data to make // Almost nulldata, but add an additional opcode after the data to make
// it nonstandard. // it nonstandard.
scriptTypeTest{ {
name: "nulldata5", name: "nulldata5",
script: []byte{ script: []byte{
btcscript.OP_RETURN, btcscript.OP_RETURN,
@ -2080,7 +2080,7 @@ var scriptTypeTests = []scriptTypeTest{
scripttype: btcscript.NonStandardTy, scripttype: btcscript.NonStandardTy,
}, // The next few are almost multisig (it is the more complex script type) }, // The next few are almost multisig (it is the more complex script type)
// but with various changes to make it fail. // but with various changes to make it fail.
scriptTypeTest{ {
// multisig but funny nsigs.. // multisig but funny nsigs..
name: "strange 1", name: "strange 1",
script: []byte{ script: []byte{
@ -2095,7 +2095,7 @@ var scriptTypeTests = []scriptTypeTest{
}, },
scripttype: btcscript.NonStandardTy, scripttype: btcscript.NonStandardTy,
}, },
scriptTypeTest{ {
name: "strange 2", name: "strange 2",
// multisig but funny pubkey. // multisig but funny pubkey.
script: []byte{ script: []byte{
@ -2106,7 +2106,7 @@ var scriptTypeTests = []scriptTypeTest{
}, },
scripttype: btcscript.NonStandardTy, scripttype: btcscript.NonStandardTy,
}, },
scriptTypeTest{ {
name: "strange 3", name: "strange 3",
// multisig but no matching npubkeys opcode. // multisig but no matching npubkeys opcode.
script: []byte{ script: []byte{
@ -2126,7 +2126,7 @@ var scriptTypeTests = []scriptTypeTest{
}, },
scripttype: btcscript.NonStandardTy, scripttype: btcscript.NonStandardTy,
}, },
scriptTypeTest{ {
name: "strange 4", name: "strange 4",
// multisig but with multisigverify // multisig but with multisigverify
script: []byte{ script: []byte{
@ -2141,7 +2141,7 @@ var scriptTypeTests = []scriptTypeTest{
}, },
scripttype: btcscript.NonStandardTy, scripttype: btcscript.NonStandardTy,
}, },
scriptTypeTest{ {
name: "strange 5", name: "strange 5",
// multisig but wrong length. // multisig but wrong length.
script: []byte{ script: []byte{
@ -2150,7 +2150,7 @@ var scriptTypeTests = []scriptTypeTest{
}, },
scripttype: btcscript.NonStandardTy, scripttype: btcscript.NonStandardTy,
}, },
scriptTypeTest{ {
name: "doesn't parse", name: "doesn't parse",
script: []byte{ script: []byte{
btcscript.OP_DATA_5, 0x1, 0x2, 0x3, 0x4, btcscript.OP_DATA_5, 0x1, 0x2, 0x3, 0x4,
@ -2191,11 +2191,11 @@ func TestBadPC(t *testing.T) {
script, off int script, off int
} }
pcTests := []pcTest{ pcTests := []pcTest{
pcTest{ {
script: 2, script: 2,
off: 0, off: 0,
}, },
pcTest{ {
script: 0, script: 0,
off: 2, off: 2,
}, },
@ -2204,7 +2204,7 @@ func TestBadPC(t *testing.T) {
tx := &btcwire.MsgTx{ tx := &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0xc9, 0x97, 0xa5, 0xe5, 0xc9, 0x97, 0xa5, 0xe5,
@ -2223,7 +2223,7 @@ func TestBadPC(t *testing.T) {
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 1000000000, Value: 1000000000,
PkScript: []byte{}, PkScript: []byte{},
}, },
@ -2263,7 +2263,7 @@ func TestCheckErrorCondition(t *testing.T) {
tx := &btcwire.MsgTx{ tx := &btcwire.MsgTx{
Version: 1, Version: 1,
TxIn: []*btcwire.TxIn{ TxIn: []*btcwire.TxIn{
&btcwire.TxIn{ {
PreviousOutpoint: btcwire.OutPoint{ PreviousOutpoint: btcwire.OutPoint{
Hash: btcwire.ShaHash([32]byte{ Hash: btcwire.ShaHash([32]byte{
0xc9, 0x97, 0xa5, 0xe5, 0xc9, 0x97, 0xa5, 0xe5,
@ -2282,7 +2282,7 @@ func TestCheckErrorCondition(t *testing.T) {
}, },
}, },
TxOut: []*btcwire.TxOut{ TxOut: []*btcwire.TxOut{
&btcwire.TxOut{ {
Value: 1000000000, Value: 1000000000,
PkScript: []byte{}, PkScript: []byte{},
}, },
@ -2423,10 +2423,10 @@ const coinbaseVal = 2500000000
const fee = 5000000 const fee = 5000000
var SigScriptTests = []TstSigScript{ var SigScriptTests = []TstSigScript{
TstSigScript{ {
name: "one input uncompressed", name: "one input uncompressed",
inputs: []TstInput{ inputs: []TstInput{
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript), txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript),
sigscriptGenerates: true, sigscriptGenerates: true,
inputValidates: true, inputValidates: true,
@ -2437,16 +2437,16 @@ var SigScriptTests = []TstSigScript{
compress: false, compress: false,
scriptAtWrongIndex: false, scriptAtWrongIndex: false,
}, },
TstSigScript{ {
name: "two inputs uncompressed", name: "two inputs uncompressed",
inputs: []TstInput{ inputs: []TstInput{
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript), txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript),
sigscriptGenerates: true, sigscriptGenerates: true,
inputValidates: true, inputValidates: true,
indexOutOfRange: false, indexOutOfRange: false,
}, },
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal+fee, uncompressedPkScript), txout: btcwire.NewTxOut(coinbaseVal+fee, uncompressedPkScript),
sigscriptGenerates: true, sigscriptGenerates: true,
inputValidates: true, inputValidates: true,
@ -2457,10 +2457,10 @@ var SigScriptTests = []TstSigScript{
compress: false, compress: false,
scriptAtWrongIndex: false, scriptAtWrongIndex: false,
}, },
TstSigScript{ {
name: "one input compressed", name: "one input compressed",
inputs: []TstInput{ inputs: []TstInput{
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal, compressedPkScript), txout: btcwire.NewTxOut(coinbaseVal, compressedPkScript),
sigscriptGenerates: true, sigscriptGenerates: true,
inputValidates: true, inputValidates: true,
@ -2471,16 +2471,16 @@ var SigScriptTests = []TstSigScript{
compress: true, compress: true,
scriptAtWrongIndex: false, scriptAtWrongIndex: false,
}, },
TstSigScript{ {
name: "two inputs compressed", name: "two inputs compressed",
inputs: []TstInput{ inputs: []TstInput{
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal, compressedPkScript), txout: btcwire.NewTxOut(coinbaseVal, compressedPkScript),
sigscriptGenerates: true, sigscriptGenerates: true,
inputValidates: true, inputValidates: true,
indexOutOfRange: false, indexOutOfRange: false,
}, },
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal+fee, compressedPkScript), txout: btcwire.NewTxOut(coinbaseVal+fee, compressedPkScript),
sigscriptGenerates: true, sigscriptGenerates: true,
inputValidates: true, inputValidates: true,
@ -2491,10 +2491,10 @@ var SigScriptTests = []TstSigScript{
compress: true, compress: true,
scriptAtWrongIndex: false, scriptAtWrongIndex: false,
}, },
TstSigScript{ {
name: "hashtype SigHashNone", name: "hashtype SigHashNone",
inputs: []TstInput{ inputs: []TstInput{
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript), txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript),
sigscriptGenerates: true, sigscriptGenerates: true,
inputValidates: true, inputValidates: true,
@ -2505,10 +2505,10 @@ var SigScriptTests = []TstSigScript{
compress: false, compress: false,
scriptAtWrongIndex: false, scriptAtWrongIndex: false,
}, },
TstSigScript{ {
name: "hashtype SigHashSingle", name: "hashtype SigHashSingle",
inputs: []TstInput{ inputs: []TstInput{
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript), txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript),
sigscriptGenerates: true, sigscriptGenerates: true,
inputValidates: true, inputValidates: true,
@ -2519,10 +2519,10 @@ var SigScriptTests = []TstSigScript{
compress: false, compress: false,
scriptAtWrongIndex: false, scriptAtWrongIndex: false,
}, },
TstSigScript{ {
name: "hashtype SigHashAnyoneCanPay", name: "hashtype SigHashAnyoneCanPay",
inputs: []TstInput{ inputs: []TstInput{
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript), txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript),
sigscriptGenerates: true, sigscriptGenerates: true,
inputValidates: true, inputValidates: true,
@ -2533,10 +2533,10 @@ var SigScriptTests = []TstSigScript{
compress: false, compress: false,
scriptAtWrongIndex: false, scriptAtWrongIndex: false,
}, },
TstSigScript{ {
name: "hashtype non-standard", name: "hashtype non-standard",
inputs: []TstInput{ inputs: []TstInput{
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript), txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript),
sigscriptGenerates: true, sigscriptGenerates: true,
inputValidates: true, inputValidates: true,
@ -2547,10 +2547,10 @@ var SigScriptTests = []TstSigScript{
compress: false, compress: false,
scriptAtWrongIndex: false, scriptAtWrongIndex: false,
}, },
TstSigScript{ {
name: "invalid compression", name: "invalid compression",
inputs: []TstInput{ inputs: []TstInput{
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript), txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript),
sigscriptGenerates: true, sigscriptGenerates: true,
inputValidates: false, inputValidates: false,
@ -2561,10 +2561,10 @@ var SigScriptTests = []TstSigScript{
compress: true, compress: true,
scriptAtWrongIndex: false, scriptAtWrongIndex: false,
}, },
TstSigScript{ {
name: "short PkScript", name: "short PkScript",
inputs: []TstInput{ inputs: []TstInput{
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal, shortPkScript), txout: btcwire.NewTxOut(coinbaseVal, shortPkScript),
sigscriptGenerates: false, sigscriptGenerates: false,
indexOutOfRange: false, indexOutOfRange: false,
@ -2574,16 +2574,16 @@ var SigScriptTests = []TstSigScript{
compress: false, compress: false,
scriptAtWrongIndex: false, scriptAtWrongIndex: false,
}, },
TstSigScript{ {
name: "valid script at wrong index", name: "valid script at wrong index",
inputs: []TstInput{ inputs: []TstInput{
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript), txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript),
sigscriptGenerates: true, sigscriptGenerates: true,
inputValidates: true, inputValidates: true,
indexOutOfRange: false, indexOutOfRange: false,
}, },
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal+fee, uncompressedPkScript), txout: btcwire.NewTxOut(coinbaseVal+fee, uncompressedPkScript),
sigscriptGenerates: true, sigscriptGenerates: true,
inputValidates: true, inputValidates: true,
@ -2594,16 +2594,16 @@ var SigScriptTests = []TstSigScript{
compress: false, compress: false,
scriptAtWrongIndex: true, scriptAtWrongIndex: true,
}, },
TstSigScript{ {
name: "index out of range", name: "index out of range",
inputs: []TstInput{ inputs: []TstInput{
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript), txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript),
sigscriptGenerates: true, sigscriptGenerates: true,
inputValidates: true, inputValidates: true,
indexOutOfRange: false, indexOutOfRange: false,
}, },
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal+fee, uncompressedPkScript), txout: btcwire.NewTxOut(coinbaseVal+fee, uncompressedPkScript),
sigscriptGenerates: true, sigscriptGenerates: true,
inputValidates: true, inputValidates: true,
@ -2614,10 +2614,10 @@ var SigScriptTests = []TstSigScript{
compress: false, compress: false,
scriptAtWrongIndex: true, scriptAtWrongIndex: true,
}, },
TstSigScript{ {
name: "invalid reader", name: "invalid reader",
inputs: []TstInput{ inputs: []TstInput{
TstInput{ {
txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript), txout: btcwire.NewTxOut(coinbaseVal, uncompressedPkScript),
invalidReader: true, invalidReader: true,
sigscriptGenerates: false, sigscriptGenerates: false,