mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-23 07:16:47 +00:00

* '' * '' * '' * Changes genesis block version to 0. * a * a * All tests are done. * All tests passed for changed block version from int32 to uint16 * Adds validation of rejecting blocks with unknown versions. * Changes txn version from int32 to uint16. * . * Adds comments to exported functions. * Change functions name from ConvertFromRpcScriptPubKeyToRPCScriptPubKey to ConvertFromAppMsgRPCScriptPubKeyToRPCScriptPubKey and from ConvertFromRPCScriptPubKeyToRpcScriptPubKey to ConvertFromRPCScriptPubKeyToAppMsgRPCScriptPubKey * change comment to "ScriptPublicKey represents a Kaspad ScriptPublicKey" * delete part (tx.Version < 0) that cannot be exist on the if statement. * Revert protobuf version. * Fix a comment. * Fix a comment. * Rename a variable. * Rename a variable. * Remove a const. * Rename a type. * Rename a field. * Rename a field. * Remove commented-out code. * Remove dangerous nil case in DomainTransactionOutput.Clone(). * Remove a constant. * Fix a string. * Fix wrong totalScriptPubKeySize in transactionMassStandalonePart. * Remove a constant. * Remove an unused error. * Fix a serialization error. * Specify version types to be uint16 explicitly. * Use constants.ScriptPublicKeyVersion. * Fix a bad test. * Remove some whitespace. * Add a case to utxoEntry.Equal(). * Rename scriptPubKey to scriptPublicKey. * Remove a TODO. * Rename constants. * Rename a variable. * Add version to parseShortForm. Co-authored-by: tal <tal@daglabs.com> Co-authored-by: stasatdaglabs <stas@daglabs.com>
44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package transactionhelper
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
|
"github.com/kaspanet/kaspad/domain/consensus/utils/hashes"
|
|
"github.com/kaspanet/kaspad/domain/consensus/utils/subnetworks"
|
|
)
|
|
|
|
// NewSubnetworkTransaction returns a new trsnactions in the specified subnetwork with specified gas and payload
|
|
func NewSubnetworkTransaction(version uint16, inputs []*externalapi.DomainTransactionInput,
|
|
outputs []*externalapi.DomainTransactionOutput, subnetworkID *externalapi.DomainSubnetworkID,
|
|
gas uint64, payload []byte) *externalapi.DomainTransaction {
|
|
|
|
payloadHash := hashes.PayloadHash(payload)
|
|
return &externalapi.DomainTransaction{
|
|
Version: version,
|
|
Inputs: inputs,
|
|
Outputs: outputs,
|
|
LockTime: 0,
|
|
SubnetworkID: *subnetworkID,
|
|
Gas: gas,
|
|
PayloadHash: *payloadHash,
|
|
Payload: payload,
|
|
Fee: 0,
|
|
Mass: 0,
|
|
}
|
|
}
|
|
|
|
// NewNativeTransaction returns a new native transaction
|
|
func NewNativeTransaction(version uint16, inputs []*externalapi.DomainTransactionInput,
|
|
outputs []*externalapi.DomainTransactionOutput) *externalapi.DomainTransaction {
|
|
return &externalapi.DomainTransaction{
|
|
Version: version,
|
|
Inputs: inputs,
|
|
Outputs: outputs,
|
|
LockTime: 0,
|
|
SubnetworkID: subnetworks.SubnetworkIDNative,
|
|
Gas: 0,
|
|
Payload: []byte{},
|
|
Fee: 0,
|
|
Mass: 0,
|
|
}
|
|
}
|