rosetta-lbry/services/types.go

114 lines
3.2 KiB
Go
Raw Normal View History

2020-09-16 21:03:14 +02:00
// Copyright 2020 Coinbase, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package services
import (
"context"
"github.com/coinbase/rosetta-bitcoin/bitcoin"
"github.com/coinbase/rosetta-sdk-go/types"
)
2020-09-21 00:20:34 +02:00
const (
// NodeVersion is the version of
// bitcoin core we are using.
NodeVersion = "0.20.1"
// HistoricalBalanceLookup indicates
// that historical balance lookup is supported.
HistoricalBalanceLookup = true
2020-10-27 20:42:58 +01:00
2020-11-13 20:49:32 +01:00
// MempoolCoins indicates that
2020-11-13 20:24:06 +01:00
// including mempool coins in the /account/coins
// response is not supported.
2020-11-13 20:49:32 +01:00
MempoolCoins = false
2020-11-11 12:44:40 +01:00
2020-10-27 20:42:58 +01:00
// inlineFetchLimit is the maximum number
// of transactions to fetch inline.
inlineFetchLimit = 100
2020-09-21 00:20:34 +02:00
// MiddlewareVersion is the version
// of rosetta-bitcoin. We set this as a
// variable instead of a constant because
// we typically need the pointer of this
// value.
2020-12-02 18:10:37 +01:00
MiddlewareVersion = "0.0.8"
2020-09-21 00:20:34 +02:00
)
2020-09-16 21:03:14 +02:00
// Client is used by the servicers to get Peer information
// and to submit transactions.
type Client interface {
GetPeers(context.Context) ([]*types.Peer, error)
2020-09-16 21:03:14 +02:00
SendRawTransaction(context.Context, string) (string, error)
SuggestedFeeRate(context.Context, int64) (float64, error)
2020-09-19 03:04:37 +02:00
RawMempool(context.Context) ([]string, error)
2020-09-16 21:03:14 +02:00
}
// Indexer is used by the servicers to get block and account data.
type Indexer interface {
2020-10-27 18:25:02 +01:00
GetBlockLazy(
context.Context,
*types.PartialBlockIdentifier,
) (*types.BlockResponse, error)
2020-09-16 21:03:14 +02:00
GetBlockTransaction(
context.Context,
*types.BlockIdentifier,
*types.TransactionIdentifier,
) (*types.Transaction, error)
GetCoins(
context.Context,
*types.AccountIdentifier,
) ([]*types.Coin, *types.BlockIdentifier, error)
GetScriptPubKeys(
context.Context,
[]*types.Coin,
) ([]*bitcoin.ScriptPubKey, error)
2020-10-27 18:25:02 +01:00
GetBalance(
context.Context,
*types.AccountIdentifier,
*types.Currency,
*types.PartialBlockIdentifier,
) (*types.Amount, *types.BlockIdentifier, error)
2020-09-16 21:03:14 +02:00
}
type unsignedTransaction struct {
Transaction string `json:"transaction"`
ScriptPubKeys []*bitcoin.ScriptPubKey `json:"scriptPubKeys"`
InputAmounts []string `json:"input_amounts"`
InputAddresses []string `json:"input_addresses"`
}
type preprocessOptions struct {
Coins []*types.Coin `json:"coins"`
EstimatedSize float64 `json:"estimated_size"`
FeeMultiplier *float64 `json:"fee_multiplier,omitempty"`
}
type constructionMetadata struct {
ScriptPubKeys []*bitcoin.ScriptPubKey `json:"script_pub_keys"`
}
type signedTransaction struct {
Transaction string `json:"transaction"`
InputAmounts []string `json:"input_amounts"`
}
// ParseOperationMetadata is returned from
// ConstructionParse.
type ParseOperationMetadata struct {
ScriptPubKey *bitcoin.ScriptPubKey `json:"scriptPubKey"`
}