Removed unused script txin/txout
This commit is contained in:
parent
4ee46b4a26
commit
3ac7b7eb7b
110
transaction.go
110
transaction.go
|
@ -6,26 +6,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
txInGenMarker = 0xff
|
txInGenMarker = 0xff
|
||||||
txInToScriptMarker = 0
|
txInToKeyMarker = 2
|
||||||
txInToScriptHashMarker = 1
|
txOutToKeyMarker = 2
|
||||||
txInToKeyMarker = 2
|
|
||||||
txOutToScriptMarker = 0
|
|
||||||
txOutToScriptHashMarker = 1
|
|
||||||
txOutToKeyMarker = 2
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var UnimplementedError = fmt.Errorf("Unimplemented")
|
var UnimplementedError = fmt.Errorf("Unimplemented")
|
||||||
|
|
||||||
type txOutToScript struct {
|
|
||||||
pubKeys []Key
|
|
||||||
script []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
type txOutToScriptHash struct {
|
|
||||||
hash Hash
|
|
||||||
}
|
|
||||||
|
|
||||||
type txOutToKey struct {
|
type txOutToKey struct {
|
||||||
key Key
|
key Key
|
||||||
}
|
}
|
||||||
|
@ -39,19 +26,6 @@ type txInGen struct {
|
||||||
height uint64
|
height uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
type txInToScript struct {
|
|
||||||
prev []byte
|
|
||||||
prevOut uint64
|
|
||||||
sigSet []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
type txInToScriptHash struct {
|
|
||||||
prev Hash
|
|
||||||
prevOut uint64
|
|
||||||
script []byte
|
|
||||||
sigSet []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
type txInToKey struct {
|
type txInToKey struct {
|
||||||
amount uint64
|
amount uint64
|
||||||
keyOffsets []uint64
|
keyOffsets []uint64
|
||||||
|
@ -92,33 +66,6 @@ func (p *Key) Serialize() (result []byte) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *txOutToScript) TargetSerialize() (result []byte) {
|
|
||||||
result = []byte{txOutToScriptMarker}
|
|
||||||
for i, pubkey := range t.pubKeys {
|
|
||||||
if i != 0 {
|
|
||||||
result = append(result, byte(txOutToScriptMarker))
|
|
||||||
}
|
|
||||||
result = append(result, pubkey.Serialize()...)
|
|
||||||
}
|
|
||||||
result = append(result, t.script...)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *txOutToScript) String() (result string) {
|
|
||||||
result = fmt.Sprintf("script: %x", t.script)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *txOutToScriptHash) TargetSerialize() (result []byte) {
|
|
||||||
result = append([]byte{txOutToScriptHashMarker}, t.hash.Serialize()...)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *txOutToScriptHash) String() (result string) {
|
|
||||||
result = fmt.Sprintf("hash: %x", t.hash)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *txOutToKey) TargetSerialize() (result []byte) {
|
func (t *txOutToKey) TargetSerialize() (result []byte) {
|
||||||
result = append([]byte{txOutToKeyMarker}, t.key.Serialize()...)
|
result = append([]byte{txOutToKeyMarker}, t.key.Serialize()...)
|
||||||
return
|
return
|
||||||
|
@ -138,29 +85,6 @@ func (t *txInGen) MixinLen() int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *txInToScript) TxInSerialize() (result []byte) {
|
|
||||||
result = append([]byte{txInToScriptMarker}, t.prev...)
|
|
||||||
result = append(result, Uint64ToBytes(t.prevOut)...)
|
|
||||||
result = append(result, t.sigSet...)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *txInToScript) MixinLen() int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *txInToScriptHash) TxInSerialize() (result []byte) {
|
|
||||||
result = append([]byte{txInToScriptHashMarker}, t.prev.Serialize()...)
|
|
||||||
result = append(result, Uint64ToBytes(t.prevOut)...)
|
|
||||||
result = append(result, t.script...)
|
|
||||||
result = append(result, t.sigSet...)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *txInToScriptHash) MixinLen() int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *txInToKey) TxInSerialize() (result []byte) {
|
func (t *txInToKey) TxInSerialize() (result []byte) {
|
||||||
result = append([]byte{txInToKeyMarker}, Uint64ToBytes(t.amount)...)
|
result = append([]byte{txInToKeyMarker}, Uint64ToBytes(t.amount)...)
|
||||||
result = append(result, Uint64ToBytes(uint64(len(t.keyOffsets)))...)
|
result = append(result, Uint64ToBytes(uint64(len(t.keyOffsets)))...)
|
||||||
|
@ -254,16 +178,6 @@ func ParseTxInGen(buf io.Reader) (txIn *txInGen, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseTxInToScript(buf io.Reader) (txIn *txInToScript, err error) {
|
|
||||||
err = UnimplementedError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseTxInToScriptHash(buf io.Reader) (txIn *txInToScriptHash, err error) {
|
|
||||||
err = UnimplementedError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseTxInToKey(buf io.Reader) (txIn *txInToKey, err error) {
|
func ParseTxInToKey(buf io.Reader) (txIn *txInToKey, err error) {
|
||||||
t := new(txInToKey)
|
t := new(txInToKey)
|
||||||
t.amount, err = ReadVarInt(buf)
|
t.amount, err = ReadVarInt(buf)
|
||||||
|
@ -308,26 +222,12 @@ func ParseTxIn(buf io.Reader) (txIn TxInSerializer, err error) {
|
||||||
switch {
|
switch {
|
||||||
case marker[0] == txInGenMarker:
|
case marker[0] == txInGenMarker:
|
||||||
txIn, err = ParseTxInGen(buf)
|
txIn, err = ParseTxInGen(buf)
|
||||||
case marker[0] == txInToScriptMarker:
|
|
||||||
txIn, err = ParseTxInToScript(buf)
|
|
||||||
case marker[0] == txInToScriptHashMarker:
|
|
||||||
txIn, err = ParseTxInToScriptHash(buf)
|
|
||||||
case marker[0] == txInToKeyMarker:
|
case marker[0] == txInToKeyMarker:
|
||||||
txIn, err = ParseTxInToKey(buf)
|
txIn, err = ParseTxInToKey(buf)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseTxOutToScript(buf io.Reader) (txOutTarget *txOutToScript, err error) {
|
|
||||||
err = UnimplementedError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseTxOutToScriptHash(buf io.Reader) (txOutTarget *txOutToScriptHash, err error) {
|
|
||||||
err = UnimplementedError
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseTxOutToKey(buf io.Reader) (txOutTarget *txOutToKey, err error) {
|
func ParseTxOutToKey(buf io.Reader) (txOutTarget *txOutToKey, err error) {
|
||||||
t := new(txOutToKey)
|
t := new(txOutToKey)
|
||||||
pubKey := make([]byte, KeyLength)
|
pubKey := make([]byte, KeyLength)
|
||||||
|
@ -360,10 +260,6 @@ func ParseTxOut(buf io.Reader) (txOut *TxOut, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
case marker[0] == txOutToScriptMarker:
|
|
||||||
t.target, err = ParseTxOutToScript(buf)
|
|
||||||
case marker[0] == txOutToScriptHashMarker:
|
|
||||||
t.target, err = ParseTxOutToScriptHash(buf)
|
|
||||||
case marker[0] == txOutToKeyMarker:
|
case marker[0] == txOutToKeyMarker:
|
||||||
t.target, err = ParseTxOutToKey(buf)
|
t.target, err = ParseTxOutToKey(buf)
|
||||||
default:
|
default:
|
||||||
|
|
Reference in a new issue