rpcserver+lnd_test: adding check in SendCoins to prevent txs sent to pubkeys
This commit is contained in:
2 files changed
+40
-1
No files matched your search
@@ -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