mirror of
https://github.com/arnaucube/slowlorisdb.git
synced 2026-02-28 05:46:48 +01:00
tmp use PubK instead of Addr, Add test add genesis block
This commit is contained in:
@@ -1,25 +1,28 @@
|
||||
package core
|
||||
|
||||
import "crypto/ecdsa"
|
||||
|
||||
type Input struct {
|
||||
TxId Hash
|
||||
Vout int // index of the output from the TxId
|
||||
Value uint64
|
||||
}
|
||||
|
||||
type Output struct {
|
||||
Value uint64
|
||||
}
|
||||
|
||||
// Tx holds the data structure of a transaction
|
||||
type Tx struct {
|
||||
From Address
|
||||
To Address
|
||||
From *ecdsa.PublicKey
|
||||
To *ecdsa.PublicKey
|
||||
InputCount uint64
|
||||
Inputs []Input
|
||||
Outputs []Output
|
||||
Signature []byte
|
||||
}
|
||||
|
||||
func NewTx(from, to Address, in []Input, out []Output) *Tx {
|
||||
func NewTx(from, to *ecdsa.PublicKey, in []Input, out []Output) *Tx {
|
||||
tx := &Tx{
|
||||
From: from,
|
||||
To: to,
|
||||
|
||||
@@ -7,13 +7,17 @@ import (
|
||||
)
|
||||
|
||||
func TestTx(t *testing.T) {
|
||||
addr0 := Address(HashBytes([]byte("addr0")))
|
||||
addr1 := Address(HashBytes([]byte("addr1")))
|
||||
privK0, err := NewKey()
|
||||
assert.Nil(t, err)
|
||||
pubK0 := privK0.PublicKey
|
||||
privK1, err := NewKey()
|
||||
assert.Nil(t, err)
|
||||
pubK1 := privK1.PublicKey
|
||||
|
||||
tx := NewTx(addr0, addr1, []Input{}, []Output{})
|
||||
tx := NewTx(&pubK0, &pubK1, []Input{}, []Output{})
|
||||
|
||||
assert.Equal(t, tx.From, addr0)
|
||||
assert.Equal(t, tx.To, addr1)
|
||||
assert.Equal(t, tx.From, &pubK0)
|
||||
assert.Equal(t, tx.To, &pubK1)
|
||||
|
||||
assert.True(t, CheckTx(tx))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user