-
Notifications
You must be signed in to change notification settings - Fork 5
/
txo.go
52 lines (45 loc) · 1.49 KB
/
txo.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
45
46
47
48
49
50
51
52
package payd
import (
"context"
"time"
)
// TxoCreate will add utxos to our data store linked by a destinationId.
// These are added when a user submit a tx to pay an invoice.
type TxoCreate struct {
Outpoint string `db:"outpoint"`
DestinationID uint64 `db:"destination_id"`
TxID string `db:"tx_id"`
Vout uint64 `db:"vout"`
}
// UTXO an internal utxo.
type UTXO struct {
Outpoint string `db:"outpoint"`
TxID string `db:"tx_id"`
Vout uint32 `db:"vout"`
Satoshis uint64 `db:"satoshis"`
LockingScript string `db:"locking_script"`
DerivationPath string `db:"derivation_path"`
}
// UTXOReserve takes args for marking a utxo in the db as reserved.
type UTXOReserve struct {
ReservedFor string
Satoshis uint64
}
// UTXOUnreserve takes args for unreserving reserved utxos in the db.
type UTXOUnreserve struct {
ReservedFor string
}
// UTXOSpend takes args for marking a utxo in the db as spent.
type UTXOSpend struct {
Timestamp time.Time `db:"timestamp"`
SpendingTxID string `db:"spending_txid"`
Reservation string `db:"reserved_for"`
}
// TxoWriter is used to add transaction information to a data store.
type TxoWriter interface {
// TxosCreate will add an array of txos to a data store.
// TxosCreate(ctx context.Context, req []*TxoCreate) error
UTXOReserve(ctx context.Context, req UTXOReserve) ([]UTXO, error)
UTXOUnreserve(ctx context.Context, req UTXOUnreserve) error
UTXOSpend(ctx context.Context, req UTXOSpend) error
}