Documentation ¶
Index ¶
- type BitcoinTx
- type BitcoinTxInfo
- type BitcoinTxStatus
- type DB
- func (db DB) Close() error
- func (db *DB) GetBitcoinTx(signRequestID uint64, btcTxID []byte) (*BitcoinTx, error)
- func (db *DB) GetBitcoinTxsToBroadcast() ([]IkaSignRequest, error)
- func (db *DB) GetBroadcastedBitcoinTxsInfo() ([]BitcoinTxInfo, error)
- func (db DB) GetIkaSignRequestByID(id uint64) (*IkaSignRequest, error)
- func (db *DB) GetIkaSignRequestWithStatus(id uint64) (*IkaSignRequest, IkaTxStatus, error)
- func (db *DB) GetIkaTx(signRequestID uint64, ikaTxID string) (*IkaTx, error)
- func (db *DB) GetPendingIkaSignRequests() ([]IkaSignRequest, error)
- func (db *DB) InitDB() error
- func (db *DB) InsertBtcTx(tx BitcoinTx) error
- func (db *DB) InsertIkaSignRequest(signReq IkaSignRequest) error
- func (db *DB) InsertIkaTx(tx IkaTx) error
- func (db *DB) UpdateBitcoinTxToConfirmed(id uint64, txID []byte) error
- func (db *DB) UpdateIkaSignRequestFinalSig(id uint64, finalSig Signature) error
- type IkaSignRequest
- type IkaTx
- type IkaTxStatus
- type Payload
- type Signature
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitcoinTx ¶
type BitcoinTx struct { // SrId is a ika sign request ID SrID uint64 `json:"sr_id"` Status BitcoinTxStatus `json:"status"` BtcTxID []byte `json:"btc_sr_id"` Timestamp int64 `json:"time"` Note string `json:"note"` }
BitcoinTx represents a row in the `bitcoin_txs` table.
type BitcoinTxInfo ¶
type BitcoinTxInfo struct { TxID uint64 `json:"sr_id"` BtcTxID []byte `json:"btc_sr_id"` Status BitcoinTxStatus `json:"status"` }
BitcoinTxInfo holds the relevant information for a Bitcoin transaction.
type BitcoinTxStatus ¶
type BitcoinTxStatus byte
BitcoinTxStatus represents the different states of a bitcoin transaction.
const ( Pending BitcoinTxStatus = iota Broadcasted Confirmed )
Bitcoin transaction status constants
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB holds the database connection and provides methods for interacting with it.
func (*DB) GetBitcoinTx ¶
GetBitcoinTx retrieves a Bitcoin transaction by its primary key (sr_id and btc_sr_id).
func (*DB) GetBitcoinTxsToBroadcast ¶
func (db *DB) GetBitcoinTxsToBroadcast() ([]IkaSignRequest, error)
GetBitcoinTxsToBroadcast retrieves IkaSignRequests that have been signed by IKA and are due to be broadcasted to bitcoin.
This function checks for the following conditions: - The IkaSignRequest must have a final signature (final_sig IS NOT NULL). - There must be no corresponding entry in the bitcoin_txs table, OR - There must be only one corresponding entry in the bitcoin_txs table with a status of "Pending".
The reason for checking these conditions is that we cannot have a Bitcoin transaction hash (btc_tx_id) before the first broadcast attempt.
func (*DB) GetBroadcastedBitcoinTxsInfo ¶
func (db *DB) GetBroadcastedBitcoinTxsInfo() ([]BitcoinTxInfo, error)
GetBroadcastedBitcoinTxsInfo queries Bitcoin transactions that has been braodcasted but not confirmed. that do not have a "Confirmed" status.
func (DB) GetIkaSignRequestByID ¶
func (db DB) GetIkaSignRequestByID(id uint64) (*IkaSignRequest, error)
GetIkaSignRequestByID retrives a signature request by its id
func (*DB) GetIkaSignRequestWithStatus ¶
func (db *DB) GetIkaSignRequestWithStatus(id uint64) (*IkaSignRequest, IkaTxStatus, error)
GetIkaSignRequestWithStatus retrieves an IkaSignRequest with its associated IkaTx status.
func (*DB) GetIkaTx ¶
GetIkaTx retrieves an Ika transaction by its primary key (sr_id and ika_sr_id).
func (*DB) GetPendingIkaSignRequests ¶
func (db *DB) GetPendingIkaSignRequests() ([]IkaSignRequest, error)
GetPendingIkaSignRequests retrieves IkaSignRequests that need to be signed.
func (*DB) InsertBtcTx ¶
InsertBtcTx inserts a new Bitcoin transaction into the database.
func (*DB) InsertIkaSignRequest ¶
func (db *DB) InsertIkaSignRequest(signReq IkaSignRequest) error
InsertIkaSignRequest inserts a new transaction into the database
func (*DB) InsertIkaTx ¶
InsertIkaTx inserts a new Ika transaction into the database.
func (*DB) UpdateBitcoinTxToConfirmed ¶
UpdateBitcoinTxToConfirmed updates the bitcoin transaction to `Confirmed`.
type IkaSignRequest ¶
type IkaSignRequest struct { ID uint64 `json:"id"` Payload Payload `json:"payload"` DWalletID string `json:"dwallet_id"` UserSig string `json:"user_sig"` FinalSig Signature `json:"final_sig"` Timestamp int64 `json:"time"` }
IkaSignRequest represents a row in the `ika_sign_requests` table.
type IkaTx ¶
type IkaTx struct { // SrId is a ika sign request ID SrID uint64 `json:"sr_id"` Status IkaTxStatus `json:"status"` IkaTxID string `json:"ika_sr_id"` Timestamp int64 `json:"time"` Note string `json:"note"` }
IkaTx represents a row in the `ika_txs` table.
type IkaTxStatus ¶
type IkaTxStatus byte
IkaTxStatus represents the different states of a native transaction.
const ( Success IkaTxStatus = iota Failed )
Ika transaction status constants