@@ -57,6 +57,18 @@ func newUtxo(explorerUtxo ExplorerUtxo, delay uint) Utxo {
57
57
}
58
58
}
59
59
60
+ type ExplorerTx struct {
61
+ Txid string `json:"txid"`
62
+ Vout []struct {
63
+ Address string `json:"scriptpubkey_address"`
64
+ Amount uint64 `json:"value"`
65
+ } `json:"vout"`
66
+ Status struct {
67
+ Confirmed bool `json:"confirmed"`
68
+ Blocktime int64 `json:"block_time"`
69
+ } `json:"status"`
70
+ }
71
+
60
72
type ExplorerUtxo struct {
61
73
Txid string `json:"txid"`
62
74
Vout uint32 `json:"vout"`
@@ -75,6 +87,7 @@ func (e ExplorerUtxo) ToUtxo(delay uint) Utxo {
75
87
type Explorer interface {
76
88
GetTxHex (txid string ) (string , error )
77
89
Broadcast (txHex string ) (string , error )
90
+ GetTxs (addr string ) ([]ExplorerTx , error )
78
91
GetUtxos (addr string ) ([]ExplorerUtxo , error )
79
92
GetBalance (addr string ) (uint64 , error )
80
93
GetRedeemedVtxosBalance (
@@ -180,6 +193,28 @@ func (e *explorerSvc) Broadcast(txStr string) (string, error) {
180
193
return txid , nil
181
194
}
182
195
196
+ func (e * explorerSvc ) GetTxs (addr string ) ([]ExplorerTx , error ) {
197
+ resp , err := http .Get (fmt .Sprintf ("%s/address/%s/txs" , e .baseUrl , addr ))
198
+ if err != nil {
199
+ return nil , err
200
+ }
201
+
202
+ defer resp .Body .Close ()
203
+ body , err := io .ReadAll (resp .Body )
204
+ if err != nil {
205
+ return nil , err
206
+ }
207
+ if resp .StatusCode != http .StatusOK {
208
+ return nil , fmt .Errorf ("failed to get txs: %s" , string (body ))
209
+ }
210
+ payload := []ExplorerTx {}
211
+ if err := json .Unmarshal (body , & payload ); err != nil {
212
+ return nil , err
213
+ }
214
+
215
+ return payload , nil
216
+ }
217
+
183
218
func (e * explorerSvc ) GetUtxos (addr string ) ([]ExplorerUtxo , error ) {
184
219
resp , err := http .Get (fmt .Sprintf ("%s/address/%s/utxo" , e .baseUrl , addr ))
185
220
if err != nil {
0 commit comments