mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-04 19:02:28 +00:00
core: add nonce field to transaction
1. Closes #840: added Nonce field to transaction.Transaction and removed Nonce field from transaction.MinerTx 2. Added following methods to different tx types: - NewMinerTx() - NewMinerTxWithNonce(...) - NewEnrollmentTx(...) - NewIssueTx() - NewPublishTx(...) - NewRegisterTx(...) - NewStateTx(...) in order to avoid code duplication when new transaction is created. 3. Commented out test cases where binary transaction/block are used. These test cases marked with `TODO NEO3.0: Update binary` and need to be updated. 4. Updated other tests 5. Added constant Nonce to GoveringTockenTx, UtilityTokenTx and genesis block to avoid data variability. Also marked with TODO.
This commit is contained in:
parent
d1f92a585b
commit
65503aa9b4
34 changed files with 354 additions and 332 deletions
|
@ -58,39 +58,32 @@ func createGenesisBlock(cfg config.ProtocolConfiguration) (*block.Block, error)
|
|||
}
|
||||
scriptOut := hash.Hash160(rawScript)
|
||||
|
||||
minerTx := transaction.NewMinerTXWithNonce(2083236893)
|
||||
|
||||
issueTx := transaction.NewIssueTX()
|
||||
// TODO NEO3.0: nonce should be constant to avoid variability of genesis block
|
||||
issueTx.Nonce = 0
|
||||
issueTx.Outputs = []transaction.Output{
|
||||
{
|
||||
AssetID: governingTokenTX.Hash(),
|
||||
Amount: governingTokenTX.Data.(*transaction.RegisterTX).Amount,
|
||||
ScriptHash: scriptOut,
|
||||
},
|
||||
}
|
||||
issueTx.Scripts = []transaction.Witness{
|
||||
{
|
||||
InvocationScript: []byte{},
|
||||
VerificationScript: []byte{byte(opcode.PUSHT)},
|
||||
},
|
||||
}
|
||||
|
||||
b := &block.Block{
|
||||
Base: base,
|
||||
Transactions: []*transaction.Transaction{
|
||||
{
|
||||
Type: transaction.MinerType,
|
||||
Data: &transaction.MinerTX{
|
||||
Nonce: 2083236893,
|
||||
},
|
||||
Attributes: []transaction.Attribute{},
|
||||
Inputs: []transaction.Input{},
|
||||
Outputs: []transaction.Output{},
|
||||
Scripts: []transaction.Witness{},
|
||||
},
|
||||
minerTx,
|
||||
&governingTokenTX,
|
||||
&utilityTokenTX,
|
||||
{
|
||||
Type: transaction.IssueType,
|
||||
Data: &transaction.IssueTX{}, // no fields.
|
||||
Inputs: []transaction.Input{},
|
||||
Outputs: []transaction.Output{
|
||||
{
|
||||
AssetID: governingTokenTX.Hash(),
|
||||
Amount: governingTokenTX.Data.(*transaction.RegisterTX).Amount,
|
||||
ScriptHash: scriptOut,
|
||||
},
|
||||
},
|
||||
Scripts: []transaction.Witness{
|
||||
{
|
||||
InvocationScript: []byte{},
|
||||
VerificationScript: []byte{byte(opcode.PUSHT)},
|
||||
},
|
||||
},
|
||||
},
|
||||
issueTx,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -111,14 +104,9 @@ func init() {
|
|||
Admin: admin,
|
||||
}
|
||||
|
||||
governingTokenTX = transaction.Transaction{
|
||||
Type: transaction.RegisterType,
|
||||
Data: registerTX,
|
||||
Attributes: []transaction.Attribute{},
|
||||
Inputs: []transaction.Input{},
|
||||
Outputs: []transaction.Output{},
|
||||
Scripts: []transaction.Witness{},
|
||||
}
|
||||
governingTokenTX = *transaction.NewRegisterTX(registerTX)
|
||||
// TODO NEO3.0: nonce should be constant to avoid variability of token hash
|
||||
governingTokenTX.Nonce = 0
|
||||
|
||||
admin = hash.Hash160([]byte{byte(opcode.PUSHF)})
|
||||
registerTX = &transaction.RegisterTX{
|
||||
|
@ -128,14 +116,9 @@ func init() {
|
|||
Precision: 8,
|
||||
Admin: admin,
|
||||
}
|
||||
utilityTokenTX = transaction.Transaction{
|
||||
Type: transaction.RegisterType,
|
||||
Data: registerTX,
|
||||
Attributes: []transaction.Attribute{},
|
||||
Inputs: []transaction.Input{},
|
||||
Outputs: []transaction.Output{},
|
||||
Scripts: []transaction.Witness{},
|
||||
}
|
||||
utilityTokenTX = *transaction.NewRegisterTX(registerTX)
|
||||
// TODO NEO3.0: nonce should be constant to avoid variability of token hash
|
||||
utilityTokenTX.Nonce = 0
|
||||
}
|
||||
|
||||
// GoverningTokenID returns the governing token (NEO) hash.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue