trying to store id pkh. Doesn't work; wallet creation never completes
This commit is contained in:
parent
e70c6aa367
commit
8504362c5e
@ -99,31 +99,30 @@ type OpenChannel struct {
|
|||||||
|
|
||||||
// These don't really belong here but not sure which other file to put them yet.
|
// These don't really belong here but not sure which other file to put them yet.
|
||||||
// PutIdKey saves the private key used for
|
// PutIdKey saves the private key used for
|
||||||
func (c *DB) PutIdKey(priv *btcec.PrivateKey) error {
|
func (c *DB) PutIdKey(pkh []byte) error {
|
||||||
return c.namespace.Update(func(tx walletdb.Tx) error {
|
return c.namespace.Update(func(tx walletdb.Tx) error {
|
||||||
// Get the bucket dedicated to storing the meta-data for open
|
// Get the bucket dedicated to storing the meta-data for open
|
||||||
// channels.
|
// channels.
|
||||||
rootBucket := tx.RootBucket()
|
rootBucket := tx.RootBucket()
|
||||||
return rootBucket.Put(identityKey, priv.Serialize())
|
return rootBucket.Put(identityKey, pkh)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIdKey returns the IdKey
|
// GetIdKey returns the IdKey
|
||||||
func (c *DB) GetIdKey() (*btcec.PrivateKey, error) {
|
func (c *DB) GetIdAdr() (*btcutil.AddressPubKeyHash, error) {
|
||||||
var privbytes []byte
|
var pkh []byte
|
||||||
err := c.namespace.View(func(tx walletdb.Tx) error {
|
err := c.namespace.View(func(tx walletdb.Tx) error {
|
||||||
// Get the bucket dedicated to storing the meta-data for open
|
// Get the bucket dedicated to storing the meta-data for open
|
||||||
// channels.
|
// channels.
|
||||||
rootBucket := tx.RootBucket()
|
rootBucket := tx.RootBucket()
|
||||||
privbytes = rootBucket.Get(identityKey)
|
pkh = rootBucket.Get(identityKey)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
fmt.Printf("identity key has length %d\n", len(pkh))
|
||||||
priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), privbytes)
|
return btcutil.NewAddressPubKeyHash(pkh, ActiveNetParams)
|
||||||
return priv, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutOpenChannel...
|
// PutOpenChannel...
|
||||||
|
@ -285,7 +285,7 @@ func NewLightningWallet(config *Config) (*LightningWallet, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
priv, err := adrs[0].(waddrmgr.ManagedPubKeyAddress).PrivKey()
|
idPubkeyHash := adrs[0].Address().ScriptAddress()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -294,11 +294,11 @@ func NewLightningWallet(config *Config) (*LightningWallet, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
cdb := channeldb.New(wallet.Manager, lnNamespace)
|
cdb := channeldb.New(wallet.Manager, lnNamespace)
|
||||||
err = cdb.PutIdKey(priv)
|
err = cdb.PutIdKey(idPubkeyHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
fmt.Printf("stored private identity key in channeldb\n")
|
fmt.Printf("stored identity key pubkey hash in channeldb\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wallet has been created and been initialized at this point, open it
|
// Wallet has been created and been initialized at this point, open it
|
||||||
|
14
rpcserver.go
14
rpcserver.go
@ -76,13 +76,21 @@ func (r *rpcServer) TCPListen(ctx context.Context,
|
|||||||
// LnListen listens on the default port for incoming connections
|
// LnListen listens on the default port for incoming connections
|
||||||
//ignore args and launch listener goroutine
|
//ignore args and launch listener goroutine
|
||||||
|
|
||||||
priv, err := r.lnwallet.ChannelDB.GetIdKey()
|
adr, err := r.lnwallet.ChannelDB.GetIdAdr()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("got a private key. %x\n", priv.Serialize())
|
fmt.Printf("got ID address: %s\n", adr.String())
|
||||||
|
adr2, err := r.lnwallet.Manager.Address(adr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
priv, err := adr2.(waddrmgr.ManagedPubKeyAddress).PrivKey()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
fmt.Printf("got privkey %x\n", priv.Serialize())
|
||||||
// go TCPListener()
|
// go TCPListener()
|
||||||
|
|
||||||
resp := new(lnrpc.TCPListenResponse)
|
resp := new(lnrpc.TCPListenResponse)
|
||||||
|
Loading…
Reference in New Issue
Block a user