mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 14:11:04 +02:00
rpc: verify address is for correct net
Verify that the addresses we're decoding when sending coins onchain are for the correct network. Without this check we'll convert the users addresses to their equivalent on other networks, which is a gross violation of the principle of least astonishment.
This commit is contained in:
committed by
Oliver Gugger
parent
4ea24c0820
commit
681e3ceede
14
rpcserver.go
14
rpcserver.go
@@ -970,6 +970,11 @@ func addrPairsToOutputs(addrPairs map[string]int64,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !addr.IsForNet(params) {
|
||||
return nil, fmt.Errorf("address is not for %s",
|
||||
params.Name)
|
||||
}
|
||||
|
||||
pkscript, err := txscript.PayToAddrScript(addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -2579,7 +2584,14 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
||||
in.DeliveryAddress, r.cfg.ActiveNetParams.Params,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid delivery address: %v", err)
|
||||
return fmt.Errorf("invalid delivery address: "+
|
||||
"%v", err)
|
||||
}
|
||||
|
||||
if !addr.IsForNet(r.cfg.ActiveNetParams.Params) {
|
||||
return fmt.Errorf("delivery address is not "+
|
||||
"for %s",
|
||||
r.cfg.ActiveNetParams.Params.Name)
|
||||
}
|
||||
|
||||
// Create a script to pay out to the address provided.
|
||||
|
Reference in New Issue
Block a user