github.com/turingchain2020/turingchain@v1.1.21/wallet/common/keys.go (about)

     1  // Copyright Turing Corp. 2018 All Rights Reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package common
     6  
     7  import "fmt"
     8  
     9  const (
    10  	keyAccount            = "Account"
    11  	keyAddr               = "Addr"
    12  	keyLabel              = "Label"
    13  	keyTx                 = "Tx"
    14  	keyEncryptionFlag     = "Encryption"
    15  	keyEncryptionCompFlag = "EncryptionFlag" // 中间有一段时间运行了一个错误的密码版本,导致有部分用户信息发生错误,需要兼容下
    16  	keyPasswordHash       = "PasswordHash"
    17  	keyWalletSeed         = "walletseed"
    18  	keyAirDropIndex       = "AirDropIndex" //存储通过seed生成的空投地址信息
    19  )
    20  
    21  // CalcAccountKey 用于所有Account账户的输出list,需要安装时间排序
    22  func CalcAccountKey(timestamp string, addr string) []byte {
    23  	return []byte(fmt.Sprintf("%s:%s:%s", keyAccount, timestamp, addr))
    24  }
    25  
    26  // CalcAddrKey 通过addr地址查询Account账户信息
    27  func CalcAddrKey(addr string) []byte {
    28  	return []byte(fmt.Sprintf("%s:%s", keyAddr, addr))
    29  }
    30  
    31  // CalcLabelKey 通过label查询Account账户信息
    32  func CalcLabelKey(label string) []byte {
    33  	return []byte(fmt.Sprintf("%s:%s", keyLabel, label))
    34  }
    35  
    36  // CalcTxKey 通过height*100000+index 查询Tx交易信息
    37  //key:Tx:height*100000+index
    38  func CalcTxKey(key string) []byte {
    39  	return []byte(fmt.Sprintf("%s:%s", keyTx, key))
    40  }
    41  
    42  // CalcEncryptionFlag 加密标志Key
    43  func CalcEncryptionFlag() []byte {
    44  	return []byte(keyEncryptionFlag)
    45  }
    46  
    47  // CalckeyEncryptionCompFlag 加密比较标志Key
    48  func CalckeyEncryptionCompFlag() []byte {
    49  	return []byte(keyEncryptionCompFlag)
    50  }
    51  
    52  // CalcPasswordHash 密码hash的Key
    53  func CalcPasswordHash() []byte {
    54  	return []byte(keyPasswordHash)
    55  }
    56  
    57  // CalcWalletSeed 钱包Seed的Key
    58  func CalcWalletSeed() []byte {
    59  	return []byte(keyWalletSeed)
    60  }
    61  
    62  // CalcAirDropIndex 通过钱包Seed指定index生成的空投地址
    63  func CalcAirDropIndex() []byte {
    64  	return []byte(keyAirDropIndex)
    65  }