Skip to content

Commit

Permalink
Receive block as json result
Browse files Browse the repository at this point in the history
  • Loading branch information
Elbandi committed Dec 25, 2021
1 parent f395c36 commit 5cda86e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions rpcclient/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,22 @@ type FutureGetBlockResult struct {
Response chan *response
}

func (r FutureGetBlockResult) ReceiveBlock() (*btcjson.GetBlockVerboseResult, error) {
res, err := r.client.waitForGetBlockRes(r.Response, r.hash, false, false)
if err != nil {
return nil, err
}

// Unmarshal result as an array of listtransaction result objects.
var block btcjson.GetBlockVerboseResult
err = json.Unmarshal(res, &block)
if err != nil {
return nil, err
}

return &block, nil
}

// Receive waits for the response promised by the future and returns the raw
// block requested from the server given its hash.
func (r FutureGetBlockResult) Receive() (*wire.MsgBlock, error) {
Expand Down

0 comments on commit 5cda86e

Please sign in to comment.