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)
|
||||
return addr, nil
|
||||
}
|
||||
func (*mockWalletController) LastUnusedAddress(addrType lnwallet.AddressType) (
|
||||
btcutil.Address, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (*mockWalletController) IsOurAddress(a btcutil.Address) bool {
|
||||
return false
|
||||
}
|
||||
|
39
rpcserver.go
39
rpcserver.go
@ -932,19 +932,44 @@ func (r *rpcServer) NewAddress(ctx context.Context,
|
||||
|
||||
// Translate the gRPC proto address type to the wallet controller's
|
||||
// available address types.
|
||||
var addrType lnwallet.AddressType
|
||||
var (
|
||||
addr btcutil.Address
|
||||
err error
|
||||
)
|
||||
switch in.Type {
|
||||
case lnrpc.AddressType_WITNESS_PUBKEY_HASH:
|
||||
addrType = lnwallet.WitnessPubKey
|
||||
case lnrpc.AddressType_NESTED_PUBKEY_HASH:
|
||||
addrType = lnwallet.NestedWitnessPubKey
|
||||
}
|
||||
|
||||
addr, err := r.server.cc.wallet.NewAddress(addrType, false)
|
||||
addr, err = r.server.cc.wallet.NewAddress(
|
||||
lnwallet.WitnessPubKey, false,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
case lnrpc.AddressType_NESTED_PUBKEY_HASH:
|
||||
addr, err = r.server.cc.wallet.NewAddress(
|
||||
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())
|
||||
return &lnrpc.NewAddressResponse{Address: addr.String()}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user