-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpcmempooltransaction.go
269 lines (234 loc) · 9.49 KB
/
rpcmempooltransaction.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package maestrobitcoingosdk
import (
"context"
"errors"
"fmt"
"net/http"
"github.com/maestro-org/maestro-bitcoin-go-sdk/internal/apijson"
"github.com/maestro-org/maestro-bitcoin-go-sdk/internal/requestconfig"
"github.com/maestro-org/maestro-bitcoin-go-sdk/option"
)
// RpcMempoolTransactionService contains methods and other services that help with
// interacting with the Maestro API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewRpcMempoolTransactionService] method instead.
type RpcMempoolTransactionService struct {
Options []option.RequestOption
Ancestors *RpcMempoolTransactionAncestorService
Descendants *RpcMempoolTransactionDescendantService
}
// NewRpcMempoolTransactionService generates a new service that applies the given
// options to each request. These options are applied after the parent client's
// options (if there is one), and before any request-specific options.
func NewRpcMempoolTransactionService(opts ...option.RequestOption) (r *RpcMempoolTransactionService) {
r = &RpcMempoolTransactionService{}
r.Options = opts
r.Ancestors = NewRpcMempoolTransactionAncestorService(opts...)
r.Descendants = NewRpcMempoolTransactionDescendantService(opts...)
return
}
// Mempool Transaction Details
func (r *RpcMempoolTransactionService) Get(ctx context.Context, txHash string, opts ...option.RequestOption) (res *TimestampedMempoolTransactionDetails, err error) {
opts = append(r.Options[:], opts...)
if txHash == "" {
err = errors.New("missing required tx_hash parameter")
return
}
path := fmt.Sprintf("rpc/mempool/transactions/%s", txHash)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
// List Mempool Transactions
func (r *RpcMempoolTransactionService) List(ctx context.Context, opts ...option.RequestOption) (res *TimestampedMempoolTransactions, err error) {
opts = append(r.Options[:], opts...)
path := "rpc/mempool/transactions"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
type TimestampedMempoolTransactionDetails struct {
Data TimestampedMempoolTransactionDetailsData `json:"data,required"`
LastUpdated TimestampedMempoolTransactionDetailsLastUpdated `json:"last_updated,required"`
JSON timestampedMempoolTransactionDetailsJSON `json:"-"`
}
// timestampedMempoolTransactionDetailsJSON contains the JSON metadata for the
// struct [TimestampedMempoolTransactionDetails]
type timestampedMempoolTransactionDetailsJSON struct {
Data apijson.Field
LastUpdated apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *TimestampedMempoolTransactionDetails) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r timestampedMempoolTransactionDetailsJSON) RawJSON() string {
return r.raw
}
type TimestampedMempoolTransactionDetailsData struct {
// Number of ancestors
AncestorCount int64 `json:"ancestor_count,required"`
// Size of ancestors
AncestorSize int64 `json:"ancestor_size,required"`
// Whether the transaction is BIP 125 replaceable
Bip125Replaceable bool `json:"bip125_replaceable,required"`
// Dependencies of the transaction
Depends []string `json:"depends,required"`
// Number of descendants
DescendantCount int64 `json:"descendant_count,required"`
// Size of descendants
DescendantSize int64 `json:"descendant_size,required"`
Fees TimestampedMempoolTransactionDetailsDataFees `json:"fees,required"`
// Block height
Height int64 `json:"height,required"`
// Transactions that spend this one
SpentBy []string `json:"spent_by,required"`
// Time of the transaction
Time int64 `json:"time,required"`
// Whether the transaction is unbroadcast
Unbroadcast bool `json:"unbroadcast,required"`
// Virtual size of the transaction
Vsize int64 `json:"vsize,required"`
// Weight of the transaction
Weight int64 `json:"weight,required"`
// Witness transaction ID
WtxID string `json:"wtx_id,required"`
JSON timestampedMempoolTransactionDetailsDataJSON `json:"-"`
}
// timestampedMempoolTransactionDetailsDataJSON contains the JSON metadata for the
// struct [TimestampedMempoolTransactionDetailsData]
type timestampedMempoolTransactionDetailsDataJSON struct {
AncestorCount apijson.Field
AncestorSize apijson.Field
Bip125Replaceable apijson.Field
Depends apijson.Field
DescendantCount apijson.Field
DescendantSize apijson.Field
Fees apijson.Field
Height apijson.Field
SpentBy apijson.Field
Time apijson.Field
Unbroadcast apijson.Field
Vsize apijson.Field
Weight apijson.Field
WtxID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *TimestampedMempoolTransactionDetailsData) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r timestampedMempoolTransactionDetailsDataJSON) RawJSON() string {
return r.raw
}
type TimestampedMempoolTransactionDetailsDataFees struct {
// Ancestor fee
Ancestor string `json:"ancestor,required"`
// Base fee
Base string `json:"base,required"`
// Descendant fee
Descendant string `json:"descendant,required"`
// Modified fee
Modified string `json:"modified,required"`
JSON timestampedMempoolTransactionDetailsDataFeesJSON `json:"-"`
}
// timestampedMempoolTransactionDetailsDataFeesJSON contains the JSON metadata for
// the struct [TimestampedMempoolTransactionDetailsDataFees]
type timestampedMempoolTransactionDetailsDataFeesJSON struct {
Ancestor apijson.Field
Base apijson.Field
Descendant apijson.Field
Modified apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *TimestampedMempoolTransactionDetailsDataFees) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r timestampedMempoolTransactionDetailsDataFeesJSON) RawJSON() string {
return r.raw
}
type TimestampedMempoolTransactionDetailsLastUpdated struct {
// The hash of the block
BlockHash string `json:"block_hash,required"`
// The height of the block in the blockchain
BlockHeight int64 `json:"block_height,required"`
JSON timestampedMempoolTransactionDetailsLastUpdatedJSON `json:"-"`
}
// timestampedMempoolTransactionDetailsLastUpdatedJSON contains the JSON metadata
// for the struct [TimestampedMempoolTransactionDetailsLastUpdated]
type timestampedMempoolTransactionDetailsLastUpdatedJSON struct {
BlockHash apijson.Field
BlockHeight apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *TimestampedMempoolTransactionDetailsLastUpdated) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r timestampedMempoolTransactionDetailsLastUpdatedJSON) RawJSON() string {
return r.raw
}
type TimestampedMempoolTransactions struct {
Data TimestampedMempoolTransactionsData `json:"data,required"`
LastUpdated TimestampedMempoolTransactionsLastUpdated `json:"last_updated,required"`
JSON timestampedMempoolTransactionsJSON `json:"-"`
}
// timestampedMempoolTransactionsJSON contains the JSON metadata for the struct
// [TimestampedMempoolTransactions]
type timestampedMempoolTransactionsJSON struct {
Data apijson.Field
LastUpdated apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *TimestampedMempoolTransactions) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r timestampedMempoolTransactionsJSON) RawJSON() string {
return r.raw
}
type TimestampedMempoolTransactionsData struct {
// Sequence number of the mempool
MempoolSequence int64 `json:"mempool_sequence,required"`
// List of transaction IDs
TxIDs []string `json:"tx_ids,required"`
JSON timestampedMempoolTransactionsDataJSON `json:"-"`
}
// timestampedMempoolTransactionsDataJSON contains the JSON metadata for the struct
// [TimestampedMempoolTransactionsData]
type timestampedMempoolTransactionsDataJSON struct {
MempoolSequence apijson.Field
TxIDs apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *TimestampedMempoolTransactionsData) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r timestampedMempoolTransactionsDataJSON) RawJSON() string {
return r.raw
}
type TimestampedMempoolTransactionsLastUpdated struct {
// The hash of the block
BlockHash string `json:"block_hash,required"`
// The height of the block in the blockchain
BlockHeight int64 `json:"block_height,required"`
JSON timestampedMempoolTransactionsLastUpdatedJSON `json:"-"`
}
// timestampedMempoolTransactionsLastUpdatedJSON contains the JSON metadata for the
// struct [TimestampedMempoolTransactionsLastUpdated]
type timestampedMempoolTransactionsLastUpdatedJSON struct {
BlockHash apijson.Field
BlockHeight apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *TimestampedMempoolTransactionsLastUpdated) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r timestampedMempoolTransactionsLastUpdatedJSON) RawJSON() string {
return r.raw
}