-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
client/zcash: replace deprecated address methods with unified address…
… parsing (#2237) getnewaddress and getrawchangeaddress RPCs are deprecated. There is no way to get a transparent address directly. Instead, get a unified address, parse "receivers", and pick out the transparent address. require 5.4.2 and handle RPC deprecations in harness.
- Loading branch information
Showing
8 changed files
with
719 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// This code is available on the terms of the project LICENSE.md file, | ||
// also available online at https://blueoakcouncil.org/license/1.0.0. | ||
|
||
package zec | ||
|
||
const ( | ||
methodZGetAddressForAccount = "z_getaddressforaccount" | ||
methodZListUnifiedReceivers = "z_listunifiedreceivers" | ||
methodZListAccounts = "z_listaccounts" | ||
methodZGetNewAccount = "z_getnewaccount" | ||
) | ||
|
||
type zListAccountsResult struct { | ||
Number uint32 `json:"account"` | ||
Addresses []struct { | ||
Diversifier uint32 `json:"diversifier"` | ||
UnifiedAddr string `json:"ua"` | ||
} `json:"addresses"` | ||
} | ||
|
||
// z_listaccounts | ||
func zListAccounts(c rpcCaller) (accts []zListAccountsResult, err error) { | ||
return accts, c.CallRPC(methodZListAccounts, nil, &accts) | ||
} | ||
|
||
// z_getnewaccount | ||
func zGetNewAccount(c rpcCaller) (uint32, error) { | ||
var res struct { | ||
Number uint32 `json:"account"` | ||
} | ||
if err := c.CallRPC(methodZGetNewAccount, nil, &res); err != nil { | ||
return 0, err | ||
} | ||
return res.Number, nil | ||
} | ||
|
||
type zGetAddressForAccountResult struct { | ||
Account uint32 `json:"account"` | ||
DiversifierIndex uint32 `json:"diversifier_index"` | ||
ReceiverTypes []string `json:"receiver_types"` | ||
Address string `json:"address"` | ||
} | ||
|
||
// z_getaddressforaccount account ( ["receiver_type", ...] diversifier_index ) | ||
func zGetAddressForAccount(c rpcCaller, acctNumber uint32, addrTypes []string) (unified *zGetAddressForAccountResult, err error) { | ||
return unified, c.CallRPC(methodZGetAddressForAccount, []interface{}{acctNumber, addrTypes}, &unified) | ||
} | ||
|
||
type unifiedReceivers struct { | ||
Transparent string `json:"p2pkh"` | ||
Orchard string `json:"orchard"` | ||
Sapling string `json:"sapling"` | ||
} | ||
|
||
// z_listunifiedreceivers unified_address | ||
func zGetUnifiedReceivers(c rpcCaller, unifiedAddr string) (receivers *unifiedReceivers, err error) { | ||
return receivers, c.CallRPC(methodZListUnifiedReceivers, []interface{}{unifiedAddr}, &receivers) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.