trying to store private identity key. Doesn't work.

This commit is contained in:
Tadge Dryja authored and Olaoluwa Osuntokun committed 2016-01-14 23:56:08 -08:00
1 parent 8bd8293c8c
commit e70c6aa367
6 files changed
+759 -2

No files matched your search

+31
View File
@@ -21,6 +21,8 @@ var (
closedChannelBucket = []byte("c")
activeChanKey = []byte("a")
identityKey = []byte("idkey")
// TODO(roasbeef): replace w/ tesnet-L also revisit dependancy...
ActiveNetParams = &chaincfg.TestNet3Params
)
@@ -95,6 +97,35 @@ type OpenChannel struct {
CreationTime time.Time
}
// These don't really belong here but not sure which other file to put them yet.
// PutIdKey saves the private key used for
func (c *DB) PutIdKey(priv *btcec.PrivateKey) error {
return c.namespace.Update(func(tx walletdb.Tx) error {
// Get the bucket dedicated to storing the meta-data for open
// channels.
rootBucket := tx.RootBucket()
return rootBucket.Put(identityKey, priv.Serialize())
})
}
// GetIdKey returns the IdKey
func (c *DB) GetIdKey() (*btcec.PrivateKey, error) {
var privbytes []byte
err := c.namespace.View(func(tx walletdb.Tx) error {
// Get the bucket dedicated to storing the meta-data for open
// channels.
rootBucket := tx.RootBucket()
privbytes = rootBucket.Get(identityKey)
return nil
})
if err != nil {
return nil, err
}
priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), privbytes)
return priv, nil
}
// PutOpenChannel...
func (c *DB) PutOpenChannel(channel *OpenChannel) error {
return c.namespace.Update(func(tx walletdb.Tx) error {