-
Notifications
You must be signed in to change notification settings - Fork 9
/
interface.go
44 lines (35 loc) · 1.96 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package transactions
import (
"crypto/ecdsa"
"github.com/gelembjuk/democoin/lib/wallet"
"github.com/gelembjuk/democoin/node/structures"
)
type UnApprovedTransactionCallbackInterface func(txhash, txstr string) error
type UnspentTransactionOutputCallbackInterface func(fromaddr string, value float64, txID []byte, output int, isbase bool) error
type TransactionsManagerInterface interface {
GetAddressBalance(address string) (wallet.WalletBalance, error)
GetUnapprovedCount() (int, error)
GetUnspentCount() (int, error)
GetUnapprovedTransactionsForNewBlock(number int) ([]*structures.Transaction, error)
GetIfExists(txid []byte) (*structures.Transaction, error)
GetIfUnapprovedExists(txid []byte) (*structures.Transaction, error)
VerifyTransaction(tx *structures.Transaction, prevtxs []*structures.Transaction, tip []byte) (bool, error)
ForEachUnspentOutput(address string, callback UnspentTransactionOutputCallbackInterface) error
ForEachUnapprovedTransaction(callback UnApprovedTransactionCallbackInterface) (int, error)
// Create transaction methods
CreateTransaction(PubKey []byte, privKey ecdsa.PrivateKey, to string, amount float64) (*structures.Transaction, error)
ReceivedNewTransaction(tx *structures.Transaction) error
ReceivedNewTransactionData(txBytes []byte, Signatures [][]byte) (*structures.Transaction, error)
PrepareNewTransaction(PubKey []byte, to string, amount float64) ([]byte, [][]byte, error)
// new block was created in blockchain DB. It must not be on top of primary blockchain
BlockAdded(block *structures.Block, ontopofchain bool) error
// block was removed from blockchain DB from top
BlockRemoved(block *structures.Block) error
// block was not in primary chain and now is
BlockAddedToPrimaryChain(block *structures.Block) error
// block was in primary chain and now is not
BlockRemovedFromPrimaryChain(block *structures.Block) error
CancelTransaction(txID []byte) error
ReindexData() (map[string]int, error)
CleanUnapprovedCache() error
}