Skip to content

Commit

Permalink
Add support to GetTreeState to return Orchard final state
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Smith authored and LarryRuane committed May 11, 2022
1 parent 6878935 commit ab4c0fe
Show file tree
Hide file tree
Showing 7 changed files with 397 additions and 141 deletions.
6 changes: 6 additions & 0 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ type (
}
SkipHash string
}
Orchard struct {
Commitments struct {
FinalState string
}
SkipHash string
}
}

// zcashd rpc "getrawtransaction txid 1" (1 means verbose), there are
Expand Down
11 changes: 9 additions & 2 deletions docs/rtd/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ <h3 id="cash.z.wallet.sdk.rpc.TreeState">TreeState</h3>
<td>height</td>
<td><a href="#uint64">uint64</a></td>
<td></td>
<td><p> </p></td>
<td><p>block height </p></td>
</tr>

<tr>
Expand All @@ -1514,12 +1514,19 @@ <h3 id="cash.z.wallet.sdk.rpc.TreeState">TreeState</h3>
</tr>

<tr>
<td>tree</td>
<td>saplingTree</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p>sapling commitment tree state </p></td>
</tr>

<tr>
<td>orchardTree</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p>orchard commitment tree state </p></td>
</tr>

</tbody>
</table>

Expand Down
11 changes: 6 additions & 5 deletions frontend/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,12 @@ func (s *lwdStreamer) GetTreeState(ctx context.Context, id *walletrpc.BlockID) (
return nil, errors.New("zcashd did not return treestate")
}
return &walletrpc.TreeState{
Network: s.chainName,
Height: uint64(gettreestateReply.Height),
Hash: gettreestateReply.Hash,
Time: gettreestateReply.Time,
Tree: gettreestateReply.Sapling.Commitments.FinalState,
Network: s.chainName,
Height: uint64(gettreestateReply.Height),
Hash: gettreestateReply.Hash,
Time: gettreestateReply.Time,
SaplingTree: gettreestateReply.Sapling.Commitments.FinalState,
OrchardTree: gettreestateReply.Orchard.Commitments.FinalState,
}, nil
}

Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.12

require (
github.com/btcsuite/btcd v0.20.1-beta
github.com/fullstorydev/grpcurl v1.8.6 // indirect
github.com/golang/protobuf v1.5.2
github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0
Expand All @@ -17,13 +18,11 @@ require (
github.com/spf13/afero v1.5.1 // indirect
github.com/spf13/cobra v0.0.6
github.com/spf13/viper v1.6.2
github.com/stretchr/testify v1.6.1 // indirect
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 // indirect
golang.org/x/text v0.3.6 // indirect
google.golang.org/genproto v0.0.0-20210406143921-e86de6bf7a46 // indirect
google.golang.org/grpc v1.37.0
google.golang.org/grpc v1.44.0
google.golang.org/protobuf v1.27.1
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.51.0
Expand Down
231 changes: 231 additions & 0 deletions go.sum

Large diffs are not rendered by default.

263 changes: 137 additions & 126 deletions walletrpc/service.pb.go

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions walletrpc/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,12 @@ message Exclude {

// The TreeState is derived from the Zcash z_gettreestate rpc.
message TreeState {
string network = 1; // "main" or "test"
uint64 height = 2;
string hash = 3; // block id
uint32 time = 4; // Unix epoch time when the block was mined
string tree = 5; // sapling commitment tree state
string network = 1; // "main" or "test"
uint64 height = 2; // block height
string hash = 3; // block id
uint32 time = 4; // Unix epoch time when the block was mined
string saplingTree = 5; // sapling commitment tree state
string orchardTree = 6; // orchard commitment tree state
}

// Results are sorted by height, which makes it easy to issue another
Expand Down

0 comments on commit ab4c0fe

Please sign in to comment.