rpcserver+lnd_test: adding check in SendCoins to prevent txs sent to pubkeys

This commit is contained in:
ccdle12 committed 2019-04-20 10:12:20 +08:00
1 parent ab4a6750cc
commit c46457fb5b
2 files changed
+40 -1

No files matched your search

+9
View File
@@ -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