本文整理匯總了Golang中github.com/btcsuite/btcwallet/waddrmgr.Manager.Encrypt方法的典型用法代碼示例。如果您正苦於以下問題:Golang Manager.Encrypt方法的具體用法?Golang Manager.Encrypt怎麽用?Golang Manager.Encrypt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/btcsuite/btcwallet/waddrmgr.Manager
的用法示例。
在下文中一共展示了Manager.Encrypt方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: encryptKeys
func encryptKeys(keys []string, mgr *waddrmgr.Manager, keyType waddrmgr.CryptoKeyType) ([][]byte, error) {
encryptedKeys := make([][]byte, len(keys))
var err error
for i, key := range keys {
if key == "" {
encryptedKeys[i] = nil
} else {
encryptedKeys[i], err = mgr.Encrypt(keyType, []byte(key))
}
if err != nil {
return nil, err
}
}
return encryptedKeys, nil
}
示例2: Encode
// Encode...
// TODO(roasbeef): checksum
func (o *OpenChannel) Encode(b io.Writer, addrManager *waddrmgr.Manager) error {
if _, err := b.Write(o.TheirLNID[:]); err != nil {
return err
}
if _, err := b.Write(o.ChanID[:]); err != nil {
return err
}
if err := binary.Write(b, endian, uint64(o.MinFeePerKb)); err != nil {
return err
}
encryptedPriv, err := addrManager.Encrypt(waddrmgr.CKTPrivate,
o.OurCommitKey.Serialize())
if err != nil {
return err
}
if _, err := b.Write(encryptedPriv); err != nil {
return err
}
if _, err := b.Write(o.TheirCommitKey.SerializeCompressed()); err != nil {
return err
}
if err := binary.Write(b, endian, uint64(o.Capacity)); err != nil {
return err
}
if err := binary.Write(b, endian, uint64(o.OurBalance)); err != nil {
return err
}
if err := binary.Write(b, endian, uint64(o.TheirBalance)); err != nil {
return err
}
if err := o.TheirCommitTx.Serialize(b); err != nil {
return err
}
if err := o.OurCommitTx.Serialize(b); err != nil {
return err
}
if err := o.FundingTx.Serialize(b); err != nil {
return err
}
encryptedPriv, err = addrManager.Encrypt(waddrmgr.CKTPrivate,
o.MultiSigKey.Serialize())
if err != nil {
return err
}
if _, err := b.Write(encryptedPriv); err != nil {
return err
}
if _, err := b.Write(o.FundingRedeemScript); err != nil {
return err
}
if _, err := b.Write(o.TheirCurrentRevocation[:]); err != nil {
return err
}
// TODO(roasbeef): serialize shachains
if _, err := b.Write([]byte(o.OurDeliveryAddress.EncodeAddress())); err != nil {
return err
}
if _, err := b.Write([]byte(o.TheirDeliveryAddress.EncodeAddress())); err != nil {
return err
}
if err := binary.Write(b, endian, o.CsvDelay); err != nil {
return err
}
if err := binary.Write(b, endian, o.NumUpdates); err != nil {
return err
}
if err := binary.Write(b, endian, o.TotalSatoshisSent); err != nil {
return err
}
if err := binary.Write(b, endian, o.TotalSatoshisReceived); err != nil {
return err
}
if err := binary.Write(b, endian, o.CreationTime.Unix()); err != nil {
return err
}
return nil
}