rpc: recognize the new unused prefix address types
This commit is contained in:
parent
8c1181af3b
commit
65cdb1294e
5
mock.go
5
mock.go
@ -226,6 +226,11 @@ func (m *mockWalletController) NewAddress(addrType lnwallet.AddressType,
|
|||||||
m.rootKey.PubKey().SerializeCompressed(), &chaincfg.MainNetParams)
|
m.rootKey.PubKey().SerializeCompressed(), &chaincfg.MainNetParams)
|
||||||
return addr, nil
|
return addr, nil
|
||||||
}
|
}
|
||||||
|
func (*mockWalletController) LastUnusedAddress(addrType lnwallet.AddressType) (
|
||||||
|
btcutil.Address, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (*mockWalletController) IsOurAddress(a btcutil.Address) bool {
|
func (*mockWalletController) IsOurAddress(a btcutil.Address) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
41
rpcserver.go
41
rpcserver.go
@ -932,17 +932,42 @@ func (r *rpcServer) NewAddress(ctx context.Context,
|
|||||||
|
|
||||||
// Translate the gRPC proto address type to the wallet controller's
|
// Translate the gRPC proto address type to the wallet controller's
|
||||||
// available address types.
|
// available address types.
|
||||||
var addrType lnwallet.AddressType
|
var (
|
||||||
|
addr btcutil.Address
|
||||||
|
err error
|
||||||
|
)
|
||||||
switch in.Type {
|
switch in.Type {
|
||||||
case lnrpc.AddressType_WITNESS_PUBKEY_HASH:
|
case lnrpc.AddressType_WITNESS_PUBKEY_HASH:
|
||||||
addrType = lnwallet.WitnessPubKey
|
addr, err = r.server.cc.wallet.NewAddress(
|
||||||
case lnrpc.AddressType_NESTED_PUBKEY_HASH:
|
lnwallet.WitnessPubKey, false,
|
||||||
addrType = lnwallet.NestedWitnessPubKey
|
)
|
||||||
}
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
addr, err := r.server.cc.wallet.NewAddress(addrType, false)
|
case lnrpc.AddressType_NESTED_PUBKEY_HASH:
|
||||||
if err != nil {
|
addr, err = r.server.cc.wallet.NewAddress(
|
||||||
return nil, err
|
lnwallet.NestedWitnessPubKey, false,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
case lnrpc.AddressType_UNUSED_WITNESS_PUBKEY_HASH:
|
||||||
|
addr, err = r.server.cc.wallet.LastUnusedAddress(
|
||||||
|
lnwallet.WitnessPubKey,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
case lnrpc.AddressType_UNUSED_NESTED_PUBKEY_HASH:
|
||||||
|
addr, err = r.server.cc.wallet.LastUnusedAddress(
|
||||||
|
lnwallet.NestedWitnessPubKey,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcsLog.Infof("[newaddress] addr=%v", addr.String())
|
rpcsLog.Infof("[newaddress] addr=%v", addr.String())
|
||||||
|
Loading…
Reference in New Issue
Block a user