Skip to content

Commit 77daa78

Browse files
committed
fix(): add pending tx api
1 parent 9d9e879 commit 77daa78

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

client.go

+15
Original file line numberDiff line numberDiff line change
@@ -479,3 +479,18 @@ func (c *Client) GetUnconfirmedTx(arId string) (*types.Transaction, error) {
479479
}
480480
return tx, nil
481481
}
482+
483+
func (c *Client) GetPendingTxIds() ([]string, error) {
484+
body, statusCode, err := c.httpGet("/tx/pending")
485+
if statusCode != 200 {
486+
return nil, errors.New("get pending txIds failed")
487+
}
488+
if err != nil {
489+
return nil, err
490+
}
491+
res := make([]string, 0)
492+
if err := json.Unmarshal(body, &res); err != nil {
493+
return nil, err
494+
}
495+
return res, nil
496+
}

client_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,10 @@ func TestClient_GetUnconfirmedTxFromPeers(t *testing.T) {
258258
assert.NoError(t, err)
259259
t.Log(tx)
260260
}
261+
262+
func TestNewClient(t *testing.T) {
263+
cli := NewClient("https://arweave.net")
264+
res, err := cli.GetPendingTxIds()
265+
assert.NoError(t, err)
266+
t.Log("pending tx number:", len(res))
267+
}

0 commit comments

Comments
 (0)