forked from TrueCloudLab/neoneo-go
core: remove Script attribute type
This commit is contained in:
parent
40e153030d
commit
08f5708edb
7 changed files with 16 additions and 55 deletions
|
@ -79,16 +79,12 @@ func getTX(t *testing.B, wif *keys.WIF) *transaction.Transaction {
|
|||
|
||||
tx := transaction.NewInvocationTX([]byte{0x51}, 1)
|
||||
tx.Version = 0
|
||||
tx.Sender = fromAddressHash
|
||||
tx.Attributes = append(tx.Attributes,
|
||||
transaction.Attribute{
|
||||
Usage: transaction.Description,
|
||||
Data: []byte(randString(10)),
|
||||
})
|
||||
tx.Attributes = append(tx.Attributes,
|
||||
transaction.Attribute{
|
||||
Usage: transaction.Script,
|
||||
Data: fromAddressHash.BytesBE(),
|
||||
})
|
||||
return tx
|
||||
}
|
||||
|
||||
|
|
|
@ -1548,17 +1548,6 @@ func (bc *Blockchain) GetScriptHashesForVerifying(t *transaction.Transaction) ([
|
|||
for i := range references {
|
||||
hashes[references[i].Out.ScriptHash] = true
|
||||
}
|
||||
for _, a := range t.Attributes {
|
||||
if a.Usage == transaction.Script {
|
||||
h, err := util.Uint160DecodeBytesBE(a.Data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, ok := hashes[h]; !ok {
|
||||
hashes[h] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for a, outputs := range t.GroupOutputByAssetID() {
|
||||
as := bc.GetAssetState(a)
|
||||
|
|
|
@ -10,7 +10,6 @@ const (
|
|||
ContractHash AttrUsage = 0x00
|
||||
ECDH02 AttrUsage = 0x02
|
||||
ECDH03 AttrUsage = 0x03
|
||||
Script AttrUsage = 0x20
|
||||
Vote AttrUsage = 0x30
|
||||
CertURL AttrUsage = 0x80
|
||||
DescriptionURL AttrUsage = 0x81
|
||||
|
|
|
@ -31,8 +31,6 @@ func (attr *Attribute) DecodeBinary(br *io.BinReader) {
|
|||
Hash6, Hash7, Hash8, Hash9, Hash10, Hash11, Hash12, Hash13,
|
||||
Hash14, Hash15:
|
||||
datasize = 32
|
||||
case Script:
|
||||
datasize = 20
|
||||
case DescriptionURL:
|
||||
// It's not VarUint as per C# implementation, dunno why
|
||||
var urllen = br.ReadB()
|
||||
|
@ -62,7 +60,7 @@ func (attr *Attribute) EncodeBinary(bw *io.BinWriter) {
|
|||
case DescriptionURL:
|
||||
bw.WriteB(byte(len(attr.Data)))
|
||||
fallthrough
|
||||
case Script, ContractHash, Vote, Hash1, Hash2, Hash3, Hash4, Hash5, Hash6,
|
||||
case ContractHash, Vote, Hash1, Hash2, Hash3, Hash4, Hash5, Hash6,
|
||||
Hash7, Hash8, Hash9, Hash10, Hash11, Hash12, Hash13, Hash14, Hash15:
|
||||
bw.WriteBytes(attr.Data)
|
||||
default:
|
||||
|
|
|
@ -11,7 +11,6 @@ func _() {
|
|||
_ = x[ContractHash-0]
|
||||
_ = x[ECDH02-2]
|
||||
_ = x[ECDH03-3]
|
||||
_ = x[Script-32]
|
||||
_ = x[Vote-48]
|
||||
_ = x[CertURL-128]
|
||||
_ = x[DescriptionURL-129]
|
||||
|
@ -52,19 +51,18 @@ func _() {
|
|||
const (
|
||||
_AttrUsage_name_0 = "ContractHash"
|
||||
_AttrUsage_name_1 = "ECDH02ECDH03"
|
||||
_AttrUsage_name_2 = "Script"
|
||||
_AttrUsage_name_3 = "Vote"
|
||||
_AttrUsage_name_4 = "CertURLDescriptionURL"
|
||||
_AttrUsage_name_5 = "Description"
|
||||
_AttrUsage_name_6 = "Hash1Hash2Hash3Hash4Hash5Hash6Hash7Hash8Hash9Hash10Hash11Hash12Hash13Hash14Hash15"
|
||||
_AttrUsage_name_7 = "RemarkRemark1Remark2Remark3Remark4Remark5Remark6Remark7Remark8Remark9Remark10Remark11Remark12Remark13Remark14Remark15"
|
||||
_AttrUsage_name_2 = "Vote"
|
||||
_AttrUsage_name_3 = "CertURLDescriptionURL"
|
||||
_AttrUsage_name_4 = "Description"
|
||||
_AttrUsage_name_5 = "Hash1Hash2Hash3Hash4Hash5Hash6Hash7Hash8Hash9Hash10Hash11Hash12Hash13Hash14Hash15"
|
||||
_AttrUsage_name_6 = "RemarkRemark1Remark2Remark3Remark4Remark5Remark6Remark7Remark8Remark9Remark10Remark11Remark12Remark13Remark14Remark15"
|
||||
)
|
||||
|
||||
var (
|
||||
_AttrUsage_index_1 = [...]uint8{0, 6, 12}
|
||||
_AttrUsage_index_4 = [...]uint8{0, 7, 21}
|
||||
_AttrUsage_index_6 = [...]uint8{0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 51, 57, 63, 69, 75, 81}
|
||||
_AttrUsage_index_7 = [...]uint8{0, 6, 13, 20, 27, 34, 41, 48, 55, 62, 69, 77, 85, 93, 101, 109, 117}
|
||||
_AttrUsage_index_3 = [...]uint8{0, 7, 21}
|
||||
_AttrUsage_index_5 = [...]uint8{0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 51, 57, 63, 69, 75, 81}
|
||||
_AttrUsage_index_6 = [...]uint8{0, 6, 13, 20, 27, 34, 41, 48, 55, 62, 69, 77, 85, 93, 101, 109, 117}
|
||||
)
|
||||
|
||||
func (i AttrUsage) String() string {
|
||||
|
@ -74,21 +72,19 @@ func (i AttrUsage) String() string {
|
|||
case 2 <= i && i <= 3:
|
||||
i -= 2
|
||||
return _AttrUsage_name_1[_AttrUsage_index_1[i]:_AttrUsage_index_1[i+1]]
|
||||
case i == 32:
|
||||
return _AttrUsage_name_2
|
||||
case i == 48:
|
||||
return _AttrUsage_name_3
|
||||
return _AttrUsage_name_2
|
||||
case 128 <= i && i <= 129:
|
||||
i -= 128
|
||||
return _AttrUsage_name_4[_AttrUsage_index_4[i]:_AttrUsage_index_4[i+1]]
|
||||
return _AttrUsage_name_3[_AttrUsage_index_3[i]:_AttrUsage_index_3[i+1]]
|
||||
case i == 144:
|
||||
return _AttrUsage_name_5
|
||||
return _AttrUsage_name_4
|
||||
case 161 <= i && i <= 175:
|
||||
i -= 161
|
||||
return _AttrUsage_name_6[_AttrUsage_index_6[i]:_AttrUsage_index_6[i+1]]
|
||||
return _AttrUsage_name_5[_AttrUsage_index_5[i]:_AttrUsage_index_5[i+1]]
|
||||
case 240 <= i && i <= 255:
|
||||
i -= 240
|
||||
return _AttrUsage_name_7[_AttrUsage_index_7[i]:_AttrUsage_index_7[i+1]]
|
||||
return _AttrUsage_name_6[_AttrUsage_index_6[i]:_AttrUsage_index_6[i+1]]
|
||||
default:
|
||||
return "AttrUsage(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
|
|
|
@ -107,14 +107,6 @@ func (t *Transaction) AddInput(in *Input) {
|
|||
t.Inputs = append(t.Inputs, *in)
|
||||
}
|
||||
|
||||
// AddVerificationHash adds a script attribute for transaction verification.
|
||||
func (t *Transaction) AddVerificationHash(addr util.Uint160) {
|
||||
t.Attributes = append(t.Attributes, Attribute{
|
||||
Usage: Script,
|
||||
Data: addr.BytesBE(),
|
||||
})
|
||||
}
|
||||
|
||||
// DecodeBinary implements Serializable interface.
|
||||
func (t *Transaction) DecodeBinary(br *io.BinReader) {
|
||||
t.Type = TXType(br.ReadB())
|
||||
|
|
|
@ -108,22 +108,13 @@ func (c *Client) TransferNEP5(acc *wallet.Account, to util.Uint160, token *walle
|
|||
emit.Opcode(w.BinWriter, opcode.THROWIFNOT)
|
||||
|
||||
tx := transaction.NewInvocationTX(w.Bytes(), gas)
|
||||
tx.Attributes = append(tx.Attributes, transaction.Attribute{
|
||||
Usage: transaction.Script,
|
||||
Data: from.BytesBE(),
|
||||
})
|
||||
tx.Sender = from
|
||||
|
||||
tx.ValidUntilBlock, err = c.CalculateValidUntilBlock()
|
||||
if err != nil {
|
||||
return util.Uint256{}, fmt.Errorf("can't calculate validUntilBlock: %v", err)
|
||||
}
|
||||
|
||||
addr, err := address.StringToUint160(acc.Address)
|
||||
if err != nil {
|
||||
return util.Uint256{}, fmt.Errorf("failed to get address: %v", err)
|
||||
}
|
||||
tx.Sender = addr
|
||||
|
||||
if err := request.AddInputsAndUnspentsToTx(tx, acc.Address, core.UtilityTokenID(), gas, c); err != nil {
|
||||
return util.Uint256{}, fmt.Errorf("can't add GAS to transaction: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue