mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
use.getOTAMixSet function
This commit is contained in:
parent
1be6007042
commit
9c6b076ed2
4 changed files with 55 additions and 1 deletions
|
|
@ -188,6 +188,10 @@ func EncodeBig(bigint *big.Int) string {
|
|||
return fmt.Sprintf("%#x", bigint)
|
||||
}
|
||||
|
||||
func Has0xPrefix(input string) bool {
|
||||
return len(input) >= 2 && input[0] == '0' && (input[1] == 'x' || input[1] == 'X')
|
||||
}
|
||||
|
||||
func has0xPrefix(input string) bool {
|
||||
return len(input) >= 2 && input[0] == '0' && (input[1] == 'x' || input[1] == 'X')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1531,6 +1531,48 @@ func (s *PublicTransactionPoolAPI) FillTransaction(ctx context.Context, args Sen
|
|||
return &SignTransactionResult{data, tx}, nil
|
||||
}
|
||||
|
||||
func (s *PublicTransactionPoolAPI) GetOTAMixSet(ctx context.Context, otaAddr string, setLen int) ([]string, error) {
|
||||
if setLen <= 0 {
|
||||
return []string{}, ErrInvalidOTAMixNum
|
||||
}
|
||||
|
||||
if uint64(setLen) > params.GetOTAMixSetMaxSize {
|
||||
return []string{}, ErrReqTooManyOTAMix
|
||||
}
|
||||
|
||||
if !hexutil.Has0xPrefix(otaAddr) {
|
||||
return []string{}, ErrInvalidOTAAddr
|
||||
}
|
||||
|
||||
orgOtaAddr := common.FromHex(otaAddr)
|
||||
if len(orgOtaAddr) < common.HashLength {
|
||||
return []string{}, ErrInvalidOTAAddr
|
||||
}
|
||||
|
||||
state, _, err := s.b.StateAndHeaderByNumber(ctx, rpc.BlockNumber(-1))
|
||||
if state == nil || err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
otaAX := orgOtaAddr[:common.HashLength]
|
||||
if len(orgOtaAddr) == common.UAddressLength {
|
||||
otaAX, _ = vm.GetAXFromUseAddr(orgOtaAddr)
|
||||
}
|
||||
|
||||
otaByteSet, _, err := vm.GetOTASet(state, otaAX, setLen)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ret := make([]string, 0, setLen)
|
||||
for _, otaByte := range otaByteSet {
|
||||
ret = append(ret, common.ToHex(otaByte))
|
||||
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// ComputeOTAPPKeys compute ota private key, public key and short address
|
||||
// from account address and ota full address.
|
||||
func (s *PublicTransactionPoolAPI) ComputeOTAPPKeys(ctx context.Context, address common.Address, inOtaAddr string) (string, error) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -13661,10 +13661,18 @@ module.exports = XMLHttpRequest;
|
|||
inputFormatter: [formatters.inputAddressFormatter, null]
|
||||
});
|
||||
|
||||
var getOTAMixSet = new Method({
|
||||
name: 'getOTAMixSet',
|
||||
call: 'use_getOTAMixSet',
|
||||
params: 2,
|
||||
inputFormatter: [null, null]
|
||||
});
|
||||
|
||||
return [
|
||||
getUseAddress,
|
||||
generateOneTimeAddress,
|
||||
computeOTAPPKeys,
|
||||
getOTAMixSet,
|
||||
];
|
||||
};
|
||||
var properties = function () {
|
||||
|
|
|
|||
Loading…
Reference in a new issue