mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-11 05:14:04 +02:00
rpcserver+lnd_test: adding check in SendCoins to prevent txs sent to pubkeys
This commit is contained in:
@@ -913,6 +913,15 @@ func (r *rpcServer) SendCoins(ctx context.Context,
|
||||
activeNetParams.Params.Name)
|
||||
}
|
||||
|
||||
// If the destination address parses to a valid pubkey, we assume the user
|
||||
// accidently tried to send funds to a bare pubkey address. This check is
|
||||
// here to prevent unintended transfers.
|
||||
decodedAddr, _ := hex.DecodeString(in.Addr)
|
||||
_, err = btcec.ParsePubKey(decodedAddr, btcec.S256())
|
||||
if err == nil {
|
||||
return nil, fmt.Errorf("cannot send coins to pubkeys")
|
||||
}
|
||||
|
||||
var txid *chainhash.Hash
|
||||
|
||||
wallet := r.server.cc.wallet
|
||||
|
Reference in New Issue
Block a user