forked from FactomProject/factom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
receipt.go
49 lines (42 loc) · 1.29 KB
/
receipt.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
// Copyright 2015 Factom Foundation
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package factom
import (
"encoding/json"
)
func GetReceipt(hash string) (*Receipt, error) {
type receiptResponse struct {
Receipt *Receipt `json:"receipt"`
}
params := hashRequest{Hash: hash}
req := NewJSON2Request("receipt", APICounter(), params)
resp, err := factomdRequest(req)
if err != nil {
return nil, err
}
if resp.Error != nil {
return nil, resp.Error
}
rec := new(receiptResponse)
if err := json.Unmarshal(resp.JSONResult(), rec); err != nil {
return nil, err
}
return rec.Receipt, nil
}
type Receipt struct {
Entry struct {
Raw string `json:"raw,omitempty"`
EntryHash string `json:"entryhash,omitempty"`
Json string `json:"json,omitempty"`
} `json:"entry,omitempty"`
MerkleBranch []struct {
Left string `json:"left,omitempty"`
Right string `json:"right,omitempty"`
Top string `json:"top,omitempty"`
} `json:"merklebranch,omitempty"`
EntryBlockKeyMR string `json:"entryblockkeymr,omitempty"`
DirectoryBlockKeyMR string `json:"directoryblockkeymr,omitempty"`
BitcoinTransactionHash string `json:"bitcointransactionhash,omitempty"`
BitcoinBlockHash string `json:"bitcoinblockhash,omitempty"`
}